<div dir="ltr">Yeah - is this necessary for CodeView? (does something break, or do you just get simple names where you'd prefer full mangled or qualified names)<br><br>It was chosen pretty deliberately to do it this way (use unqualified names) for gmlt to keep size down. Have you got numbers for the size delta for CodeView with this change? I'd really prefer to make the same choice for both - it'd seem a bit arbitrary to choose our size optimization based on differences in the kind of workloads we happen to have on these two platforms.<br><br>- David<br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jun 30, 2016 at 10:41 AM, Reid Kleckner via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rnk<br>
Date: Thu Jun 30 12:41:31 2016<br>
New Revision: 274246<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=274246&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=274246&view=rev</a><br>
Log:<br>
[codeview] Emit qualified display names if -gline-tables-only is on<br>
<br>
When -gmlt is on, we don't emit namespace or class scope information,<br>
and the CodeView emission code in LLVM can't compute the fully qualified<br>
name. If we know LLVM won't be able to get the name right, go ahead and<br>
emit the qualified name in the frontend.<br>
<br>
We could change our -gmlt emission strategy to include those scopes when<br>
emitting codeview, but that would increase memory usage and slow down<br>
LTO and add more complexity to debug info emission.<br>
<br>
The same problem exists when you debug a -gmlt binary with GDB, so we<br>
should consider removing '&& EmitCodeView' from the condition here at<br>
some point in the future after evaluating the impact on object file<br>
size.<br>
<br>
Modified:<br>
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp<br>
    cfe/trunk/test/CodeGenCXX/debug-info-codeview-display-name.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=274246&r1=274245&r2=274246&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=274246&r1=274245&r2=274246&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Jun 30 12:41:31 2016<br>
@@ -185,17 +185,27 @@ StringRef CGDebugInfo::getFunctionName(c<br>
   FunctionTemplateSpecializationInfo *Info =<br>
       FD->getTemplateSpecializationInfo();<br>
<br>
-  if (!Info && FII)<br>
+  // Emit the unqualified name in normal operation. LLVM and the debugger can<br>
+  // compute the fully qualified name from the scope chain. If we're only<br>
+  // emitting line table info, there won't be any scope chains, so emit the<br>
+  // fully qualified name here so that stack traces are more accurate.<br>
+  // FIXME: Do this when emitting DWARF as well as when emitting CodeView after<br>
+  // evaluating the size impact.<br>
+  bool UseQualifiedName = DebugKind == codegenoptions::DebugLineTablesOnly &&<br>
+                          CGM.getCodeGenOpts().EmitCodeView;<br>
+<br>
+  if (!Info && FII && !UseQualifiedName)<br>
     return FII->getName();<br>
<br>
-  // Otherwise construct human readable name for debug info.<br>
   SmallString<128> NS;<br>
   llvm::raw_svector_ostream OS(NS);<br>
   PrintingPolicy Policy(CGM.getLangOpts());<br>
   Policy.MSVCFormatting = CGM.getCodeGenOpts().EmitCodeView;<br>
+  if (!UseQualifiedName)<br>
+    FD->printName(OS);<br>
+  else<br>
+    FD->printQualifiedName(OS, Policy);<br>
<br>
-  // Print the unqualified name with some template arguments.<br>
-  FD->printName(OS);<br>
   // Add any template specialization args.<br>
   if (Info) {<br>
     const TemplateArgumentList *TArgs = Info->TemplateArguments;<br>
<br>
Modified: cfe/trunk/test/CodeGenCXX/debug-info-codeview-display-name.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-codeview-display-name.cpp?rev=274246&r1=274245&r2=274246&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-codeview-display-name.cpp?rev=274246&r1=274245&r2=274246&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/CodeGenCXX/debug-info-codeview-display-name.cpp (original)<br>
+++ cfe/trunk/test/CodeGenCXX/debug-info-codeview-display-name.cpp Thu Jun 30 12:41:31 2016<br>
@@ -1,14 +1,22 @@<br>
-// RUN: %clang_cc1 -fblocks -debug-info-kind=limited -gcodeview -emit-llvm %s -o - -triple=x86_64-pc-win32 -std=c++98 | \<br>
-// RUN:  grep 'DISubprogram' | sed -e 's/.*name: "\([^"]*\)".*/"\1"/' | FileCheck %s<br>
+// RUN: %clang_cc1 -fblocks -debug-info-kind=limited -gcodeview -emit-llvm %s \<br>
+// RUN:       -o - -triple=x86_64-pc-win32 -std=c++98 | \<br>
+// RUN:    grep 'DISubprogram' | sed -e 's/.*name: "\([^"]*\)".*/"\1"/' | \<br>
+// RUN:    FileCheck %s --check-prefix=CHECK --check-prefix=UNQUAL<br>
+// RUN: %clang_cc1 -fblocks -debug-info-kind=line-tables-only -gcodeview -emit-llvm %s \<br>
+// RUN:       -o - -triple=x86_64-pc-win32 -std=c++98 | \<br>
+// RUN:    grep 'DISubprogram' | sed -e 's/.*name: "\([^"]*\)".*/"\1"/' | \<br>
+// RUN:    FileCheck %s --check-prefix=CHECK --check-prefix=QUAL<br>
<br>
 void freefunc() { }<br>
 // CHECK-DAG: "freefunc"<br>
<br>
 namespace N {<br>
   int b() { return 0; }<br>
-// CHECK-DAG: "b"<br>
+// UNQUAL-DAG: "b"<br>
+// QUAL-DAG: "N::b"<br>
   namespace { void func() { } }<br>
-// CHECK-DAG: "func"<br>
+// UNQUAL-DAG: "func"<br>
+// QUAL-DAG: "N::`anonymous namespace'::func"<br>
 }<br>
<br>
 void _c(void) {<br>
@@ -19,19 +27,24 @@ void _c(void) {<br>
 struct foo {<br>
   int operator+(int);<br>
   foo(){}<br>
-// CHECK-DAG: "foo"<br>
+// UNQUAL-DAG: "foo"<br>
+// QUAL-DAG: "foo::foo"<br>
<br>
   ~foo(){}<br>
-// CHECK-DAG: "~foo"<br>
+// UNQUAL-DAG: "~foo"<br>
+// QUAL-DAG: "foo::~foo"<br>
<br>
   foo(int i){}<br>
-// CHECK-DAG: "foo"<br>
+// UNQUAL-DAG: "foo"<br>
+// QUAL-DAG: "foo::foo"<br>
<br>
   foo(char *q){}<br>
-// CHECK-DAG: "foo"<br>
+// UNQUAL-DAG: "foo"<br>
+// QUAL-DAG: "foo::foo"<br>
<br>
   static foo* static_method() { return 0; }<br>
-// CHECK-DAG: "static_method"<br>
+// UNQUAL-DAG: "static_method"<br>
+// QUAL-DAG: "foo::static_method"<br>
<br>
 };<br>
<br>
@@ -40,7 +53,8 @@ void use_foo() {<br>
   foo::static_method();<br>
 }<br>
<br>
-// CHECK-DAG: "operator+"<br>
+// UNQUAL-DAG: "operator+"<br>
+// QUAL-DAG: "foo::operator+"<br>
 int foo::operator+(int a) { return a; }<br>
<br>
 // PR17371<br>
@@ -60,11 +74,17 @@ void OverloadedNewDelete::operator delet<br>
 void OverloadedNewDelete::operator delete[](void *) { }<br>
 int OverloadedNewDelete::operator+(int x) { return x; };<br>
<br>
-// CHECK-DAG: "operator new"<br>
-// CHECK-DAG: "operator new[]"<br>
-// CHECK-DAG: "operator delete"<br>
-// CHECK-DAG: "operator delete[]"<br>
-// CHECK-DAG: "operator+"<br>
+// UNQUAL-DAG: "operator new"<br>
+// UNQUAL-DAG: "operator new[]"<br>
+// UNQUAL-DAG: "operator delete"<br>
+// UNQUAL-DAG: "operator delete[]"<br>
+// UNQUAL-DAG: "operator+"<br>
+// QUAL-DAG: "OverloadedNewDelete::operator new"<br>
+// QUAL-DAG: "OverloadedNewDelete::operator new[]"<br>
+// QUAL-DAG: "OverloadedNewDelete::operator delete"<br>
+// QUAL-DAG: "OverloadedNewDelete::operator delete[]"<br>
+// QUAL-DAG: "OverloadedNewDelete::operator+"<br>
+<br>
<br>
 template <typename T, void (*)(void)><br>
 void fn_tmpl() {}<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div></div>