<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 5, 2014 at 11:19 AM, Frederic Riss <span dir="ltr"><<a href="mailto:friss@apple.com" target="_blank">friss@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: friss<br>
Date: Wed Nov  5 13:19:04 2014<br>
New Revision: 221385<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=221385&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=221385&view=rev</a><br>
Log:<br>
[DebugInfo] Do not record artificial global initializer functions in the DeclCache.<br>
<br>
When we are generating the global initializer functions, we call<br>
CGDebugInfo::EmitFunctionStart() with a valid decl which is describing<br>
the initialized global variable. Do not update the DeclCache with this<br>
key as it will overwrite the the cached variable DIGlobalVariable with<br>
the newly created artificial DISubprogram.<br>
<br>
One could wonder if we should put artificial subprograms in the DIE tree<br>
at all (there are vaild uses for them carrying line information though).<br>
<br>
Modified:<br>
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp<br>
    cfe/trunk/test/CodeGenCXX/debug-info-namespace.cpp<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=221385&r1=221384&r2=221385&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=221385&r1=221384&r2=221385&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Nov  5 13:19:04 2014<br>
@@ -2527,7 +2527,10 @@ void CGDebugInfo::EmitFunctionStart(Glob<br>
       getOrCreateFunctionType(D, FnType, Unit), Fn->hasInternalLinkage(),<br>
       true /*definition*/, ScopeLine, Flags, CGM.getLangOpts().Optimize, Fn,<br>
       TParamsArray, getFunctionDeclaration(D));<br>
-  if (HasDecl)<br>
+  // We might get here with a VarDecl in the case we're generating<br>
+  // code for the initialization of globals. Do not record these decls<br>
+  // as they will overwrite the actual VarDecl Decl in the cache.<br>
+  if (HasDecl && isa<FunctionDecl>(D))<br>
     DeclCache.insert(std::make_pair(D->getCanonicalDecl(), llvm::WeakVH(SP)));<br>
<br>
   // Push the function onto the lexical block stack.<br>
<br>
Modified: cfe/trunk/test/CodeGenCXX/debug-info-namespace.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-namespace.cpp?rev=221385&r1=221384&r2=221385&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-namespace.cpp?rev=221385&r1=221384&r2=221385&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/CodeGenCXX/debug-info-namespace.cpp (original)<br>
+++ cfe/trunk/test/CodeGenCXX/debug-info-namespace.cpp Wed Nov  5 13:19:04 2014<br>
@@ -5,8 +5,8 @@<br>
 namespace A {<br>
 #line 1 "foo.cpp"<br>
 namespace B {<br>
-int i;<br>
-void f1() { }<br>
+extern int i;<br>
+int f1() { return 0; }<br>
 void f1(int) { }<br>
 struct foo;<br>
 struct bar { };<br>
@@ -19,7 +19,7 @@ using namespace B;<br>
<br>
 using namespace A;<br>
 namespace E = A;<br>
-<br>
+int B::i = f1();<br>
 int func(bool b) {<br>
   if (b) {<br>
     using namespace A::B;<br>
@@ -51,8 +51,8 @@ using B::i;<br>
 // CHECK: [[FILE]] {{.*}}debug-info-namespace.cpp"<br>
 // CHECK: [[BAR:![0-9]*]] {{.*}} ; [ DW_TAG_structure_type ] [bar] [line 6, {{.*}}] [decl] [from ]<br>
 // CHECK: [[F1:![0-9]*]] {{.*}} ; [ DW_TAG_subprogram ] [line 4] [def] [f1]<br>
-// CHECK: [[FUNC:![0-9]*]] {{.*}} ; [ DW_TAG_subprogram ] {{.*}} [def] [func]<br>
 // CHECK: [[FILE2]]} ; [ DW_TAG_file_type ] [{{.*}}foo.cpp]<br>
+// CHECK: [[FUNC:![0-9]*]] {{.*}} ; [ DW_TAG_subprogram ] {{.*}} [def] [func]<br></blockquote><div><br></div><div>Is there a more specific observable change we should be testing here? I assume if this produced a bug, it would be actually visible in some way not just "metadat order changed slightly".</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
 // CHECK: [[I:![0-9]*]] = metadata !{metadata !"0x34\00i\00{{.*}}", metadata [[NS]], {{.*}} ; [ DW_TAG_variable ] [i]<br>
 // CHECK: [[MODULES]] = metadata !{metadata [[M1:![0-9]*]], metadata [[M2:![0-9]*]], metadata [[M3:![0-9]*]], metadata [[M4:![0-9]*]], metadata [[M5:![0-9]*]], metadata [[M6:![0-9]*]], metadata [[M7:![0-9]*]], metadata [[M8:![0-9]*]], metadata [[M9:![0-9]*]], metadata [[M10:![0-9]*]], metadata [[M11:![0-9]*]], metadata [[M12:![0-9]*]], metadata [[M13:![0-9]*]]}<br>
 // CHECK: [[M1]] = metadata !{metadata !"0x3a\0011\00", metadata [[CTXT]], metadata [[NS]]} ; [ DW_TAG_imported_module ]<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div></div>