[llvm] r221813 - Temporary fix for PR21528 - use mangled C++ function names in COFF debug info to un-break ASan on Windows

Timur Iskhodzhanov timurrrr at google.com
Wed Nov 12 12:21:20 PST 2014


Author: timurrrr
Date: Wed Nov 12 14:21:20 2014
New Revision: 221813

URL: http://llvm.org/viewvc/llvm-project?rev=221813&view=rev
Log:
Temporary fix for PR21528 - use mangled C++ function names in COFF debug info to un-break ASan on Windows

Added:
    llvm/trunk/test/DebugInfo/COFF/cpp-mangling.ll
Modified:
    llvm/trunk/lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp?rev=221813&r1=221812&r2=221813&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp Wed Nov 12 14:21:20 2014
@@ -190,7 +190,14 @@ void WinCodeViewLineTables::emitDebugInf
     return;
   assert(FI.End && "Don't know where the function ends?");
 
-  const StringRef FuncName = getDISubprogram(GV).getDisplayName();
+  StringRef FuncName = getDISubprogram(GV).getDisplayName(),
+            GVName = GV->getName();
+  // FIXME Clang currently sets DisplayName to "bar" for a C++
+  // "namespace_foo::bar" function, see PR21528.  Luckily, dbghelp.dll is trying
+  // to demangle display names anyways, so let's just put a mangled name into
+  // the symbols subsection until Clang gives us what we need.
+  if (GVName.startswith("\01?"))
+    FuncName = GVName.substr(1);
   // Emit a symbol subsection, required by VS2012+ to find function boundaries.
   MCSymbol *SymbolsBegin = Asm->MMI->getContext().CreateTempSymbol(),
            *SymbolsEnd = Asm->MMI->getContext().CreateTempSymbol();

Added: llvm/trunk/test/DebugInfo/COFF/cpp-mangling.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/cpp-mangling.ll?rev=221813&view=auto
==============================================================================
--- llvm/trunk/test/DebugInfo/COFF/cpp-mangling.ll (added)
+++ llvm/trunk/test/DebugInfo/COFF/cpp-mangling.ll Wed Nov 12 14:21:20 2014
@@ -0,0 +1,43 @@
+; RUN: llc -mcpu=core2 -mtriple=i686-pc-win32 -o - -O0 < %s | llvm-mc -triple=i686-pc-win32 -filetype=obj | llvm-readobj -s -sr -codeview-linetables | FileCheck %s
+
+; This LL file was generated by running clang on the following code:
+; D:\src.cpp:
+;  1 namespace foo {
+;  2 int bar(int x) {
+;  3   return x * 2;
+;  4 }
+;  5 }
+
+; CHECK:        ProcStart {
+; FIXME: The display name should in fact be "foo::bar", see PR21528
+; CHECK-NEXT:     DisplayName: ?bar at foo@@YAHH at Z
+; CHECK-NEXT:     Section: ?bar at foo@@YAHH at Z
+
+; Function Attrs: nounwind
+define i32 @"\01?bar at foo@@YAHH at Z"(i32 %x) #0 {
+entry:
+  %x.addr = alloca i32, align 4
+  store i32 %x, i32* %x.addr, align 4
+  %0 = load i32* %x.addr, align 4, !dbg !11
+  %mul = mul nsw i32 %0, 2, !dbg !11
+  ret i32 %mul, !dbg !11
+}
+
+attributes #0 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!8, !9}
+!llvm.ident = !{!10}
+
+!0 = metadata !{metadata !"0x11\004\00clang version 3.6.0 \000\00\000\00\002", metadata !1, metadata !2, metadata !2, metadata !3, metadata !2, metadata !2} ; [ DW_TAG_compile_unit ] [D:\/<stdin>] [DW_LANG_C_plus_plus]
+!1 = metadata !{metadata !"<stdin>", metadata !"D:\5C"}
+!2 = metadata !{}
+!3 = metadata !{metadata !4}
+!4 = metadata !{metadata !"0x2e\00bar\00bar\00\002\000\001\000\000\00256\000\002", metadata !5, metadata !6, metadata !7, null, i32 (i32)* @"\01?bar at foo@@YAHH at Z", null, null, metadata !2} ; [ DW_TAG_subprogram ] [line 2] [def] [bar]
+!5 = metadata !{metadata !"src.cpp", metadata !"D:\5C"}
+!6 = metadata !{metadata !"0x29", metadata !5}    ; [ DW_TAG_file_type ] [D:\/src.cpp]
+!7 = metadata !{metadata !"0x15\00\000\000\000\000\000\000", null, null, null, metadata !2, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
+!8 = metadata !{i32 2, metadata !"Dwarf Version", i32 4}
+!9 = metadata !{i32 2, metadata !"Debug Info Version", i32 2}
+!10 = metadata !{metadata !"clang version 3.6.0 "}
+!11 = metadata !{i32 3, i32 0, metadata !4, null}





More information about the llvm-commits mailing list