add new apis for getting/setting !dbg metadata on
authorChris Lattner <sabre@nondot.org>
Wed, 31 Mar 2010 03:34:40 +0000 (03:34 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 31 Mar 2010 03:34:40 +0000 (03:34 +0000)
instructions.  In addition to being a convenience,
they are faster than the old apis, particularly when
not going from an MDKindID like people should be
doing.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99982 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Instruction.h
include/llvm/Support/ValueHandle.h
lib/CodeGen/AsmPrinter/DwarfDebug.cpp
lib/CodeGen/SelectionDAG/FastISel.cpp
lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
lib/VMCore/Metadata.cpp

index 41841126b31dcb18c55fcf1def5d2af5dbb45806..472ab83f2e27d2c989211fae51c553670dc6a697 100644 (file)
@@ -156,6 +156,16 @@ public:
   void setMetadata(unsigned KindID, MDNode *Node);
   void setMetadata(const char *Kind, MDNode *Node);
 
+  /// setDbgMetadata - This is just an optimized helper function that is
+  /// equivalent to setMetadata("dbg", Node);
+  void setDbgMetadata(MDNode *Node);
+  
+  /// getDbgMetadata - This is just an optimized helper function that is
+  /// equivalent to calling getMetadata("dbg").
+  MDNode *getDbgMetadata() const {
+    return DbgInfo;
+  }
+  
 private:
   /// hasMetadataHashEntry - Return true if we have an entry in the on-the-side
   /// metadata hash.
index 0e61d093b9d8a688164a804f6c30510c9655ce7e..130a620ab2fa2a80f3fc1ec9e60580f6da14861f 100644 (file)
@@ -284,8 +284,7 @@ class TrackingVH : public ValueHandleBase {
     Value *VP = ValueHandleBase::getValPtr();
 
     // Null is always ok.
-    if (!VP)
-        return;
+    if (!VP) return;
 
     // Check that this value is valid (i.e., it hasn't been deleted). We
     // explicitly delay this check until access to avoid requiring clients to be
index 00a98fba0b4ca8fb5f94feb7eb845f7397ab193d..2f1a063924e905be284cce391c7b96e3ec96257d 100644 (file)
@@ -2014,7 +2014,8 @@ void DwarfDebug::collectVariableInfo() {
       // FIXME : Lift this restriction.
       if (MInsn->getNumOperands() != 3)
         continue;
-      DIVariable DV((MDNode*)(MInsn->getOperand(MInsn->getNumOperands() - 1).getMetadata()));
+      DIVariable DV((MDNode*)(MInsn->getOperand(MInsn->getNumOperands()
+                                                - 1).getMetadata()));
       if (DV.getTag() == dwarf::DW_TAG_arg_variable)  {
         // FIXME Handle inlined subroutine arguments.
         DbgVariable *ArgVar = new DbgVariable(DV, MInsn, NULL);
index 3fc30ff90886cdd6e48f382852b33698e63492e1..e4e9ef405f631700df9c76e2df309263b7c9db2b 100644 (file)
@@ -340,10 +340,9 @@ bool FastISel::SelectCall(User *I) {
       StaticAllocaMap.find(AI);
     if (SI == StaticAllocaMap.end()) break; // VLAs.
     int FI = SI->second;
-    if (MMI) {
-      if (MDNode *Dbg = DI->getMetadata("dbg"))
-        MMI->setVariableDbgInfo(DI->getVariable(), FI, Dbg);
-    }
+    if (MDNode *Dbg = DI->getDbgMetadata())
+      MMI->setVariableDbgInfo(DI->getVariable(), FI, Dbg);
+    
     // Building the map above is target independent.  Generating DBG_VALUE
     // inline is target dependent; do this now.
     (void)TargetSelectInstruction(cast<Instruction>(I));
index 7a0daf69c84c5c8247f476fe8ec142f1c608cbf4..922c6e8b02a97d64e701d0abfb2e5b13ea74be53 100644 (file)
@@ -3800,7 +3800,7 @@ SelectionDAGBuilder::visitIntrinsicCall(CallInst &I, unsigned Intrinsic) {
     int FI = SI->second;
 
     if (MachineModuleInfo *MMI = DAG.getMachineModuleInfo())
-      if (MDNode *Dbg = DI.getMetadata("dbg"))
+      if (MDNode *Dbg = DI.getDbgMetadata())
         MMI->setVariableDbgInfo(Variable, FI, Dbg);
     return 0;
   }
@@ -3852,7 +3852,7 @@ SelectionDAGBuilder::visitIntrinsicCall(CallInst &I, unsigned Intrinsic) {
       return 0; // VLAs.
     int FI = SI->second;
     if (MachineModuleInfo *MMI = DAG.getMachineModuleInfo())
-      if (MDNode *Dbg = DI.getMetadata("dbg"))
+      if (MDNode *Dbg = DI.getDbgMetadata())
         MMI->setVariableDbgInfo(Variable, FI, Dbg);
     return 0;
   }
index 77926f9af3466d39ee00d937a2ac31f4298782e3..6f794da9110b28d98d3e38091c59cc2f0d56b137 100644 (file)
@@ -424,6 +424,10 @@ MDNode *Instruction::getMetadataImpl(const char *Kind) const {
   return getMetadataImpl(getContext().getMDKindID(Kind));
 }
 
+void Instruction::setDbgMetadata(MDNode *Node) {
+  DbgInfo = Node;
+}
+
 /// setMetadata - Set the metadata of of the specified kind to the specified
 /// node.  This updates/replaces metadata if already present, or removes it if
 /// Node is null.