<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Nov 5, 2014, at 1:33 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" class="">dblaikie@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><br class="Apple-interchange-newline"><br style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class="gmail_quote" style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">On Wed, Nov 5, 2014 at 11:19 AM, Frederic Riss<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:friss@apple.com" target="_blank" class="">friss@apple.com</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;">Author: friss<br class="">Date: Wed Nov  5 13:19:04 2014<br class="">New Revision: 221385<br class=""><br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project?rev=221385&view=rev" target="_blank" class="">http://llvm.org/viewvc/llvm-project?rev=221385&view=rev</a><br class="">Log:<br class="">[DebugInfo] Do not record artificial global initializer functions in the DeclCache.<br class=""><br class="">When we are generating the global initializer functions, we call<br class="">CGDebugInfo::EmitFunctionStart() with a valid decl which is describing<br class="">the initialized global variable. Do not update the DeclCache with this<br class="">key as it will overwrite the the cached variable DIGlobalVariable with<br class="">the newly created artificial DISubprogram.<br class=""><br class="">One could wonder if we should put artificial subprograms in the DIE tree<br class="">at all (there are vaild uses for them carrying line information though).<br class=""><br class="">Modified:<br class="">   <span class="Apple-converted-space"> </span>cfe/trunk/lib/CodeGen/CGDebugInfo.cpp<br class="">   <span class="Apple-converted-space"> </span>cfe/trunk/test/CodeGenCXX/debug-info-namespace.cpp<br class=""><br class="">Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=221385&r1=221384&r2=221385&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=221385&r1=221384&r2=221385&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)<br class="">+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Nov  5 13:19:04 2014<br class="">@@ -2527,7 +2527,10 @@ void CGDebugInfo::EmitFunctionStart(Glob<br class="">       getOrCreateFunctionType(D, FnType, Unit), Fn->hasInternalLinkage(),<br class="">       true /*definition*/, ScopeLine, Flags, CGM.getLangOpts().Optimize, Fn,<br class="">       TParamsArray, getFunctionDeclaration(D));<br class="">-  if (HasDecl)<br class="">+  // We might get here with a VarDecl in the case we're generating<br class="">+  // code for the initialization of globals. Do not record these decls<br class="">+  // as they will overwrite the actual VarDecl Decl in the cache.<br class="">+  if (HasDecl && isa<FunctionDecl>(D))<br class="">     DeclCache.insert(std::make_pair(D->getCanonicalDecl(), llvm::WeakVH(SP)));<br class=""><br class="">   // Push the function onto the lexical block stack.<br class=""><br class="">Modified: cfe/trunk/test/CodeGenCXX/debug-info-namespace.cpp<br class="">URL:<span class="Apple-converted-space"> </span><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" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-namespace.cpp?rev=221385&r1=221384&r2=221385&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/test/CodeGenCXX/debug-info-namespace.cpp (original)<br class="">+++ cfe/trunk/test/CodeGenCXX/debug-info-namespace.cpp Wed Nov  5 13:19:04 2014<br class="">@@ -5,8 +5,8 @@<br class=""> namespace A {<br class=""> #line 1 "foo.cpp"<br class=""> namespace B {<br class="">-int i;<br class="">-void f1() { }<br class="">+extern int i;<br class="">+int f1() { return 0; }<br class=""> void f1(int) { }<br class=""> struct foo;<br class=""> struct bar { };<br class="">@@ -19,7 +19,7 @@ using namespace B;<br class=""><br class=""> using namespace A;<br class=""> namespace E = A;<br class="">-<br class="">+int B::i = f1();<br class=""> int func(bool b) {<br class="">   if (b) {<br class="">     using namespace A::B;<br class="">@@ -51,8 +51,8 @@ using B::i;<br class=""> // CHECK: [[FILE]] {{.*}}debug-info-namespace.cpp"<br class=""> // CHECK: [[BAR:![0-9]*]] {{.*}} ; [ DW_TAG_structure_type ] [bar] [line 6, {{.*}}] [decl] [from ]<br class=""> // CHECK: [[F1:![0-9]*]] {{.*}} ; [ DW_TAG_subprogram ] [line 4] [def] [f1]<br class="">-// CHECK: [[FUNC:![0-9]*]] {{.*}} ; [ DW_TAG_subprogram ] {{.*}} [def] [func]<br class=""> // CHECK: [[FILE2]]} ; [ DW_TAG_file_type ] [{{.*}}foo.cpp]<br class="">+// CHECK: [[FUNC:![0-9]*]] {{.*}} ; [ DW_TAG_subprogram ] {{.*}} [def] [func]<br class=""></blockquote><div class=""><br class=""></div><div class="">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 class=""><br class=""></div></div></div></blockquote><div><br class=""></div><div>You misunderstood the change in the testcase. The metadata order change is a side effect from the patch, but it’s not this part that tests the change. (This kinda random order is a pain BTW. While I was investigating various fixes for that issue, I had to dig into quite a few failing test cases just to find out that things had only been reordered)</div><div><br class=""></div><div>I changed the global variable B::i to need an initializer function. If you run the version of the testcase I committed through a clang that hasn’t the patch, you’ll see that the import directive will point to the a global init function rather than to the variable. The real test performed wrt the patch is that the import directive really points to the variable and this test was already there and thus doesn’t appear in the patch.</div><div><br class=""></div><div>Fred</div><br class=""><blockquote type="cite" class=""><div class=""><div class="gmail_quote" style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"> // CHECK: [[I:![0-9]*]] = metadata !{metadata !"0x34\00i\00{{.*}}", metadata [[NS]], {{.*}} ; [ DW_TAG_variable ] [i]<br class=""> // 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 class=""> // CHECK: [[M1]] = metadata !{metadata !"0x3a\0011\00", metadata [[CTXT]], metadata [[NS]]} ; [ DW_TAG_imported_module ]<br class=""><br class=""><br class="">_______________________________________________<br class="">cfe-commits mailing list<br class=""><a href="mailto:cfe-commits@cs.uiuc.edu" class="">cfe-commits@cs.uiuc.edu</a><br class=""><a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank" class="">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a></blockquote></div></div></blockquote></div><br class=""></body></html>