[llvm] r362038 - CodeView - add static data members to global variable debug info.

Amy Huang via llvm-commits llvm-commits at lists.llvm.org
Wed May 29 14:45:35 PDT 2019


Author: akhuang
Date: Wed May 29 14:45:34 2019
New Revision: 362038

URL: http://llvm.org/viewvc/llvm-project?rev=362038&view=rev
Log:
CodeView - add static data members to global variable debug info.

Summary:
Add static data members to IR debug info's list of global variables
so that they are emitted as S_CONSTANT records.

Related to https://bugs.llvm.org/show_bug.cgi?id=41615.

Reviewers: rnk

Subscribers: aprantl, cfe-commits, llvm-commits, thakis

Tags: #clang, #llvm

Differential Revision: https://reviews.llvm.org/D62167

Modified:
    llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
    llvm/trunk/test/DebugInfo/COFF/global-constants.ll

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp?rev=362038&r1=362037&r2=362038&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp Wed May 29 14:45:34 2019
@@ -3069,7 +3069,12 @@ void CodeViewDebug::emitDebugInfoForGlob
     OS.EmitBinaryData(SRef);
 
     OS.AddComment("Name");
-    emitNullTerminatedSymbolName(OS, DIGV->getDisplayName());
+    // Get fully qualified name if global is a static data member.
+    std::string Name = DIGV->getDisplayName();
+    if (const auto *MemberDecl = dyn_cast_or_null<DIDerivedType>(
+            DIGV->getRawStaticDataMemberDeclaration()))
+      Name = getFullyQualifiedName(MemberDecl->getScope(), Name);
+    emitNullTerminatedSymbolName(OS, Name);
     endSymbolRecord(SConstantEnd);
   }
 }

Modified: llvm/trunk/test/DebugInfo/COFF/global-constants.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/global-constants.ll?rev=362038&r1=362037&r2=362038&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/COFF/global-constants.ll (original)
+++ llvm/trunk/test/DebugInfo/COFF/global-constants.ll Wed May 29 14:45:34 2019
@@ -3,18 +3,25 @@
 
 ; C++ source to regenerate:
 ; const int Test1 = 1;
+; struct Foo { static const int Test2 = 2; };
 ; int main() {
-;   return Test1;
+;   return Test1 + Foo::Test2;
 ; }
 ; $ clang t.cpp -S -emit-llvm -g -gcodeview -o t.ll
 
-; ASM-LABEL:  .long 241              # Symbol subsection for globals
+; ASM-LABEL:  .long 241             # Symbol subsection for globals
 
-; ASM:        .short {{.*-.*}}       # Record length
-; ASM:        .short 4359            # Record kind: S_CONSTANT
-; ASM-NEXT:   .long 4099             # Type
-; ASM-NEXT:   .byte 0x01, 0x00       # Value
-; ASM-NEXT:   .asciz "Test1"         # Name
+; ASM:        .short {{.*-.*}}      # Record length
+; ASM:        .short 4359           # Record kind: S_CONSTANT
+; ASM-NEXT:   .long 4099            # Type
+; ASM-NEXT:   .byte 0x01, 0x00      # Value
+; ASM-NEXT:   .asciz "Test1"        # Name
+
+; ASM:        .short {{.*-.*}}      # Record length
+; ASM:        .short 4359           # Record kind: S_CONSTANT
+; ASM:        .long 4099            # Type
+; ASM:        .byte 0x02, 0x00      # Value
+; ASM:        .asciz "Foo::Test2"   # Name
 
 ; OBJ:        CodeViewDebugInfo [
 ; OBJ:          Section: .debug$S
@@ -27,6 +34,12 @@
 ; OBJ-NEXT:         Value: 1
 ; OBJ-NEXT:         Name: Test1
 ; OBJ-NEXT:       }
+; OBJ:            ConstantSym {
+; OBJ-NEXT:         Kind: S_CONSTANT (0x1107)
+; OBJ-NEXT:         Type: const int (0x1003)
+; OBJ-NEXT:         Value: 2
+; OBJ-NEXT:         Name: Foo::Test2
+; OBJ-NEXT:       }
 
 ; ModuleID = 't.cpp'
 source_filename = "t.cpp"
@@ -34,31 +47,39 @@ target datalayout = "e-m:w-i64:64-f80:12
 target triple = "x86_64-pc-windows-msvc"
 
 ; Function Attrs: noinline norecurse nounwind optnone
