/// 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
// 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);
}
}
// 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))
#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"
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.