diff options
author | Devang Patel <dpatel@apple.com> | 2010-06-16 00:53:55 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2010-06-16 00:53:55 +0000 |
commit | a6d20f446fe3b19112e54dc7f1468b3ff0f2f50a (patch) | |
tree | 24f7e34a01e20f46ac77c0123fd57f836b0200a0 | |
parent | 6972a62c8feda5ac53125978170f89657d978d4e (diff) | |
download | bcm5719-llvm-a6d20f446fe3b19112e54dc7f1468b3ff0f2f50a.tar.gz bcm5719-llvm-a6d20f446fe3b19112e54dc7f1468b3ff0f2f50a.zip |
Use separate named MDNode to hold each function's local variable info.
This speeds up local variable handling in DwarfDebug.
llvm-svn: 106075
-rw-r--r-- | llvm/include/llvm/Module.h | 1 | ||||
-rw-r--r-- | llvm/lib/Analysis/DebugInfo.cpp | 8 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 5 | ||||
-rw-r--r-- | llvm/lib/VMCore/Module.cpp | 7 |
4 files changed, 17 insertions, 4 deletions
diff --git a/llvm/include/llvm/Module.h b/llvm/include/llvm/Module.h index 901fada3ebf..15e0a17e1e5 100644 --- a/llvm/include/llvm/Module.h +++ b/llvm/include/llvm/Module.h @@ -326,6 +326,7 @@ public: /// 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 diff --git a/llvm/lib/Analysis/DebugInfo.cpp b/llvm/lib/Analysis/DebugInfo.cpp index 774dce06421..6ef160b9726 100644 --- a/llvm/lib/Analysis/DebugInfo.cpp +++ b/llvm/lib/Analysis/DebugInfo.cpp @@ -1053,8 +1053,12 @@ DIVariable DIFactory::CreateVariable(unsigned Tag, DIDescriptor Context, // 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); } diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 4705a0eed35..7da363fa561 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -2259,8 +2259,9 @@ void DwarfDebug::collectVariableInfo(const MachineFunction *MF) { } // 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)) diff --git a/llvm/lib/VMCore/Module.cpp b/llvm/lib/VMCore/Module.cpp index 94840f07a4a..a4c3d2e9a0e 100644 --- a/llvm/lib/VMCore/Module.cpp +++ b/llvm/lib/VMCore/Module.cpp @@ -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 @@ NamedMDNode *Module::getNamedMetadata(StringRef Name) const { 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. |