-define dso_local i32 @main() #0 !dbg !13 {
+define dso_local i32 @main() #0 !dbg !19 {
 entry:
   %retval = alloca i32, align 4
   store i32 0, i32* %retval, align 4
-  ret i32 1, !dbg !16
+  ret i32 3, !dbg !22
 }
 
+attributes #0 = { noinline norecurse nounwind optnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
+
 !llvm.dbg.cu = !{!0}
-!llvm.module.flags = !{!9, !10, !11}
-!llvm.ident = !{!12}
+!llvm.module.flags = !{!15, !16, !17}
+!llvm.ident = !{!18}
 
-!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 9.0.0 (https://github.com/llvm/llvm-project.git 4a1902b6739e3087a03c0ac7ab85b640764e9335)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3, nameTableKind: None)
-!1 = !DIFile(filename: "<stdin>", directory: "C:\5Csrc\5Ctest", checksumkind: CSK_MD5, checksum: "0d5ef00bdd80bdb409a3deac9938f20d")
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 9.0.0 (https://github.com/llvm/llvm-project.git 2b66a49044196d8b90d95d7d3b5246ccbe3abc05)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, globals: !10, nameTableKind: None)
+!1 = !DIFile(filename: "<stdin>", directory: "C:\5Csrc\5Ctest", checksumkind: CSK_MD5, checksum: "77cff5e1c7b260440ed03b23c18809c3")
 !2 = !{}
 !3 = !{!4}
-!4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression(DW_OP_constu, 1, DW_OP_stack_value))
-!5 = distinct !DIGlobalVariable(name: "Test1", scope: !0, file: !6, line: 1, type: !7, isLocal: true, isDefinition: true)
-!6 = !DIFile(filename: "t.cpp", directory: "C:\5Csrc\5Ctest", checksumkind: CSK_MD5, checksum: "0d5ef00bdd80bdb409a3deac9938f20d")
-!7 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !8)
-!8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
-!9 = !{i32 2, !"CodeView", i32 1}
-!10 = !{i32 2, !"Debug Info Version", i32 3}
-!11 = !{i32 1, !"wchar_size", i32 2}
-!12 = !{!"clang version 9.0.0 (https://github.com/llvm/llvm-project.git 4a1902b6739e3087a03c0ac7ab85b640764e9335)"}
-!13 = distinct !DISubprogram(name: "main", scope: !6, file: !6, line: 3, type: !14, scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
-!14 = !DISubroutineType(types: !15)
-!15 = !{!8}
-!16 = !DILocation(line: 4, scope: !13)
+!4 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Foo", file: !5, line: 3, size: 8, flags: DIFlagTypePassByValue, elements: !6, identifier: ".?AUFoo@@")
+!5 = !DIFile(filename: "t.cpp", directory: "C:\5Csrc\5Ctest", checksumkind: CSK_MD5, checksum: "77cff5e1c7b260440ed03b23c18809c3")
+!6 = !{!7}
+!7 = !DIDerivedType(tag: DW_TAG_member, name: "Test2", scope: !4, file: !5, line: 4, baseType: !8, flags: DIFlagStaticMember, extraData: i32 2)
+!8 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !9)
+!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!10 = !{!11, !13}
+!11 = !DIGlobalVariableExpression(var: !12, expr: !DIExpression(DW_OP_constu, 1, DW_OP_stack_value))
+!12 = distinct !DIGlobalVariable(name: "Test1", scope: null, file: !5, line: 1, type: !8, isLocal: true, isDefinition: true)
+!13 = !DIGlobalVariableExpression(var: !14, expr: !DIExpression(DW_OP_constu, 2, DW_OP_stack_value))
+!14 = distinct !DIGlobalVariable(name: "Test2", scope: !0, file: !5, line: 4, type: !8, isLocal: true, isDefinition: true, declaration: !7)
+!15 = !{i32 2, !"CodeView", i32 1}
+!16 = !{i32 2, !"Debug Info Version", i32 3}
+!17 = !{i32 1, !"wchar_size", i32 2}
+!18 = !{!"clang version 9.0.0 (https://github.com/llvm/llvm-project.git 2b66a49044196d8b90d95d7d3b5246ccbe3abc05)"}
+!19 = distinct !DISubprogram(name: "main", scope: !5, file: !5, line: 7, type: !20, scopeLine: 7, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
+!20 = !DISubroutineType(types: !21)
+!21 = !{!9}
+!22 = !DILocation(line: 8, scope: !19)




More information about the llvm-commits mailing list