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