[llvm-commits] [llvm] r106075 - in /llvm/trunk: include/llvm/Module.h lib/Analysis/DebugInfo.cpp lib/CodeGen/AsmPrinter/DwarfDebug.cpp lib/VMCore/Module.cpp

Devang Patel dpatel at apple.com
Tue Jun 15 17:53:55 PDT 2010


Author: dpatel
Date: Tue Jun 15 19:53:55 2010
New Revision: 106075

URL: http://llvm.org/viewvc/llvm-project?rev=106075&view=rev
Log:
Use separate named MDNode to hold each function's local variable info.
This speeds up local variable handling in DwarfDebug.

Modified:
    llvm/trunk/include/llvm/Module.h
    llvm/trunk/lib/Analysis/DebugInfo.cpp
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
    llvm/trunk/lib/VMCore/Module.cpp

Modified: llvm/trunk/include/llvm/Module.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Module.h?rev=106075&r1=106074&r2=106075&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Module.h (original)
+++ llvm/trunk/include/llvm/Module.h Tue Jun 15 19:53:55 2010
@@ -326,6 +326,7 @@
   /// specified name. This method returns null if a NamedMDNode with the 
   /// specified name is not found.
   NamedMDNode *getNamedMetadata(StringRef Name) const;
+  NamedMDNode *getNamedMetadataUsingTwine(Twine Name) const;
 
   /// getOrInsertNamedMetadata - Return the first named MDNode in the module 
   /// with the specified name. This method returns a new NamedMDNode if a 

Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=106075&r1=106074&r2=106075&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/DebugInfo.cpp (original)
+++ llvm/trunk/lib/Analysis/DebugInfo.cpp Tue Jun 15 19:53:55 2010
@@ -1053,8 +1053,12 @@
     // The optimizer may remove local variable. If there is an interest
     // to preserve variable info in such situation then stash it in a
     // named mdnode.
-    NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.lv");
-    NMD->addOperand(Node);
+    DISubprogram Fn(getDISubprogram(Context));
+    const Twine FnLVName = Twine("llvm.dbg.lv.", Fn.getName());
+    NamedMDNode *FnLocals = M.getNamedMetadataUsingTwine(FnLVName);
+    if (!FnLocals)
+      FnLocals = NamedMDNode::Create(VMContext, FnLVName, NULL, 0, &M);
+    FnLocals->addOperand(Node);
   }
   return DIVariable(Node);
 }

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=106075&r1=106074&r2=106075&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Tue Jun 15 19:53:55 2010
@@ -2259,8 +2259,9 @@
   }
 
   // Collect info for variables that were optimized out.
-  if (NamedMDNode *NMD = 
-      MF->getFunction()->getParent()->getNamedMetadata("llvm.dbg.lv")) {
+  const Twine FnLVName = Twine("llvm.dbg.lv.", MF->getFunction()->getName());
+  if (NamedMDNode *NMD =
+      MF->getFunction()->getParent()->getNamedMetadataUsingTwine(FnLVName)) {
     for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) {
       DIVariable DV(cast_or_null<MDNode>(NMD->getOperand(i)));
       if (!DV || !Processed.insert(DV))

Modified: llvm/trunk/lib/VMCore/Module.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Module.cpp?rev=106075&r1=106074&r2=106075&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Module.cpp (original)
+++ llvm/trunk/lib/VMCore/Module.cpp Tue Jun 15 19:53:55 2010
@@ -17,6 +17,7 @@
 #include "llvm/DerivedTypes.h"
 #include "llvm/GVMaterializer.h"
 #include "llvm/LLVMContext.h"
+#include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/LeakDetector.h"
@@ -316,6 +317,12 @@
   return NamedMDSymTab->lookup(Name);
 }
 
+NamedMDNode *Module::getNamedMetadataUsingTwine(Twine Name) const {
+  SmallString<256> NameData;
+  StringRef NameRef = Name.toStringRef(NameData);
+   return NamedMDSymTab->lookup(NameRef);
+}
+
 /// getOrInsertNamedMetadata - Return the first named MDNode in the module 
 /// with the specified name. This method returns a new NamedMDNode if a 
 /// NamedMDNode with the specified name is not found.





More information about the llvm-commits mailing list