<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Sep 9, 2013 at 12:23 PM, Manman Ren <span dir="ltr"><<a href="mailto:manman.ren@gmail.com" target="_blank">manman.ren@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: mren<br>
Date: Mon Sep 9 14:23:58 2013<br>
New Revision: 190330<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=190330&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=190330&view=rev</a><br>
Log:<br>
Debug Info: move DIScope::getContext to DwarfDebug.<br></blockquote><div><br></div><div>This seems a little unfortunate. Though admittedly it's not actually a feature of all DIScopes to have, themselves, a context.<br>
<br>What would happen if DIScope::getContext returned a DIScopeRef instead of a DIScope? It shouldn't need the map then, right? Seems like it would be a smaller change.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
DIScope::getContext is a wrapper function that calls the specific getContext<br>
method on each subclass. When we switch DIType::getContext to return DIScopeRef<br>
instead of DIScope, DIScope::getContext can no longer return a DIScope without<br>
a type identifier map.<br>
<br>
DIScope::getContext is only used by DwarfDebug, so we move it to DwarfDebug<br>
to have easy access to the type identifier map.<br>
<br>
Modified:<br>
llvm/trunk/include/llvm/DebugInfo.h<br>
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp<br>
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp<br>
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h<br>
llvm/trunk/lib/IR/DebugInfo.cpp<br>
<br>
Modified: llvm/trunk/include/llvm/DebugInfo.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo.h?rev=190330&r1=190329&r2=190330&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo.h?rev=190330&r1=190329&r2=190330&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/DebugInfo.h (original)<br>
+++ llvm/trunk/include/llvm/DebugInfo.h Mon Sep 9 14:23:58 2013<br>
@@ -200,9 +200,6 @@ namespace llvm {<br>
public:<br>
explicit DIScope(const MDNode *N = 0) : DIDescriptor (N) {}<br>
<br>
- /// Gets the parent scope for this scope node or returns a<br>
- /// default constructed scope.<br>
- DIScope getContext() const;<br>
StringRef getFilename() const;<br>
StringRef getDirectory() const;<br>
<br>
<br>
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp?rev=190330&r1=190329&r2=190330&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp?rev=190330&r1=190329&r2=190330&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp Mon Sep 9 14:23:58 2013<br>
@@ -913,19 +913,19 @@ void CompileUnit::constructTypeDIE(DIE &<br>
<br>
/// Return true if the type is appropriately scoped to be contained inside<br>
/// its own type unit.<br>
-static bool isTypeUnitScoped(DIType Ty) {<br>
+static bool isTypeUnitScoped(DIType Ty, const DwarfDebug *DD) {<br>
DIScope Parent = Ty.getContext();<br>
while (Parent) {<br>
// Don't generate a hash for anything scoped inside a function.<br>
if (Parent.isSubprogram())<br>
return false;<br>
- Parent = Parent.getContext();<br>
+ Parent = DD->getScopeContext(Parent);<br>
}<br>
return true;<br>
}<br>
<br>
/// Return true if the type should be split out into a type unit.<br>
-static bool shouldCreateTypeUnit(DICompositeType CTy) {<br>
+static bool shouldCreateTypeUnit(DICompositeType CTy, const DwarfDebug *DD) {<br>
uint16_t Tag = CTy.getTag();<br>
<br>
switch (Tag) {<br>
@@ -936,7 +936,7 @@ static bool shouldCreateTypeUnit(DICompo<br>
// If this is a class, structure, union, or enumeration type<br>
// that is not a declaration, is a type definition, and not scoped<br>
// inside a function then separate this out as a type unit.<br>
- if (CTy.isForwardDecl() || !isTypeUnitScoped(CTy))<br>
+ if (CTy.isForwardDecl() || !isTypeUnitScoped(CTy, DD))<br>
return 0;<br>
return 1;<br>
default:<br>
@@ -1138,7 +1138,7 @@ void CompileUnit::constructTypeDIE(DIE &<br>
}<br>
// If this is a type applicable to a type unit it then add it to the<br>
// list of types we'll compute a hash for later.<br>
- if (shouldCreateTypeUnit(CTy))<br>
+ if (shouldCreateTypeUnit(CTy, DD))<br>
DD->addTypeUnitType(&Buffer);<br>
}<br>
<br>
<br>
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=190330&r1=190329&r2=190330&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=190330&r1=190329&r2=190330&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Sep 9 14:23:58 2013<br>
@@ -2650,3 +2650,26 @@ void DwarfDebug::emitDebugStrDWO() {<br>
DIScope DwarfDebug::resolve(DIScopeRef SRef) const {<br>
return SRef.resolve(TypeIdentifierMap);<br>
}<br>
+<br>
+// If the current node has a parent scope then return that,<br>
+// else return an empty scope.<br>
+DIScope DwarfDebug::getScopeContext(DIScope S) const {<br>
+<br>
+ if (S.isType())<br>
+ return DIType(S).getContext();<br>
+<br>
+ if (S.isSubprogram())<br>
+ return DISubprogram(S).getContext();<br>
+<br>
+ if (S.isLexicalBlock())<br>
+ return DILexicalBlock(S).getContext();<br>
+<br>
+ if (S.isLexicalBlockFile())<br>
+ return DILexicalBlockFile(S).getContext();<br>
+<br>
+ if (S.isNameSpace())<br>
+ return DINameSpace(S).getContext();<br>
+<br>
+ assert((S.isFile() || S.isCompileUnit()) && "Unhandled type of scope.");<br>
+ return DIScope();<br>
+}<br>
<br>
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=190330&r1=190329&r2=190330&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=190330&r1=190329&r2=190330&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)<br>
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Mon Sep 9 14:23:58 2013<br>
@@ -690,6 +690,9 @@ public:<br>
/// or another context nested inside a subprogram.<br>
bool isSubprogramContext(const MDNode *Context);<br>
<br>
+ /// Gets the parent scope for this scope node or returns a<br>
+ /// default constructed scope.<br>
+ DIScope getScopeContext(DIScope S) const;<br>
};<br>
} // End of namespace llvm<br>
<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=190330&r1=190329&r2=190330&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfo.cpp?rev=190330&r1=190329&r2=190330&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/IR/DebugInfo.cpp (original)<br>
+++ llvm/trunk/lib/IR/DebugInfo.cpp Mon Sep 9 14:23:58 2013<br>
@@ -779,29 +779,6 @@ Value *DITemplateValueParameter::getValu<br>
return getField(DbgNode, 4);<br>
}<br>
<br>
-// If the current node has a parent scope then return that,<br>
-// else return an empty scope.<br>
-DIScope DIScope::getContext() const {<br>
-<br>
- if (isType())<br>
- return DIType(DbgNode).getContext();<br>
-<br>
- if (isSubprogram())<br>
- return DISubprogram(DbgNode).getContext();<br>
-<br>
- if (isLexicalBlock())<br>
- return DILexicalBlock(DbgNode).getContext();<br>
-<br>
- if (isLexicalBlockFile())<br>
- return DILexicalBlockFile(DbgNode).getContext();<br>
-<br>
- if (isNameSpace())<br>
- return DINameSpace(DbgNode).getContext();<br>
-<br>
- assert((isFile() || isCompileUnit()) && "Unhandled type of scope.");<br>
- return DIScope();<br>
-}<br>
-<br>
StringRef DIScope::getFilename() const {<br>
if (!DbgNode)<br>
return StringRef();<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>