[llvm] r219798 - DI: Use a `DenseMap` instead of named metadata, NFC
Duncan P. N. Exon Smith
dexonsmith at apple.com
Wed Oct 15 09:11:41 PDT 2014
Author: dexonsmith
Date: Wed Oct 15 11:11:41 2014
New Revision: 219798
URL: http://llvm.org/viewvc/llvm-project?rev=219798&view=rev
Log:
DI: Use a `DenseMap` instead of named metadata, NFC
Remove a strange round-trip through named metadata to assign preserved
local variables to their subprograms.
Modified:
llvm/trunk/include/llvm/IR/DIBuilder.h
llvm/trunk/include/llvm/IR/DebugInfo.h
llvm/trunk/lib/IR/DIBuilder.cpp
llvm/trunk/lib/IR/DebugInfo.cpp
Modified: llvm/trunk/include/llvm/IR/DIBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DIBuilder.h?rev=219798&r1=219797&r2=219798&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DIBuilder.h (original)
+++ llvm/trunk/include/llvm/IR/DIBuilder.h Wed Oct 15 11:11:41 2014
@@ -73,6 +73,9 @@ namespace llvm {
SmallVector<Value *, 4> AllGVs;
SmallVector<TrackingVH<MDNode>, 4> AllImportedModules;
+ /// Each subprogram's preserved local variables.
+ DenseMap<MDNode *, std::vector<TrackingVH<MDNode>>> PreservedVariables;
+
// Private use for multiple types of template parameters.
DITemplateValueParameter
createTemplateValueParameter(unsigned Tag, DIDescriptor Scope,
Modified: llvm/trunk/include/llvm/IR/DebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DebugInfo.h?rev=219798&r1=219797&r2=219798&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DebugInfo.h (original)
+++ llvm/trunk/include/llvm/IR/DebugInfo.h Wed Oct 15 11:11:41 2014
@@ -958,14 +958,6 @@ DISubprogram getDISubprogram(const MDNod
/// getDICompositeType - Find underlying composite type.
DICompositeType getDICompositeType(DIType T);
-/// getOrInsertFnSpecificMDNode - Return a NameMDNode that is suitable
-/// to hold function specific information.
-NamedMDNode *getOrInsertFnSpecificMDNode(Module &M, DISubprogram SP);
-
-/// getFnSpecificMDNode - Return a NameMDNode, if available, that is
-/// suitable to hold function specific information.
-NamedMDNode *getFnSpecificMDNode(const Module &M, DISubprogram SP);
-
/// createInlinedVariable - Create a new inlined variable based on current
/// variable.
/// @param DV Current Variable.
Modified: llvm/trunk/lib/IR/DIBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DIBuilder.cpp?rev=219798&r1=219797&r2=219798&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DIBuilder.cpp (original)
+++ llvm/trunk/lib/IR/DIBuilder.cpp Wed Oct 15 11:11:41 2014
@@ -73,13 +73,10 @@ void DIBuilder::finalize() {
DIType(TempSubprograms).replaceAllUsesWith(SPs);
for (unsigned i = 0, e = SPs.getNumElements(); i != e; ++i) {
DISubprogram SP(SPs.getElement(i));
- SmallVector<Value *, 4> Variables;
- if (NamedMDNode *NMD = getFnSpecificMDNode(M, SP)) {
- for (unsigned ii = 0, ee = NMD->getNumOperands(); ii != ee; ++ii)
- Variables.push_back(NMD->getOperand(ii));
- NMD->eraseFromParent();
- }
if (MDNode *Temp = SP.getVariablesNodes()) {
+ SmallVector<Value *, 4> Variables;
+ for (Value *V : PreservedVariables.lookup(SP))
+ Variables.push_back(V);
DIArray AV = getOrCreateArray(Variables);
DIType(Temp).replaceAllUsesWith(AV);
}
@@ -906,8 +903,8 @@ DIVariable DIBuilder::createLocalVariabl
// to preserve variable info in such situation then stash it in a
// named mdnode.
DISubprogram Fn(getDISubprogram(Scope));
- NamedMDNode *FnLocals = getOrInsertFnSpecificMDNode(M, Fn);
- FnLocals->addOperand(Node);
+ assert(Fn && "Missing subprogram for local variable");
+ PreservedVariables[Fn].push_back(Node);
}
DIVariable RetVar(Node);
assert(RetVar.isVariable() &&
Modified: llvm/trunk/lib/IR/DebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfo.cpp?rev=219798&r1=219797&r2=219798&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DebugInfo.cpp (original)
+++ llvm/trunk/lib/IR/DebugInfo.cpp Wed Oct 15 11:11:41 2014
@@ -936,47 +936,6 @@ unsigned DILocation::computeNewDiscrimin
return ++Ctx.pImpl->DiscriminatorTable[Key];
}
-/// fixupSubprogramName - Replace contains special characters used
-/// in a typical Objective-C names with '.' in a given string.
-static void fixupSubprogramName(DISubprogram Fn, SmallVectorImpl<char> &Out) {
- StringRef FName =
- Fn.getFunction() ? Fn.getFunction()->getName() : Fn.getName();
- FName = Function::getRealLinkageName(FName);
-
- StringRef Prefix("llvm.dbg.lv.");
- Out.reserve(FName.size() + Prefix.size());
- Out.append(Prefix.begin(), Prefix.end());
-
- bool isObjCLike = false;
- for (size_t i = 0, e = FName.size(); i < e; ++i) {
- char C = FName[i];
- if (C == '[')
- isObjCLike = true;
-
- if (isObjCLike && (C == '[' || C == ']' || C == ' ' || C == ':' ||
- C == '+' || C == '(' || C == ')'))
- Out.push_back('.');
- else
- Out.push_back(C);
- }
-}
-
-/// getFnSpecificMDNode - Return a NameMDNode, if available, that is
-/// suitable to hold function specific information.
-NamedMDNode *llvm::getFnSpecificMDNode(const Module &M, DISubprogram Fn) {
- SmallString<32> Name;
- fixupSubprogramName(Fn, Name);
- return M.getNamedMetadata(Name.str());
-}
-
-/// getOrInsertFnSpecificMDNode - Return a NameMDNode that is suitable
-/// to hold function specific information.
-NamedMDNode *llvm::getOrInsertFnSpecificMDNode(Module &M, DISubprogram Fn) {
- SmallString<32> Name;
- fixupSubprogramName(Fn, Name);
- return M.getOrInsertNamedMetadata(Name.str());
-}
-
/// createInlinedVariable - Create a new inlined variable based on current
/// variable.
/// @param DV Current Variable.
More information about the llvm-commits
mailing list