diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp index cd75c4085eb99e..f167cead4e2c55 100644 --- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp @@ -3092,14 +3092,6 @@ void CodeViewDebug::emitGlobalVariableList(ArrayRef Globals) { void CodeViewDebug::emitDebugInfoForGlobal(const CVGlobalVariable &CVGV) { const DIGlobalVariable *DIGV = CVGV.DIGV; - - const DIScope *Scope = DIGV->getScope(); - // For static data members, get the scope from the declaration. - if (const auto *MemberDecl = dyn_cast_or_null( - DIGV->getRawStaticDataMemberDeclaration())) - Scope = MemberDecl->getScope(); - std::string QualifiedName = getFullyQualifiedName(Scope, DIGV->getName()); - if (const GlobalVariable *GV = CVGV.GVInfo.dyn_cast()) { // DataSym record, see SymbolRecord.h for more info. Thread local data @@ -3119,9 +3111,13 @@ void CodeViewDebug::emitDebugInfoForGlobal(const CVGlobalVariable &CVGV) { OS.EmitCOFFSectionIndex(GVSym); OS.AddComment("Name"); const unsigned LengthOfDataRecord = 12; - emitNullTerminatedSymbolName(OS, QualifiedName, LengthOfDataRecord); + emitNullTerminatedSymbolName( + OS, getFullyQualifiedName(DIGV->getScope(), DIGV->getName()), + LengthOfDataRecord); endSymbolRecord(DataEnd); } else { + // FIXME: Currently this only emits the global variables in the IR metadata. + // This should also emit enums and static data members. const DIExpression *DIE = CVGV.GVInfo.get(); assert(DIE->isConstant() && "Global constant variables must contain a constant expression."); @@ -3141,7 +3137,13 @@ void CodeViewDebug::emitDebugInfoForGlobal(const CVGlobalVariable &CVGV) { OS.emitBinaryData(SRef); OS.AddComment("Name"); - emitNullTerminatedSymbolName(OS, QualifiedName); + const DIScope *Scope = DIGV->getScope(); + // For static data members, get the scope from the declaration. + if (const auto *MemberDecl = dyn_cast_or_null( + DIGV->getRawStaticDataMemberDeclaration())) + Scope = MemberDecl->getScope(); + emitNullTerminatedSymbolName(OS, + getFullyQualifiedName(Scope, DIGV->getName())); endSymbolRecord(SConstantEnd); } } diff --git a/llvm/test/DebugInfo/COFF/global-constants.ll b/llvm/test/DebugInfo/COFF/global-constants.ll index d008252e6977a5..7f68465da00f13 100644 --- a/llvm/test/DebugInfo/COFF/global-constants.ll +++ b/llvm/test/DebugInfo/COFF/global-constants.ll @@ -1,17 +1,17 @@ ; RUN: llc < %s | FileCheck %s --check-prefix=ASM ; RUN: llc < %s -filetype=obj | llvm-readobj - --codeview | FileCheck %s --check-prefix=OBJ -; // C++ source to regenerate: +; C++ source to regenerate: ; namespace Test1 { ; const float TestConst1 = 3.14; ; } ; struct S { ; static const int TestConst2 = -10; ; enum { SEnum = 42 }; -; }; +; } ; enum TestEnum : int { -; ENUM_A = 2147000000, -; ENUM_B = -2147000000, +; ENUM_A = 2147000000, +; ENUM_B = -2147000000, ; }; ; void useConst(int); ; void foo() { @@ -20,33 +20,27 @@ ; useConst(ENUM_B); ; useConst(S::SEnum); ; } -; -; $ clang a.cpp -S -emit-llvm -g -gcodeview +; $ clang t.cpp -S -emit-llvm -g -gcodeview -o t.ll ; ASM-LABEL: .long 241 # Symbol subsection for globals - -; ASM: .short 4359 # Record kind: S_CONSTANT -; ASM-NEXT: .long 4099 # Type -; ASM-NEXT: .byte 0x04, 0x80, 0xc3, 0xf5 # Value -; ASM-NEXT: .byte 0x48, 0x40 -; ASM-NEXT: .asciz "Test1::TestConst1" # Name -; ASM-NEXT: .p2align 2 - -; ASM: .short 4359 # Record kind: S_CONSTANT -; ASM-NEXT: .long 4100 # Type -; ASM-NEXT: .byte 0x0a, 0x80, 0xf6, 0xff # Value -; ASM-NEXT: .byte 0xff, 0xff, 0xff, 0xff -; ASM-NEXT: .byte 0xff, 0xff -; ASM-NEXT: .asciz "S::TestConst2" # Name -; ASM-NEXT: .p2align 2 - -; ASM: .short 4359 # Record kind: S_CONSTANT -; ASM-NEXT: .long 4110 # Type -; ASM-NEXT: .byte 0x0a, 0x80, 0x40, 0x61 # Value -; ASM-NEXT: .byte 0x07, 0x80, 0xff, 0xff -; ASM-NEXT: .byte 0xff, 0xff -; ASM-NEXT: .asciz "ENUM_B" # Name -; ASM-NEXT: .p2align 2 +; ASM: .short {{.*-.*}} # Record length +; ASM: .short 4359 # Record kind: S_CONSTANT +; ASM-NEXT: .long 4102 # Type +; ASM-NEXT: .byte 0x04, 0x80, 0xc3, 0xf5 # Value +; ASM-NEXT: .byte 0x48, 0x40 +; ASM-NEXT: .asciz "Test1::TestConst1" # Name +; ASM: .short {{.*-.*}} # Record length +; ASM: .short 4359 # Record kind: S_CONSTANT +; ASM-NEXT: .long 4103 # Type +; ASM-NEXT: .byte 0x61, 0x00 # Value +; ASM-NEXT: .asciz "S::TestConst2" # Name +; ASM: .short {{.*-.*}} # Record length +; ASM: .short 4359 # Record kind: S_CONSTANT +; ASM-NEXT: .long 4105 # Type +; ASM-NEXT: .byte 0x0a, 0x80, 0x40, 0x61 # Value +; ASM-NEXT: .byte 0x07, 0x80, 0xff, 0xff +; ASM-NEXT: .byte 0xff, 0xff +; ASM-NEXT: .asciz "ENUM_B" # Name ; ASM-NOT: .asciz "S::SEnum" # Name ; OBJ: CodeViewDebugInfo [ @@ -56,85 +50,110 @@ ; OBJ: SubSectionType: Symbols (0xF1) ; OBJ: ConstantSym { ; OBJ-NEXT: Kind: S_CONSTANT (0x1107) -; OBJ-NEXT: Type: const float (0x1003) +; OBJ-NEXT: Type: const float (0x1006) ; OBJ-NEXT: Value: 1078523331 ; OBJ-NEXT: Name: Test1::TestConst1 ; OBJ-NEXT: } ; OBJ-NEXT: ConstantSym { ; OBJ-NEXT: Kind: S_CONSTANT (0x1107) -; OBJ-NEXT: Type: const int (0x1004) -; OBJ-NEXT: Value: 18446744073709551606 +; OBJ-NEXT: Type: const char (0x1007) +; OBJ-NEXT: Value: 97 ; OBJ-NEXT: Name: S::TestConst2 ; OBJ-NEXT: } ; OBJ-NEXT: ConstantSym { ; OBJ-NEXT: Kind: S_CONSTANT (0x1107) -; OBJ-NEXT: Type: TestEnum (0x100E) +; OBJ-NEXT: Type: TestEnum (0x1009) ; OBJ-NEXT: Value: 18446744071562551616 ; OBJ-NEXT: Name: ENUM_B ; OBJ-NEXT: } ; OBJ-NOT: Name: S::SEnum -; ModuleID = 'a.cpp' -source_filename = "a.cpp" -target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" -target triple = "x86_64-pc-windows-msvc19.25.28614" +; ModuleID = 't.cpp' +source_filename = "t.cpp" +target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-pc-windows-msvc19.16.27030" + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @"?useConst@@YAXH@Z"(i32) #0 !dbg !32 { +entry: + %.addr = alloca i32, align 4 + store i32 %0, i32* %.addr, align 4 + call void @llvm.dbg.declare(metadata i32* %.addr, metadata !36, metadata !DIExpression()), !dbg !37 + ret void, !dbg !37 +} + +; Function Attrs: nounwind readnone speculatable +declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 -; Function Attrs: noinline optnone uwtable -define dso_local void @"?foo@@YAXXZ"() #0 !dbg !31 { +; Function Attrs: noinline norecurse nounwind optnone uwtable +define dso_local i32 @main() #2 !dbg !38 { entry: - call void @"?useConst@@YAXH@Z"(i32 3), !dbg !35 - call void @"?useConst@@YAXH@Z"(i32 -10), !dbg !36 - call void @"?useConst@@YAXH@Z"(i32 -2147000000), !dbg !37 - call void @"?useConst@@YAXH@Z"(i32 42), !dbg !38 - ret void, !dbg !39 + %retval = alloca i32, align 4 + store i32 0, i32* %retval, align 4 + call void @"?useConst@@YAXH@Z"(i32 3), !dbg !41 + call void @"?useConst@@YAXH@Z"(i32 97), !dbg !42 + call void @"?useConst@@YAXH@Z"(i32 -2147000000), !dbg !43 + call void @"?useConst@@YAXH@Z"(i32 42), !dbg !44 + call void @llvm.debugtrap(), !dbg !45 + ret i32 0, !dbg !46 } -declare dso_local void @"?useConst@@YAXH@Z"(i32) #1 +; Function Attrs: nounwind +declare void @llvm.debugtrap() #3 -attributes #0 = { noinline optnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "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-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } -attributes #1 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #0 = { noinline nounwind optnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "frame-pointer"="none" "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-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #1 = { nounwind readnone speculatable } +attributes #2 = { noinline norecurse nounwind optnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "frame-pointer"="none" "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-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #3 = { nounwind } !llvm.dbg.cu = !{!0} -!llvm.module.flags = !{!26, !27, !28, !29} -!llvm.ident = !{!30} +!llvm.module.flags = !{!27, !28, !29, !30} +!llvm.ident = !{!31} -!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 11.0.0 (https://github.com/llvm/llvm-project.git 202f144bffd0be254a829924195e1b8ebabcbb79)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !15, globals: !16, nameTableKind: None) -!1 = !DIFile(filename: "a.cpp", directory: "F:\\llvm-project\\__test", checksumkind: CSK_MD5, checksum: "a1dbf3aabea9e8f9d1be48f60287942f") -!2 = !{!3, !11} -!3 = !DICompositeType(tag: DW_TAG_enumeration_type, scope: !4, file: !1, line: 6, baseType: !8, size: 32, elements: !9, identifier: ".?AW4@S@@") +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 9.0.0 (https://github.com/llvm/llvm-project.git f60f863075c7056f26e701b0405fc5752f0db576)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !16, globals: !17, nameTableKind: None) +!1 = !DIFile(filename: "t.cpp", directory: "C:\5Csrc\5Ctesting", checksumkind: CSK_MD5, checksum: "70da26ef1009521e2127bf71f8d532a2") +!2 = !{!3, !12} +!3 = !DICompositeType(tag: DW_TAG_enumeration_type, scope: !4, file: !1, line: 6, baseType: !9, size: 32, elements: !10, identifier: ".?AW4@S@@") !4 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S", file: !1, line: 4, size: 8, flags: DIFlagTypePassByValue, elements: !5, identifier: ".?AUS@@") !5 = !{!6, !3} -!6 = !DIDerivedType(tag: DW_TAG_member, name: "TestConst2", scope: !4, file: !1, line: 5, baseType: !7, flags: DIFlagStaticMember, extraData: i32 -10) +!6 = !DIDerivedType(tag: DW_TAG_member, name: "TestConst2", scope: !4, file: !1, line: 5, baseType: !7, flags: DIFlagStaticMember, extraData: i8 97) !7 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !8) -!8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) -!9 = !{!10} -!10 = !DIEnumerator(name: "SEnum", value: 42) -!11 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "TestEnum", file: !1, line: 8, baseType: !8, size: 32, elements: !12, identifier: ".?AW4TestEnum@@") -!12 = !{!13, !14} -!13 = !DIEnumerator(name: "ENUM_A", value: 2147000000) -!14 = !DIEnumerator(name: "ENUM_B", value: -2147000000) -!15 = !{!4} -!16 = !{!17, !22, !24} -!17 = !DIGlobalVariableExpression(var: !18, expr: !DIExpression(DW_OP_constu, 1078523331, DW_OP_stack_value)) -!18 = distinct !DIGlobalVariable(name: "TestConst1", scope: !19, file: !1, line: 2, type: !20, isLocal: true, isDefinition: true) -!19 = !DINamespace(name: "Test1", scope: null) -!20 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !21) -!21 = !DIBasicType(name: "float", size: 32, encoding: DW_ATE_float) -!22 = !DIGlobalVariableExpression(var: !23, expr: !DIExpression(DW_OP_constu, 18446744073709551606, DW_OP_stack_value)) -!23 = distinct !DIGlobalVariable(name: "TestConst2", scope: !0, file: !1, line: 5, type: !7, isLocal: true, isDefinition: true, declaration: !6) -!24 = !DIGlobalVariableExpression(var: !25, expr: !DIExpression(DW_OP_constu, 18446744071562551616, DW_OP_stack_value)) -!25 = distinct !DIGlobalVariable(name: "ENUM_B", scope: !0, file: !1, line: 10, type: !11, isLocal: true, isDefinition: true) -!26 = !{i32 2, !"CodeView", i32 1} -!27 = !{i32 2, !"Debug Info Version", i32 3} -!28 = !{i32 1, !"wchar_size", i32 2} -!29 = !{i32 7, !"PIC Level", i32 2} -!30 = !{!"clang version 11.0.0 (https://github.com/llvm/llvm-project.git 202f144bffd0be254a829924195e1b8ebabcbb79)"} -!31 = distinct !DISubprogram(name: "foo", linkageName: "?foo@@YAXXZ", scope: !1, file: !1, line: 13, type: !32, scopeLine: 13, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !34) -!32 = !DISubroutineType(types: !33) -!33 = !{null} -!34 = !{} -!35 = !DILocation(line: 14, scope: !31) -!36 = !DILocation(line: 15, scope: !31) -!37 = !DILocation(line: 16, scope: !31) -!38 = !DILocation(line: 17, scope: !31) -!39 = !DILocation(line: 18, scope: !31) +!8 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) +!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!10 = !{!11} +!11 = !DIEnumerator(name: "SEnum", value: 42) +!12 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "TestEnum", file: !1, line: 8, baseType: !9, size: 32, elements: !13, identifier: ".?AW4TestEnum@@") +!13 = !{!14, !15} +!14 = !DIEnumerator(name: "ENUM_A", value: 2147000000) +!15 = !DIEnumerator(name: "ENUM_B", value: -2147000000) +!16 = !{!4} +!17 = !{!18, !23, !25} +!18 = !DIGlobalVariableExpression(var: !19, expr: !DIExpression(DW_OP_constu, 1078523331, DW_OP_stack_value)) +!19 = distinct !DIGlobalVariable(name: "TestConst1", scope: !20, file: !1, line: 2, type: !21, isLocal: true, isDefinition: true) +!20 = !DINamespace(name: "Test1", scope: null) +!21 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !22) +!22 = !DIBasicType(name: "float", size: 32, encoding: DW_ATE_float) +!23 = !DIGlobalVariableExpression(var: !24, expr: !DIExpression(DW_OP_constu, 97, DW_OP_stack_value)) +!24 = distinct !DIGlobalVariable(name: "TestConst2", scope: !0, file: !1, line: 5, type: !7, isLocal: true, isDefinition: true, declaration: !6) +!25 = !DIGlobalVariableExpression(var: !26, expr: !DIExpression(DW_OP_constu, 18446744071562551616, DW_OP_stack_value)) +!26 = distinct !DIGlobalVariable(name: "ENUM_B", scope: !0, file: !1, line: 10, type: !12, isLocal: true, isDefinition: true) +!27 = !{i32 2, !"CodeView", i32 1} +!28 = !{i32 2, !"Debug Info Version", i32 3} +!29 = !{i32 1, !"wchar_size", i32 2} +!30 = !{i32 7, !"PIC Level", i32 2} +!31 = !{!"clang version 9.0.0 (https://github.com/llvm/llvm-project.git f60f863075c7056f26e701b0405fc5752f0db576)"} +!32 = distinct !DISubprogram(name: "useConst", linkageName: "?useConst@@YAXH@Z", scope: !1, file: !1, line: 12, type: !33, scopeLine: 12, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !35) +!33 = !DISubroutineType(types: !34) +!34 = !{null, !9} +!35 = !{} +!36 = !DILocalVariable(arg: 1, scope: !32, file: !1, line: 12, type: !9) +!37 = !DILocation(line: 12, scope: !32) +!38 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 13, type: !39, scopeLine: 13, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !35) +!39 = !DISubroutineType(types: !40) +!40 = !{!9} +!41 = !DILocation(line: 14, scope: !38) +!42 = !DILocation(line: 15, scope: !38) +!43 = !DILocation(line: 16, scope: !38) +!44 = !DILocation(line: 17, scope: !38) +!45 = !DILocation(line: 18, scope: !38) +!46 = !DILocation(line: 19, scope: !38) diff --git a/llvm/test/DebugInfo/COFF/global_visibility.ll b/llvm/test/DebugInfo/COFF/global_visibility.ll index 4a5eff8a6b28f4..8a3e8307785cb7 100644 --- a/llvm/test/DebugInfo/COFF/global_visibility.ll +++ b/llvm/test/DebugInfo/COFF/global_visibility.ll @@ -3,36 +3,34 @@ ; This test verifies global variables are emitted within the correct scope. ; ; -- global_visibility.cpp ---------------------------------------------------- -; int global_int = 0; -; -; template struct A { -; static T comdat_int; -; static T set(T value) { -; T r = comdat_int; -; comdat_int = value; -; return r; -; }; -; }; -; -; template T A::comdat_int = 42; -; -; void foo() { -; static int local_int = 1; -; { -; static int nested_int = 2; -; local_int = nested_int; -; } -; local_int = A::set(42); -; } -; -; void bar() { -; static int local_int = 3; -; { -; static int nested_int = 4; -; local_int = nested_int; -; } -; local_int = A::set(42); -; } +; 1 +; 2 int global_int = 0; +; 3 +; 4 template struct A { +; 5 static T comdat_int; +; 6 static T set(T value) { T r = comdat_int; comdat_int = value; return r; }; +; 7 }; +; 8 +; 9 template T A::comdat_int = 42; +; 10 +; 11 void foo() { +; 12 static int local_int = 1; +; 13 { +; 14 static int nested_int = 2; +; 15 local_int = nested_int; +; 16 } +; 17 local_int = A::set(42); +; 18 } +; 19 +; 20 void bar() { +; 21 static int local_int = 3; +; 22 { +; 23 static int nested_int = 4; +; 24 local_int = nested_int; +; 25 } +; 26 local_int = A::set(42); +; 27 } +; 28 ; ----------------------------------------------------------------------------- ; ; $ clang -S -emit-llvm -g -gcodeview global_visibility.cpp @@ -56,11 +54,17 @@ ; CHECK: DisplayName: foo::local_int ; CHECK: LinkageName: ?local_int@?1??foo@@YAXXZ@4HA ; CHECK: } +; CHECK: BlockSym { +; CHECK: Kind: S_BLOCK32 (0x1103) +; CHECK: } ; CHECK: DataSym { ; CHECK: Kind: S_LDATA32 (0x110C) ; CHECK: DisplayName: foo::nested_int ; CHECK: LinkageName: ?nested_int@?1??foo@@YAXXZ@4HA ; CHECK: } +; CHECK: ScopeEndSym { +; CHECK: Kind: S_END (0x6) +; CHECK: } ; CHECK: ProcEnd { ; CHECK: Kind: S_PROC_ID_END (0x114F) ; CHECK: } @@ -77,11 +81,17 @@ ; CHECK: DisplayName: bar::local_int ; CHECK: LinkageName: ?local_int@?1??bar@@YAXXZ@4HA ; CHECK: } +; CHECK: BlockSym { +; CHECK: Kind: S_BLOCK32 (0x1103) +; CHECK: } ; CHECK: DataSym { ; CHECK: Kind: S_LDATA32 (0x110C) ; CHECK: DisplayName: bar::nested_int ; CHECK: LinkageName: ?nested_int@?1??bar@@YAXXZ@4HA ; CHECK: } +; CHECK: ScopeEndSym { +; CHECK: Kind: S_END (0x6) +; CHECK: } ; CHECK: ProcEnd { ; CHECK: Kind: S_PROC_ID_END (0x114F) ; CHECK: } @@ -101,7 +111,7 @@ ; CHECK: SubSectionType: Symbols (0xF1) ; CHECK: GlobalData { ; CHECK: Kind: S_GDATA32 (0x110D) -; CHECK: DisplayName: A::comdat_int +; CHECK: DisplayName: comdat_int ; CHECK: LinkageName: ?comdat_int@?$A@H@@2HA ; CHECK: } ; CHECK: ] @@ -112,17 +122,17 @@ ; CHECK: SubSectionType: Symbols (0xF1) ; CHECK: GlobalData { ; CHECK: Kind: S_GDATA32 (0x110D) -; CHECK: DisplayName: A::comdat_int +; CHECK: DisplayName: comdat_int ; CHECK: LinkageName: ?comdat_int@?$A@I@@2IA ; CHECK: } ; CHECK: ] ; CHECK: ] ; -; ModuleID = 'a.cpp' -source_filename = "a.cpp" -target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" -target triple = "x86_64-pc-windows-msvc19.25.28614" +; ModuleID = 'global_visibility.cpp' +source_filename = "global_visibility.cpp" +target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-pc-windows-msvc19.15.26730" $"?set@?$A@H@@SAHH@Z" = comdat any @@ -157,88 +167,88 @@ entry: %r = alloca i32, align 4 store i32 %value, i32* %value.addr, align 4 call void @llvm.dbg.declare(metadata i32* %value.addr, metadata !50, metadata !DIExpression()), !dbg !51 - call void @llvm.dbg.declare(metadata i32* %r, metadata !52, metadata !DIExpression()), !dbg !53 - %0 = load i32, i32* @"?comdat_int@?$A@H@@2HA", align 4, !dbg !53 - store i32 %0, i32* %r, align 4, !dbg !53 - %1 = load i32, i32* %value.addr, align 4, !dbg !54 - store i32 %1, i32* @"?comdat_int@?$A@H@@2HA", align 4, !dbg !54 - %2 = load i32, i32* %r, align 4, !dbg !55 - ret i32 %2, !dbg !55 + call void @llvm.dbg.declare(metadata i32* %r, metadata !52, metadata !DIExpression()), !dbg !51 + %0 = load i32, i32* @"?comdat_int@?$A@H@@2HA", align 4, !dbg !51 + store i32 %0, i32* %r, align 4, !dbg !51 + %1 = load i32, i32* %value.addr, align 4, !dbg !51 + store i32 %1, i32* @"?comdat_int@?$A@H@@2HA", align 4, !dbg !51 + %2 = load i32, i32* %r, align 4, !dbg !51 + ret i32 %2, !dbg !51 } ; Function Attrs: noinline optnone uwtable define dso_local void @"?bar@@YAXXZ"() #0 !dbg !16 { entry: - %0 = load i32, i32* @"?nested_int@?1??bar@@YAXXZ@4HA", align 4, !dbg !56 - store i32 %0, i32* @"?local_int@?1??bar@@YAXXZ@4HA", align 4, !dbg !56 - %call = call i32 @"?set@?$A@I@@SAII@Z"(i32 42), !dbg !58 - store i32 %call, i32* @"?local_int@?1??bar@@YAXXZ@4HA", align 4, !dbg !58 - ret void, !dbg !59 + %0 = load i32, i32* @"?nested_int@?1??bar@@YAXXZ@4HA", align 4, !dbg !53 + store i32 %0, i32* @"?local_int@?1??bar@@YAXXZ@4HA", align 4, !dbg !53 + %call = call i32 @"?set@?$A@I@@SAII@Z"(i32 42), !dbg !55 + store i32 %call, i32* @"?local_int@?1??bar@@YAXXZ@4HA", align 4, !dbg !55 + ret void, !dbg !56 } ; Function Attrs: noinline nounwind optnone uwtable -define linkonce_odr dso_local i32 @"?set@?$A@I@@SAII@Z"(i32 %value) #1 comdat align 2 !dbg !60 { +define linkonce_odr dso_local i32 @"?set@?$A@I@@SAII@Z"(i32 %value) #1 comdat align 2 !dbg !57 { entry: %value.addr = alloca i32, align 4 %r = alloca i32, align 4 store i32 %value, i32* %value.addr, align 4 - call void @llvm.dbg.declare(metadata i32* %value.addr, metadata !61, metadata !DIExpression()), !dbg !62 - call void @llvm.dbg.declare(metadata i32* %r, metadata !63, metadata !DIExpression()), !dbg !64 - %0 = load i32, i32* @"?comdat_int@?$A@I@@2IA", align 4, !dbg !64 - store i32 %0, i32* %r, align 4, !dbg !64 - %1 = load i32, i32* %value.addr, align 4, !dbg !65 - store i32 %1, i32* @"?comdat_int@?$A@I@@2IA", align 4, !dbg !65 - %2 = load i32, i32* %r, align 4, !dbg !66 - ret i32 %2, !dbg !66 + call void @llvm.dbg.declare(metadata i32* %value.addr, metadata !58, metadata !DIExpression()), !dbg !59 + call void @llvm.dbg.declare(metadata i32* %r, metadata !60, metadata !DIExpression()), !dbg !59 + %0 = load i32, i32* @"?comdat_int@?$A@I@@2IA", align 4, !dbg !59 + store i32 %0, i32* %r, align 4, !dbg !59 + %1 = load i32, i32* %value.addr, align 4, !dbg !59 + store i32 %1, i32* @"?comdat_int@?$A@I@@2IA", align 4, !dbg !59 + %2 = load i32, i32* %r, align 4, !dbg !59 + ret i32 %2, !dbg !59 } -; Function Attrs: nounwind readnone speculatable willreturn +; Function Attrs: nounwind readnone speculatable declare void @llvm.dbg.declare(metadata, metadata, metadata) #2 -attributes #0 = { noinline optnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "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-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } -attributes #1 = { noinline nounwind optnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "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-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } -attributes #2 = { nounwind readnone speculatable willreturn } +attributes #0 = { noinline optnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "frame-pointer"="none" "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-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #1 = { noinline nounwind optnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "frame-pointer"="none" "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-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #2 = { nounwind readnone speculatable } !llvm.dbg.cu = !{!2} !llvm.module.flags = !{!40, !41, !42, !43} !llvm.ident = !{!44} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) -!1 = distinct !DIGlobalVariable(name: "global_int", linkageName: "?global_int@@3HA", scope: !2, file: !3, line: 1, type: !11, isLocal: false, isDefinition: true) -!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !3, producer: "clang version 11.0.0 (https://github.com/llvm/llvm-project.git 202f144bffd0be254a829924195e1b8ebabcbb79)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, nameTableKind: None) -!3 = !DIFile(filename: "a.cpp", directory: "F:\\llvm-project\\__test", checksumkind: CSK_MD5, checksum: "66a5399777dc9d37656fb00438bca542") +!1 = distinct !DIGlobalVariable(name: "global_int", linkageName: "?global_int@@3HA", scope: !2, file: !3, line: 2, type: !11, isLocal: false, isDefinition: true) +!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang version 8.0.0 (trunk)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, nameTableKind: None) +!3 = !DIFile(filename: "global_visibility.cpp", directory: "C:\5Cpath\5Cto\5Cdirectory", checksumkind: CSK_MD5, checksum: "f59b9e5de12391471b1a61888cb68a3e") !4 = !{} !5 = !{!0, !6, !12, !14, !17, !19, !29} !6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression()) -!7 = distinct !DIGlobalVariable(name: "local_int", scope: !8, file: !3, line: 15, type: !11, isLocal: true, isDefinition: true) -!8 = distinct !DISubprogram(name: "foo", linkageName: "?foo@@YAXXZ", scope: !3, file: !3, line: 14, type: !9, scopeLine: 14, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !4) +!7 = distinct !DIGlobalVariable(name: "local_int", scope: !8, file: !3, line: 12, type: !11, isLocal: true, isDefinition: true) +!8 = distinct !DISubprogram(name: "foo", linkageName: "?foo@@YAXXZ", scope: !3, file: !3, line: 11, type: !9, scopeLine: 11, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !4) !9 = !DISubroutineType(types: !10) !10 = !{null} !11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) !12 = !DIGlobalVariableExpression(var: !13, expr: !DIExpression()) -!13 = distinct !DIGlobalVariable(name: "nested_int", scope: !8, file: !3, line: 17, type: !11, isLocal: true, isDefinition: true) +!13 = distinct !DIGlobalVariable(name: "nested_int", scope: !46, file: !3, line: 14, type: !11, isLocal: true, isDefinition: true) !14 = !DIGlobalVariableExpression(var: !15, expr: !DIExpression()) -!15 = distinct !DIGlobalVariable(name: "local_int", scope: !16, file: !3, line: 24, type: !11, isLocal: true, isDefinition: true) -!16 = distinct !DISubprogram(name: "bar", linkageName: "?bar@@YAXXZ", scope: !3, file: !3, line: 23, type: !9, scopeLine: 23, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !4) +!15 = distinct !DIGlobalVariable(name: "local_int", scope: !16, file: !3, line: 21, type: !11, isLocal: true, isDefinition: true) +!16 = distinct !DISubprogram(name: "bar", linkageName: "?bar@@YAXXZ", scope: !3, file: !3, line: 20, type: !9, scopeLine: 20, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !4) !17 = !DIGlobalVariableExpression(var: !18, expr: !DIExpression()) -!18 = distinct !DIGlobalVariable(name: "nested_int", scope: !16, file: !3, line: 26, type: !11, isLocal: true, isDefinition: true) +!18 = distinct !DIGlobalVariable(name: "nested_int", scope: !54, file: !3, line: 23, type: !11, isLocal: true, isDefinition: true) !19 = !DIGlobalVariableExpression(var: !20, expr: !DIExpression()) -!20 = distinct !DIGlobalVariable(name: "comdat_int", linkageName: "?comdat_int@?$A@H@@2HA", scope: !2, file: !3, line: 12, type: !11, isLocal: false, isDefinition: true, declaration: !21) -!21 = !DIDerivedType(tag: DW_TAG_member, name: "comdat_int", scope: !22, file: !3, line: 4, baseType: !11, flags: DIFlagStaticMember) -!22 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "A", file: !3, line: 3, size: 8, flags: DIFlagTypePassByValue, elements: !23, templateParams: !27, identifier: ".?AU?$A@H@@") +!20 = distinct !DIGlobalVariable(name: "comdat_int", linkageName: "?comdat_int@?$A@H@@2HA", scope: !2, file: !3, line: 9, type: !11, isLocal: false, isDefinition: true, declaration: !21) +!21 = !DIDerivedType(tag: DW_TAG_member, name: "comdat_int", scope: !22, file: !3, line: 5, baseType: !11, flags: DIFlagStaticMember) +!22 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "A", file: !3, line: 4, size: 8, flags: DIFlagTypePassByValue, elements: !23, templateParams: !27, identifier: ".?AU?$A@H@@") !23 = !{!21, !24} -!24 = !DISubprogram(name: "set", linkageName: "?set@?$A@H@@SAHH@Z", scope: !22, file: !3, line: 5, type: !25, scopeLine: 5, flags: DIFlagPrototyped | DIFlagStaticMember, spFlags: 0) +!24 = !DISubprogram(name: "set", linkageName: "?set@?$A@H@@SAHH@Z", scope: !22, file: !3, line: 6, type: !25, scopeLine: 6, flags: DIFlagPrototyped | DIFlagStaticMember, spFlags: 0) !25 = !DISubroutineType(types: !26) !26 = !{!11, !11} !27 = !{!28} !28 = !DITemplateTypeParameter(name: "T", type: !11) !29 = !DIGlobalVariableExpression(var: !30, expr: !DIExpression()) -!30 = distinct !DIGlobalVariable(name: "comdat_int", linkageName: "?comdat_int@?$A@I@@2IA", scope: !2, file: !3, line: 12, type: !31, isLocal: false, isDefinition: true, declaration: !32) +!30 = distinct !DIGlobalVariable(name: "comdat_int", linkageName: "?comdat_int@?$A@I@@2IA", scope: !2, file: !3, line: 9, type: !31, isLocal: false, isDefinition: true, declaration: !32) !31 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned) -!32 = !DIDerivedType(tag: DW_TAG_member, name: "comdat_int", scope: !33, file: !3, line: 4, baseType: !31, flags: DIFlagStaticMember) -!33 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "A", file: !3, line: 3, size: 8, flags: DIFlagTypePassByValue, elements: !34, templateParams: !38, identifier: ".?AU?$A@I@@") +!32 = !DIDerivedType(tag: DW_TAG_member, name: "comdat_int", scope: !33, file: !3, line: 5, baseType: !31, flags: DIFlagStaticMember) +!33 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "A", file: !3, line: 4, size: 8, flags: DIFlagTypePassByValue, elements: !34, templateParams: !38, identifier: ".?AU?$A@I@@") !34 = !{!32, !35} -!35 = !DISubprogram(name: "set", linkageName: "?set@?$A@I@@SAII@Z", scope: !33, file: !3, line: 5, type: !36, scopeLine: 5, flags: DIFlagPrototyped | DIFlagStaticMember, spFlags: 0) +!35 = !DISubprogram(name: "set", linkageName: "?set@?$A@I@@SAII@Z", scope: !33, file: !3, line: 6, type: !36, scopeLine: 6, flags: DIFlagPrototyped | DIFlagStaticMember, spFlags: 0) !36 = !DISubroutineType(types: !37) !37 = !{!31, !31} !38 = !{!39} @@ -247,26 +257,20 @@ attributes #2 = { nounwind readnone speculatable willreturn } !41 = !{i32 2, !"Debug Info Version", i32 3} !42 = !{i32 1, !"wchar_size", i32 2} !43 = !{i32 7, !"PIC Level", i32 2} -!44 = !{!"clang version 11.0.0 (https://github.com/llvm/llvm-project.git 202f144bffd0be254a829924195e1b8ebabcbb79)"} -!45 = !DILocation(line: 18, scope: !46) -!46 = distinct !DILexicalBlock(scope: !8, file: !3, line: 16) -!47 = !DILocation(line: 20, scope: !8) -!48 = !DILocation(line: 21, scope: !8) -!49 = distinct !DISubprogram(name: "set", linkageName: "?set@?$A@H@@SAHH@Z", scope: !22, file: !3, line: 5, type: !25, scopeLine: 5, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, declaration: !24, retainedNodes: !4) -!50 = !DILocalVariable(name: "value", arg: 1, scope: !49, file: !3, line: 5, type: !11) -!51 = !DILocation(line: 5, scope: !49) +!44 = !{!"clang version 8.0.0 (trunk)"} +!45 = !DILocation(line: 15, scope: !46) +!46 = distinct !DILexicalBlock(scope: !8, file: !3, line: 13) +!47 = !DILocation(line: 17, scope: !8) +!48 = !DILocation(line: 18, scope: !8) +!49 = distinct !DISubprogram(name: "set", linkageName: "?set@?$A@H@@SAHH@Z", scope: !22, file: !3, line: 6, type: !25, scopeLine: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, declaration: !24, retainedNodes: !4) +!50 = !DILocalVariable(name: "value", arg: 1, scope: !49, file: !3, line: 6, type: !11) +!51 = !DILocation(line: 6, scope: !49) !52 = !DILocalVariable(name: "r", scope: !49, file: !3, line: 6, type: !11) -!53 = !DILocation(line: 6, scope: !49) -!54 = !DILocation(line: 7, scope: !49) -!55 = !DILocation(line: 8, scope: !49) -!56 = !DILocation(line: 27, scope: !57) -!57 = distinct !DILexicalBlock(scope: !16, file: !3, line: 25) -!58 = !DILocation(line: 29, scope: !16) -!59 = !DILocation(line: 30, scope: !16) -!60 = distinct !DISubprogram(name: "set", linkageName: "?set@?$A@I@@SAII@Z", scope: !33, file: !3, line: 5, type: !36, scopeLine: 5, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, declaration: !35, retainedNodes: !4) -!61 = !DILocalVariable(name: "value", arg: 1, scope: !60, file: !3, line: 5, type: !31) -!62 = !DILocation(line: 5, scope: !60) -!63 = !DILocalVariable(name: "r", scope: !60, file: !3, line: 6, type: !31) -!64 = !DILocation(line: 6, scope: !60) -!65 = !DILocation(line: 7, scope: !60) -!66 = !DILocation(line: 8, scope: !60) +!53 = !DILocation(line: 24, scope: !54) +!54 = distinct !DILexicalBlock(scope: !16, file: !3, line: 22) +!55 = !DILocation(line: 26, scope: !16) +!56 = !DILocation(line: 27, scope: !16) +!57 = distinct !DISubprogram(name: "set", linkageName: "?set@?$A@I@@SAII@Z", scope: !33, file: !3, line: 6, type: !36, scopeLine: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, declaration: !35, retainedNodes: !4) +!58 = !DILocalVariable(name: "value", arg: 1, scope: !57, file: !3, line: 6, type: !31) +!59 = !DILocation(line: 6, scope: !57) +!60 = !DILocalVariable(name: "r", scope: !57, file: !3, line: 6, type: !31) diff --git a/llvm/test/DebugInfo/COFF/globals.ll b/llvm/test/DebugInfo/COFF/globals.ll index 583f108f3f495f..3312e81618a917 100644 --- a/llvm/test/DebugInfo/COFF/globals.ll +++ b/llvm/test/DebugInfo/COFF/globals.ll @@ -6,44 +6,19 @@ ; C++ source to regenerate: ; $ cat a.cpp ; int first; -; ; template struct A { static const int comdat = 3; }; -; ; thread_local const int *middle = &A::comdat; -; ; namespace foo { ; thread_local int globalTLS = 4; ; static thread_local int staticTLS = 5; ; int justGlobal = 6; ; static int globalStatic = 7; -; constexpr int constExpr = 8; -; const int constVal = 9; -; -; struct Data { -; inline static thread_local int DataStaticTLS = 11; -; int DataGlobal = 12; -; inline static int DataStatic = 13; -; constexpr static int DataConstExpr = 14; -; const int DataConstVal = 15; -; }; -; } // namespace foo -; +; } ; int last; -; ; int bar() { -; struct Local { -; int LocalGlobal = 12; -; const int LocalConstVal = 15; -; }; -; foo::Data D; -; Local L; -; return foo::globalStatic + foo::globalTLS + foo::staticTLS + foo::justGlobal + -; foo::globalStatic + foo::constExpr + foo::constVal + D.DataStaticTLS + -; D.DataGlobal + D.DataStatic + D.DataConstExpr + D.DataConstVal + -; L.LocalGlobal + L.LocalConstVal; +; return foo::globalStatic + foo::globalTLS + foo::staticTLS; ; } -; -; $ clang-cl a.cpp /c /GS- /Z7 /GR- /std:c++17 /clang:-S /clang:-emit-llvm +; $ clang-cl a.cpp /c /Z7 /GS- /clang:-S /clang:-emit-llvm ; ASM: .section .debug$S,"dr" ; ASM-NEXT: .p2align 2 @@ -57,7 +32,7 @@ ; ASM-NEXT: .p2align 2 ; ASM: .short 4371 # Record kind: S_GTHREAD32 -; ASM-NEXT: .long 4117 # Type +; ASM-NEXT: .long 4100 # Type ; ASM-NEXT: .secrel32 "?middle@@3PEBHEB" # DataOffset ; ASM-NEXT: .secidx "?middle@@3PEBHEB" # Segment ; ASM-NEXT: .asciz "middle" # Name @@ -84,24 +59,6 @@ ; ASM-NEXT: .asciz "last" # Name ; ASM-NEXT: .p2align 2 -; ASM: .short 4359 # Record kind: S_CONSTANT -; ASM-NEXT: .long 4100 # Type -; ASM-NEXT: .byte 0x08, 0x00 # Value -; ASM-NEXT: .asciz "foo::constExpr" # Name -; ASM-NEXT: .p2align 2 - -; ASM: .short 4359 # Record kind: S_CONSTANT -; ASM-NEXT: .long 4100 # Type -; ASM-NEXT: .byte 0x09, 0x00 # Value -; ASM-NEXT: .asciz "foo::constVal" # Name -; ASM-NEXT: .p2align 2 - -; ASM: .short 4359 # Record kind: S_CONSTANT -; ASM-NEXT: .long 4100 # Type -; ASM-NEXT: .byte 0x0e, 0x00 # Value -; ASM-NEXT: .asciz "foo::Data::DataConstExpr" # Name -; ASM-NEXT: .p2align 2 - ; ASM: .short 4364 # Record kind: S_LDATA32 ; ASM-NEXT: .long 116 # Type ; ASM-NEXT: .secrel32 "?globalStatic@foo@@3HA" # DataOffset @@ -121,30 +78,10 @@ ; ASM-NEXT: .long 4 # Debug section magic ; ASM: .short 4365 # Record kind: S_GDATA32 -; ASM-NEXT: .long 4100 # Type +; ASM-NEXT: .long 4099 # Type ; ASM-NEXT: .secrel32 "?comdat@?$A@X@@2HB" # DataOffset ; ASM-NEXT: .secidx "?comdat@?$A@X@@2HB" # Segment -; ASM-NEXT: .asciz "A::comdat" # Name - -; ASM: .section .debug$S,"dr",associative,"?DataStaticTLS@Data@foo@@2HA" -; ASM-NEXT: .p2align 2 # Symbol subsection for ?DataStaticTLS@Data@foo@@2HA - -; ASM: .short 4371 # Record kind: S_GTHREAD32 -; ASM-NEXT: .long 116 # Type -; ASM-NEXT: .secrel32 "?DataStaticTLS@Data@foo@@2HA" # DataOffset -; ASM-NEXT: .secidx "?DataStaticTLS@Data@foo@@2HA" # Segment -; ASM-NEXT: .asciz "foo::Data::DataStaticTLS" # Name -; ASM-NEXT: .p2align 2 - -; ASM: .section .debug$S,"dr",associative,"?DataStatic@Data@foo@@2HA" -; ASM-NEXT: .p2align 2 # Symbol subsection for ?DataStatic@Data@foo@@2HA - -; ASM: .short 4365 # Record kind: S_GDATA32 -; ASM-NEXT: .long 116 # Type -; ASM-NEXT: .secrel32 "?DataStatic@Data@foo@@2HA" # DataOffset -; ASM-NEXT: .secidx "?DataStatic@Data@foo@@2HA" # Segment -; ASM-NEXT: .asciz "foo::Data::DataStatic" # Name -; ASM-NEXT: .p2align 2 +; ASM-NEXT: .asciz "comdat" # Name ; OBJ: CodeViewDebugInfo [ ; OBJ: Section: .debug$S @@ -161,7 +98,7 @@ ; OBJ-NEXT: GlobalTLS { ; OBJ-NEXT: Kind: S_GTHREAD32 (0x1113) ; OBJ-NEXT: DataOffset: ?middle@@3PEBHEB+0x0 -; OBJ-NEXT: Type: const int* (0x1015) +; OBJ-NEXT: Type: const int* (0x1004) ; OBJ-NEXT: DisplayName: middle ; OBJ-NEXT: LinkageName: ?middle@@3PEBHEB ; OBJ-NEXT: } @@ -186,24 +123,6 @@ ; OBJ-NEXT: DisplayName: last ; OBJ-NEXT: LinkageName: ?last@@3HA ; OBJ-NEXT: } -; OBJ-NEXT: ConstantSym { -; OBJ-NEXT: Kind: S_CONSTANT (0x1107) -; OBJ-NEXT: Type: const int (0x1004) -; OBJ-NEXT: Value: 8 -; OBJ-NEXT: Name: foo::constExpr -; OBJ-NEXT: } -; OBJ-NEXT: ConstantSym { -; OBJ-NEXT: Kind: S_CONSTANT (0x1107) -; OBJ-NEXT: Type: const int (0x1004) -; OBJ-NEXT: Value: 9 -; OBJ-NEXT: Name: foo::constVal -; OBJ-NEXT: } -; OBJ-NEXT: ConstantSym { -; OBJ-NEXT: Kind: S_CONSTANT (0x1107) -; OBJ-NEXT: Type: const int (0x1004) -; OBJ-NEXT: Value: 14 -; OBJ-NEXT: Name: foo::Data::DataConstExpr -; OBJ-NEXT: } ; OBJ-NEXT: DataSym { ; OBJ-NEXT: Kind: S_LDATA32 (0x110C) ; OBJ-NEXT: DataOffset: ?globalStatic@foo@@3HA+0x0 @@ -222,26 +141,10 @@ ; OBJ: GlobalData { ; OBJ-NEXT: Kind: S_GDATA32 (0x110D) ; OBJ-LABEL: DataOffset: ?comdat@?$A@X@@2HB+0x0 -; OBJ-NEXT: Type: const int (0x1004) -; OBJ-NEXT: DisplayName: A::comdat +; OBJ-NEXT: Type: const int (0x1003) +; OBJ-NEXT: DisplayName: comdat ; OBJ-NEXT: LinkageName: ?comdat@?$A@X@@2HB -; OBJ: GlobalTLS { -; OBJ-NEXT: Kind: S_GTHREAD32 (0x1113) -; OBJ-NEXT: DataOffset: ?DataStaticTLS@Data@foo@@2HA+0x0 -; OBJ-NEXT: Type: int (0x74) -; OBJ-NEXT: DisplayName: foo::Data::DataStaticTLS -; OBJ-NEXT: LinkageName: ?DataStaticTLS@Data@foo@@2HA -; OBJ-NEXT: } - -; OBJ: GlobalData { -; OBJ-NEXT: Kind: S_GDATA32 (0x110D) -; OBJ-NEXT: DataOffset: ?DataStatic@Data@foo@@2HA+0x0 -; OBJ-NEXT: Type: int (0x74) -; OBJ-NEXT: DisplayName: foo::Data::DataStatic -; OBJ-NEXT: LinkageName: ?DataStatic@Data@foo@@2HA -; OBJ-NEXT: } - ; YAML-LABEL: - Name: '.debug$S' ; YAML: Subsections: ; YAML: - !Symbols @@ -260,7 +163,7 @@ ; YAML-NOT: Segment ; YAML-NEXT: - Kind: S_GTHREAD32 ; YAML-NEXT: ThreadLocalDataSym: -; YAML-NEXT: Type: 4117 +; YAML-NEXT: Type: 4100 ; YAML-NEXT: DisplayName: middle ; YAML-NEXT: - Kind: S_GTHREAD32 ; YAML-NEXT: ThreadLocalDataSym: @@ -277,21 +180,6 @@ ; YAML-NEXT: DataSym: ; YAML-NEXT: Type: 116 ; YAML-NEXT: DisplayName: last -; YAML-NEXT: - Kind: S_CONSTANT -; YAML-NEXT: ConstantSym: -; YAML-NEXT: Type: 4100 -; YAML-NEXT: Value: 8 -; YAML-NEXT: Name: 'foo::constExpr' -; YAML-NEXT: - Kind: S_CONSTANT -; YAML-NEXT: ConstantSym: -; YAML-NEXT: Type: 4100 -; YAML-NEXT: Value: 9 -; YAML-NEXT: Name: 'foo::constVal' -; YAML-NEXT: - Kind: S_CONSTANT -; YAML-NEXT: ConstantSym: -; YAML-NEXT: Type: 4100 -; YAML-NEXT: Value: 14 -; YAML-NEXT: Name: 'foo::Data::DataConstExpr' ; YAML-NEXT: - Kind: S_LDATA32 ; YAML-NEXT: DataSym: ; YAML-NEXT: Type: 116 @@ -306,189 +194,72 @@ source_filename = "a.cpp" target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-pc-windows-msvc19.25.28614" -%"struct.foo::Data" = type { i32, i32 } -%struct.Local = type { i32, i32 } - -$"??0Data@foo@@QEAA@XZ" = comdat any - $"?comdat@?$A@X@@2HB" = comdat any -$"?DataStaticTLS@Data@foo@@2HA" = comdat any - -$"?DataStatic@Data@foo@@2HA" = comdat any - @"?first@@3HA" = dso_local global i32 0, align 4, !dbg !0 -@"?comdat@?$A@X@@2HB" = linkonce_odr dso_local constant i32 3, comdat, align 4, !dbg !17 -@"?middle@@3PEBHEB" = dso_local thread_local global i32* @"?comdat@?$A@X@@2HB", align 8, !dbg !24 -@"?globalTLS@foo@@3HA" = dso_local thread_local global i32 4, align 4, !dbg !27 -@"?justGlobal@foo@@3HA" = dso_local global i32 6, align 4, !dbg !29 -@"?last@@3HA" = dso_local global i32 0, align 4, !dbg !31 -@"?globalStatic@foo@@3HA" = internal global i32 7, align 4, !dbg !43 -@"?staticTLS@foo@@3HA" = internal thread_local global i32 5, align 4, !dbg !45 -@"?DataStaticTLS@Data@foo@@2HA" = linkonce_odr dso_local thread_local global i32 11, comdat, align 4, !dbg !37 -@"?DataStatic@Data@foo@@2HA" = linkonce_odr dso_local global i32 13, comdat, align 4, !dbg !39 - -; Function Attrs: noinline nounwind optnone uwtable -define dso_local i32 @"?bar@@YAHXZ"() #0 !dbg !54 { -entry: - %D = alloca %"struct.foo::Data", align 4 - %L = alloca %struct.Local, align 4 - call void @llvm.dbg.declare(metadata %"struct.foo::Data"* %D, metadata !57, metadata !DIExpression()), !dbg !58 - %call = call %"struct.foo::Data"* @"??0Data@foo@@QEAA@XZ"(%"struct.foo::Data"* %D) #2, !dbg !58 - call void @llvm.dbg.declare(metadata %struct.Local* %L, metadata !59, metadata !DIExpression()), !dbg !64 - %call1 = call %struct.Local* @"??0Local@?1??bar@@YAHXZ@QEAA@XZ"(%struct.Local* %L) #2, !dbg !64 - %0 = load i32, i32* @"?globalStatic@foo@@3HA", align 4, !dbg !65 - %1 = load i32, i32* @"?globalTLS@foo@@3HA", align 4, !dbg !65 - %add = add nsw i32 %0, %1, !dbg !65 - %2 = load i32, i32* @"?staticTLS@foo@@3HA", align 4, !dbg !65 - %add2 = add nsw i32 %add, %2, !dbg !65 - %3 = load i32, i32* @"?justGlobal@foo@@3HA", align 4, !dbg !65 - %add3 = add nsw i32 %add2, %3, !dbg !65 - %4 = load i32, i32* @"?globalStatic@foo@@3HA", align 4, !dbg !65 - %add4 = add nsw i32 %add3, %4, !dbg !65 - %add5 = add nsw i32 %add4, 8, !dbg !65 - %add6 = add nsw i32 %add5, 9, !dbg !65 - %5 = load i32, i32* @"?DataStaticTLS@Data@foo@@2HA", align 4, !dbg !65 - %add7 = add nsw i32 %add6, %5, !dbg !65 - %DataGlobal = getelementptr inbounds %"struct.foo::Data", %"struct.foo::Data"* %D, i32 0, i32 0, !dbg !65 - %6 = load i32, i32* %DataGlobal, align 4, !dbg !65 - %add8 = add nsw i32 %add7, %6, !dbg !65 - %7 = load i32, i32* @"?DataStatic@Data@foo@@2HA", align 4, !dbg !65 - %add9 = add nsw i32 %add8, %7, !dbg !65 - %add10 = add nsw i32 %add9, 14, !dbg !65 - %DataConstVal = getelementptr inbounds %"struct.foo::Data", %"struct.foo::Data"* %D, i32 0, i32 1, !dbg !65 - %8 = load i32, i32* %DataConstVal, align 4, !dbg !65 - %add11 = add nsw i32 %add10, %8, !dbg !65 - %LocalGlobal = getelementptr inbounds %struct.Local, %struct.Local* %L, i32 0, i32 0, !dbg !65 - %9 = load i32, i32* %LocalGlobal, align 4, !dbg !65 - %add12 = add nsw i32 %add11, %9, !dbg !65 - %LocalConstVal = getelementptr inbounds %struct.Local, %struct.Local* %L, i32 0, i32 1, !dbg !65 - %10 = load i32, i32* %LocalConstVal, align 4, !dbg !65 - %add13 = add nsw i32 %add12, %10, !dbg !65 - ret i32 %add13, !dbg !65 -} - -; Function Attrs: nounwind readnone speculatable willreturn -declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 - -; Function Attrs: noinline nounwind optnone uwtable -define linkonce_odr dso_local %"struct.foo::Data"* @"??0Data@foo@@QEAA@XZ"(%"struct.foo::Data"* returned %this) unnamed_addr #0 comdat align 2 !dbg !66 { -entry: - %this.addr = alloca %"struct.foo::Data"*, align 8 - store %"struct.foo::Data"* %this, %"struct.foo::Data"** %this.addr, align 8 - call void @llvm.dbg.declare(metadata %"struct.foo::Data"** %this.addr, metadata !71, metadata !DIExpression()), !dbg !73 - %this1 = load %"struct.foo::Data"*, %"struct.foo::Data"** %this.addr, align 8 - %DataGlobal = getelementptr inbounds %"struct.foo::Data", %"struct.foo::Data"* %this1, i32 0, i32 0, !dbg !74 - store i32 12, i32* %DataGlobal, align 4, !dbg !74 - %DataConstVal = getelementptr inbounds %"struct.foo::Data", %"struct.foo::Data"* %this1, i32 0, i32 1, !dbg !74 - store i32 15, i32* %DataConstVal, align 4, !dbg !74 - ret %"struct.foo::Data"* %this1, !dbg !74 -} +@"?comdat@?$A@X@@2HB" = linkonce_odr dso_local constant i32 3, comdat, align 4, !dbg !6 +@"?middle@@3PEBHEB" = dso_local thread_local global i32* @"?comdat@?$A@X@@2HB", align 8, !dbg !15 +@"?globalTLS@foo@@3HA" = dso_local thread_local global i32 4, align 4, !dbg !18 +@"?justGlobal@foo@@3HA" = dso_local global i32 6, align 4, !dbg !21 +@"?last@@3HA" = dso_local global i32 0, align 4, !dbg !23 +@"?globalStatic@foo@@3HA" = internal global i32 7, align 4, !dbg !25 +@"?staticTLS@foo@@3HA" = internal thread_local global i32 5, align 4, !dbg !27 ; Function Attrs: noinline nounwind optnone uwtable -define internal %struct.Local* @"??0Local@?1??bar@@YAHXZ@QEAA@XZ"(%struct.Local* returned %this) unnamed_addr #0 align 2 !dbg !75 { +define dso_local i32 @"?bar@@YAHXZ"() #0 !dbg !36 { entry: - %this.addr = alloca %struct.Local*, align 8 - store %struct.Local* %this, %struct.Local** %this.addr, align 8 - call void @llvm.dbg.declare(metadata %struct.Local** %this.addr, metadata !80, metadata !DIExpression()), !dbg !82 - %this1 = load %struct.Local*, %struct.Local** %this.addr, align 8 - %LocalGlobal = getelementptr inbounds %struct.Local, %struct.Local* %this1, i32 0, i32 0, !dbg !83 - store i32 12, i32* %LocalGlobal, align 4, !dbg !83 - %LocalConstVal = getelementptr inbounds %struct.Local, %struct.Local* %this1, i32 0, i32 1, !dbg !83 - store i32 15, i32* %LocalConstVal, align 4, !dbg !83 - ret %struct.Local* %this1, !dbg !83 + %0 = load i32, i32* @"?globalStatic@foo@@3HA", align 4, !dbg !39 + %1 = load i32, i32* @"?globalTLS@foo@@3HA", align 4, !dbg !39 + %add = add nsw i32 %0, %1, !dbg !39 + %2 = load i32, i32* @"?staticTLS@foo@@3HA", align 4, !dbg !39 + %add1 = add nsw i32 %add, %2, !dbg !39 + ret i32 %add1, !dbg !39 } attributes #0 = { noinline nounwind optnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "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-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } -attributes #1 = { nounwind readnone speculatable willreturn } -attributes #2 = { nounwind } !llvm.dbg.cu = !{!2} -!llvm.linker.options = !{!47, !48} -!llvm.module.flags = !{!49, !50, !51, !52} -!llvm.ident = !{!53} +!llvm.linker.options = !{!29, !30} +!llvm.module.flags = !{!31, !32, !33, !34} +!llvm.ident = !{!35} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) -!1 = distinct !DIGlobalVariable(name: "first", linkageName: "?first@@3HA", scope: !2, file: !3, line: 1, type: !10, isLocal: false, isDefinition: true) -!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !3, producer: "clang version 11.0.0 (https://github.com/llvm/llvm-project.git 202f144bffd0be254a829924195e1b8ebabcbb79)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !5, globals: !16, nameTableKind: None) -!3 = !DIFile(filename: "a.cpp", directory: "F:\\llvm-project\\__test", checksumkind: CSK_MD5, checksum: "ae8137877dbd6fb10cfa1fc9ea4a39ca") +!1 = distinct !DIGlobalVariable(name: "first", linkageName: "?first@@3HA", scope: !2, file: !3, line: 1, type: !9, isLocal: false, isDefinition: true) +!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !3, producer: "clang version 11.0.0 (https://github.com/llvm/llvm-project.git f5b1301ce8575f6d82e87031a1a5485c33637a93)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, nameTableKind: None) +!3 = !DIFile(filename: "a.cpp", directory: "F:\\llvm-project\\__test", checksumkind: CSK_MD5, checksum: "65c2a7701cffb7a2e8d4caf1cc24caa7") !4 = !{} -!5 = !{!6} -!6 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Data", scope: !7, file: !3, line: 15, size: 64, flags: DIFlagTypePassByValue | DIFlagNonTrivial, elements: !8, identifier: ".?AUData@foo@@") -!7 = !DINamespace(name: "foo", scope: null) -!8 = !{!9, !11, !12, !13, !15} -!9 = !DIDerivedType(tag: DW_TAG_member, name: "DataStaticTLS", scope: !6, file: !3, line: 16, baseType: !10, flags: DIFlagStaticMember, extraData: i32 11) -!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) -!11 = !DIDerivedType(tag: DW_TAG_member, name: "DataGlobal", scope: !6, file: !3, line: 17, baseType: !10, size: 32) -!12 = !DIDerivedType(tag: DW_TAG_member, name: "DataStatic", scope: !6, file: !3, line: 18, baseType: !10, flags: DIFlagStaticMember, extraData: i32 13) -!13 = !DIDerivedType(tag: DW_TAG_member, name: "DataConstExpr", scope: !6, file: !3, line: 19, baseType: !14, flags: DIFlagStaticMember, extraData: i32 14) -!14 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !10) -!15 = !DIDerivedType(tag: DW_TAG_member, name: "DataConstVal", scope: !6, file: !3, line: 20, baseType: !14, size: 32, offset: 32) -!16 = !{!0, !17, !24, !27, !29, !31, !33, !35, !37, !39, !41, !43, !45} -!17 = !DIGlobalVariableExpression(var: !18, expr: !DIExpression()) -!18 = distinct !DIGlobalVariable(name: "comdat", linkageName: "?comdat@?$A@X@@2HB", scope: !2, file: !3, line: 3, type: !14, isLocal: false, isDefinition: true, declaration: !19) -!19 = !DIDerivedType(tag: DW_TAG_member, name: "comdat", scope: !20, file: !3, line: 3, baseType: !14, flags: DIFlagStaticMember, extraData: i32 3) -!20 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "A", file: !3, line: 3, size: 8, flags: DIFlagTypePassByValue, elements: !21, templateParams: !22, identifier: ".?AU?$A@X@@") -!21 = !{!19} -!22 = !{!23} -!23 = !DITemplateTypeParameter(name: "T", type: null) -!24 = !DIGlobalVariableExpression(var: !25, expr: !DIExpression()) -!25 = distinct !DIGlobalVariable(name: "middle", linkageName: "?middle@@3PEBHEB", scope: !2, file: !3, line: 5, type: !26, isLocal: false, isDefinition: true) -!26 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !14, size: 64) +!5 = !{!0, !6, !15, !18, !21, !23, !25, !27} +!6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression()) +!7 = distinct !DIGlobalVariable(name: "comdat", linkageName: "?comdat@?$A@X@@2HB", scope: !2, file: !3, line: 2, type: !8, isLocal: false, isDefinition: true, declaration: !10) +!8 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !9) +!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!10 = !DIDerivedType(tag: DW_TAG_member, name: "comdat", scope: !11, file: !3, line: 2, baseType: !8, flags: DIFlagStaticMember, extraData: i32 3) +!11 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "A", file: !3, line: 2, size: 8, flags: DIFlagTypePassByValue, elements: !12, templateParams: !13, identifier: ".?AU?$A@X@@") +!12 = !{!10} +!13 = !{!14} +!14 = !DITemplateTypeParameter(name: "T", type: null) +!15 = !DIGlobalVariableExpression(var: !16, expr: !DIExpression()) +!16 = distinct !DIGlobalVariable(name: "middle", linkageName: "?middle@@3PEBHEB", scope: !2, file: !3, line: 3, type: !17, isLocal: false, isDefinition: true) +!17 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !8, size: 64) +!18 = !DIGlobalVariableExpression(var: !19, expr: !DIExpression()) +!19 = distinct !DIGlobalVariable(name: "globalTLS", linkageName: "?globalTLS@foo@@3HA", scope: !20, file: !3, line: 5, type: !9, isLocal: false, isDefinition: true) +!20 = !DINamespace(name: "foo", scope: null) +!21 = !DIGlobalVariableExpression(var: !22, expr: !DIExpression()) +!22 = distinct !DIGlobalVariable(name: "justGlobal", linkageName: "?justGlobal@foo@@3HA", scope: !20, file: !3, line: 7, type: !9, isLocal: false, isDefinition: true) +!23 = !DIGlobalVariableExpression(var: !24, expr: !DIExpression()) +!24 = distinct !DIGlobalVariable(name: "last", linkageName: "?last@@3HA", scope: !2, file: !3, line: 10, type: !9, isLocal: false, isDefinition: true) +!25 = !DIGlobalVariableExpression(var: !26, expr: !DIExpression()) +!26 = distinct !DIGlobalVariable(name: "globalStatic", linkageName: "?globalStatic@foo@@3HA", scope: !20, file: !3, line: 8, type: !9, isLocal: true, isDefinition: true) !27 = !DIGlobalVariableExpression(var: !28, expr: !DIExpression()) -!28 = distinct !DIGlobalVariable(name: "globalTLS", linkageName: "?globalTLS@foo@@3HA", scope: !7, file: !3, line: 8, type: !10, isLocal: false, isDefinition: true) -!29 = !DIGlobalVariableExpression(var: !30, expr: !DIExpression()) -!30 = distinct !DIGlobalVariable(name: "justGlobal", linkageName: "?justGlobal@foo@@3HA", scope: !7, file: !3, line: 10, type: !10, isLocal: false, isDefinition: true) -!31 = !DIGlobalVariableExpression(var: !32, expr: !DIExpression()) -!32 = distinct !DIGlobalVariable(name: "last", linkageName: "?last@@3HA", scope: !2, file: !3, line: 24, type: !10, isLocal: false, isDefinition: true) -!33 = !DIGlobalVariableExpression(var: !34, expr: !DIExpression(DW_OP_constu, 8, DW_OP_stack_value)) -!34 = distinct !DIGlobalVariable(name: "constExpr", scope: !7, file: !3, line: 12, type: !14, isLocal: true, isDefinition: true) -!35 = !DIGlobalVariableExpression(var: !36, expr: !DIExpression(DW_OP_constu, 9, DW_OP_stack_value)) -!36 = distinct !DIGlobalVariable(name: "constVal", scope: !7, file: !3, line: 13, type: !14, isLocal: true, isDefinition: true) -!37 = !DIGlobalVariableExpression(var: !38, expr: !DIExpression()) -!38 = distinct !DIGlobalVariable(name: "DataStaticTLS", linkageName: "?DataStaticTLS@Data@foo@@2HA", scope: !2, file: !3, line: 16, type: !10, isLocal: false, isDefinition: true, declaration: !9) -!39 = !DIGlobalVariableExpression(var: !40, expr: !DIExpression()) -!40 = distinct !DIGlobalVariable(name: "DataStatic", linkageName: "?DataStatic@Data@foo@@2HA", scope: !2, file: !3, line: 18, type: !10, isLocal: false, isDefinition: true, declaration: !12) -!41 = !DIGlobalVariableExpression(var: !42, expr: !DIExpression(DW_OP_constu, 14, DW_OP_stack_value)) -!42 = distinct !DIGlobalVariable(name: "DataConstExpr", scope: !2, file: !3, line: 19, type: !14, isLocal: true, isDefinition: true, declaration: !13) -!43 = !DIGlobalVariableExpression(var: !44, expr: !DIExpression()) -!44 = distinct !DIGlobalVariable(name: "globalStatic", linkageName: "?globalStatic@foo@@3HA", scope: !7, file: !3, line: 11, type: !10, isLocal: true, isDefinition: true) -!45 = !DIGlobalVariableExpression(var: !46, expr: !DIExpression()) -!46 = distinct !DIGlobalVariable(name: "staticTLS", linkageName: "?staticTLS@foo@@3HA", scope: !7, file: !3, line: 9, type: !10, isLocal: true, isDefinition: true) -!47 = !{!"/DEFAULTLIB:libcmt.lib"} -!48 = !{!"/DEFAULTLIB:oldnames.lib"} -!49 = !{i32 2, !"CodeView", i32 1} -!50 = !{i32 2, !"Debug Info Version", i32 3} -!51 = !{i32 1, !"wchar_size", i32 2} -!52 = !{i32 7, !"PIC Level", i32 2} -!53 = !{!"clang version 11.0.0 (https://github.com/llvm/llvm-project.git 202f144bffd0be254a829924195e1b8ebabcbb79)"} -!54 = distinct !DISubprogram(name: "bar", linkageName: "?bar@@YAHXZ", scope: !3, file: !3, line: 26, type: !55, scopeLine: 26, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !4) -!55 = !DISubroutineType(types: !56) -!56 = !{!10} -!57 = !DILocalVariable(name: "D", scope: !54, file: !3, line: 31, type: !6) -!58 = !DILocation(line: 31, scope: !54) -!59 = !DILocalVariable(name: "L", scope: !54, file: !3, line: 32, type: !60) -!60 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Local", scope: !54, file: !3, line: 27, size: 64, flags: DIFlagTypePassByValue | DIFlagNonTrivial, elements: !61, identifier: ".?AULocal@?1??bar@@YAHXZ@") -!61 = !{!62, !63} -!62 = !DIDerivedType(tag: DW_TAG_member, name: "LocalGlobal", scope: !60, file: !3, line: 28, baseType: !10, size: 32) -!63 = !DIDerivedType(tag: DW_TAG_member, name: "LocalConstVal", scope: !60, file: !3, line: 29, baseType: !14, size: 32, offset: 32) -!64 = !DILocation(line: 32, scope: !54) -!65 = !DILocation(line: 33, scope: !54) -!66 = distinct !DISubprogram(name: "Data", linkageName: "??0Data@foo@@QEAA@XZ", scope: !6, file: !3, line: 15, type: !67, scopeLine: 15, flags: DIFlagArtificial | DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, declaration: !70, retainedNodes: !4) -!67 = !DISubroutineType(types: !68) -!68 = !{null, !69} -!69 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !6, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer) -!70 = !DISubprogram(name: "Data", scope: !6, type: !67, flags: DIFlagArtificial | DIFlagPrototyped, spFlags: 0) -!71 = !DILocalVariable(name: "this", arg: 1, scope: !66, type: !72, flags: DIFlagArtificial | DIFlagObjectPointer) -!72 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !6, size: 64) -!73 = !DILocation(line: 0, scope: !66) -!74 = !DILocation(line: 15, scope: !66) -!75 = distinct !DISubprogram(name: "Local", linkageName: "??0Local@?1??bar@@YAHXZ@QEAA@XZ", scope: !60, file: !3, line: 27, type: !76, scopeLine: 27, flags: DIFlagArtificial | DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !2, declaration: !79, retainedNodes: !4) -!76 = !DISubroutineType(types: !77) -!77 = !{null, !78} -!78 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !60, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer) -!79 = !DISubprogram(name: "Local", scope: !60, type: !76, flags: DIFlagArtificial | DIFlagPrototyped, spFlags: 0) -!80 = !DILocalVariable(name: "this", arg: 1, scope: !75, type: !81, flags: DIFlagArtificial | DIFlagObjectPointer) -!81 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !60, size: 64) -!82 = !DILocation(line: 0, scope: !75) -!83 = !DILocation(line: 27, scope: !75) +!28 = distinct !DIGlobalVariable(name: "staticTLS", linkageName: "?staticTLS@foo@@3HA", scope: !20, file: !3, line: 6, type: !9, isLocal: true, isDefinition: true) +!29 = !{!"/DEFAULTLIB:libcmt.lib"} +!30 = !{!"/DEFAULTLIB:oldnames.lib"} +!31 = !{i32 2, !"CodeView", i32 1} +!32 = !{i32 2, !"Debug Info Version", i32 3} +!33 = !{i32 1, !"wchar_size", i32 2} +!34 = !{i32 7, !"PIC Level", i32 2} +!35 = !{!"clang version 11.0.0 (https://github.com/llvm/llvm-project.git f5b1301ce8575f6d82e87031a1a5485c33637a93)"} +!36 = distinct !DISubprogram(name: "bar", linkageName: "?bar@@YAHXZ", scope: !3, file: !3, line: 11, type: !37, scopeLine: 11, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !4) +!37 = !DISubroutineType(types: !38) +!38 = !{!9} +!39 = !DILocation(line: 12, scope: !36) diff --git a/llvm/test/DebugInfo/COFF/types-array-unsized.ll b/llvm/test/DebugInfo/COFF/types-array-unsized.ll index de0bcfff988d92..abfcbbfebd3276 100644 --- a/llvm/test/DebugInfo/COFF/types-array-unsized.ll +++ b/llvm/test/DebugInfo/COFF/types-array-unsized.ll @@ -4,7 +4,7 @@ ; We should emit two array types: one used to describe the static data member, ; and the other used by the S_GDATA32 for the definition. -; // Build with: clang-cl a.cpp /c /Z7 /clang:-S /clang:-emit-llvm +; C++ source: ; struct Foo { ; static const char str[]; ; }; @@ -41,34 +41,33 @@ ; CHECK-NEXT: Kind: S_GDATA32 (0x110D) ; CHECK-NEXT: DataOffset: ?str@Foo@@2QBDB+0x0 ; CHECK-NEXT: Type: [[ARRAY_COMPLETE]] -; CHECK-NEXT: DisplayName: Foo::str +; CHECK-NEXT: DisplayName: str ; CHECK-NEXT: LinkageName: ?str@Foo@@2QBDB ; CHECK-NEXT: } -; ModuleID = 'a.cpp' -source_filename = "a.cpp" -target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" -target triple = "x86_64-pc-windows-msvc19.25.28614" +; ModuleID = 't.cpp' +source_filename = "t.cpp" +target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-pc-windows-msvc19.0.24215" %struct.Foo = type { i8 } -@"?str@Foo@@2QBDB" = dso_local constant [5 x i8] c"asdf\00", align 1, !dbg !0 -@"?f@@3UFoo@@A" = dso_local global %struct.Foo zeroinitializer, align 1, !dbg !6 +@"\01?str@Foo@@2QBDB" = constant [5 x i8] c"asdf\00", align 1, !dbg !0 +@"\01?f@@3UFoo@@A" = global %struct.Foo zeroinitializer, align 1, !dbg !6 !llvm.dbg.cu = !{!2} -!llvm.linker.options = !{!19, !20} -!llvm.module.flags = !{!21, !22, !23, !24} -!llvm.ident = !{!25} +!llvm.module.flags = !{!19, !20, !21, !22} +!llvm.ident = !{!23} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) -!1 = distinct !DIGlobalVariable(name: "str", linkageName: "?str@Foo@@2QBDB", scope: !2, file: !3, line: 4, type: !16, isLocal: false, isDefinition: true, declaration: !10) -!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !3, producer: "clang version 11.0.0 (https://github.com/llvm/llvm-project.git 202f144bffd0be254a829924195e1b8ebabcbb79)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, nameTableKind: None) -!3 = !DIFile(filename: "a.cpp", directory: "F:\\llvm-project\\__test", checksumkind: CSK_MD5, checksum: "c2b2d28fd8aaa040c4141cea420d0648") +!1 = distinct !DIGlobalVariable(name: "str", linkageName: "\01?str@Foo@@2QBDB", scope: !2, file: !3, line: 4, type: !16, isLocal: false, isDefinition: true, declaration: !10) +!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang version 6.0.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5) +!3 = !DIFile(filename: "t.cpp", directory: "C:\5Csrc\5Cllvm-project\5Cbuild", checksumkind: CSK_MD5, checksum: "15aa843c5a80301928caf03e71f87a54") !4 = !{} !5 = !{!0, !6} !6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression()) -!7 = distinct !DIGlobalVariable(name: "f", linkageName: "?f@@3UFoo@@A", scope: !2, file: !3, line: 5, type: !8, isLocal: false, isDefinition: true) -!8 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Foo", file: !3, line: 1, size: 8, flags: DIFlagTypePassByValue, elements: !9, identifier: ".?AUFoo@@") +!7 = distinct !DIGlobalVariable(name: "f", linkageName: "\01?f@@3UFoo@@A", scope: !2, file: !3, line: 5, type: !8, isLocal: false, isDefinition: true) +!8 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Foo", file: !3, line: 1, size: 8, elements: !9, identifier: ".?AUFoo@@") !9 = !{!10} !10 = !DIDerivedType(tag: DW_TAG_member, name: "str", scope: !8, file: !3, line: 2, baseType: !11, flags: DIFlagStaticMember) !11 = !DICompositeType(tag: DW_TAG_array_type, baseType: !12, elements: !14) @@ -79,10 +78,8 @@ target triple = "x86_64-pc-windows-msvc19.25.28614" !16 = !DICompositeType(tag: DW_TAG_array_type, baseType: !12, size: 40, elements: !17) !17 = !{!18} !18 = !DISubrange(count: 5) -!19 = !{!"/DEFAULTLIB:libcmt.lib"} -!20 = !{!"/DEFAULTLIB:oldnames.lib"} -!21 = !{i32 2, !"CodeView", i32 1} -!22 = !{i32 2, !"Debug Info Version", i32 3} -!23 = !{i32 1, !"wchar_size", i32 2} -!24 = !{i32 7, !"PIC Level", i32 2} -!25 = !{!"clang version 11.0.0 (https://github.com/llvm/llvm-project.git 202f144bffd0be254a829924195e1b8ebabcbb79)"} +!19 = !{i32 2, !"CodeView", i32 1} +!20 = !{i32 2, !"Debug Info Version", i32 3} +!21 = !{i32 1, !"wchar_size", i32 2} +!22 = !{i32 7, !"PIC Level", i32 2} +!23 = !{!"clang version 6.0.0 "}