diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp --- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp @@ -144,9 +144,14 @@ auto *GVContext = GV->getScope(); const DIType *GTy = GV->getType(); - auto *CB = GVContext ? dyn_cast(GVContext) : nullptr; - DIE *ContextDIE = CB ? getOrCreateCommonBlock(CB, GlobalExprs) - : getOrCreateContextDIE(GVContext); + DIE *ContextDIE; + if (auto *CB = dyn_cast_or_null(GVContext)) { + ContextDIE = getOrCreateCommonBlock(CB, GlobalExprs); + } else if (DIE *AbstractSP = getAbstractSPDies().lookup(GVContext)) { + ContextDIE = AbstractSP; + } else { + ContextDIE = getOrCreateContextDIE(GVContext); + } // Add to map. DIE *VariableDIE = &createAndAddDIE(GV->getTag(), *ContextDIE, GV); diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h @@ -322,6 +322,9 @@ SmallPtrSet> ProcessedSPNodes; + /// If nonnull, stores the current module we're processing. + const Module *CurModule = nullptr; + /// If nonnull, stores the current machine function we're processing. const MachineFunction *CurFn = nullptr; @@ -484,6 +487,8 @@ void finishSubprogramDefinitions(); + void createGlobalVariableDefinitions(); + /// Finish off debug information after all functions have been /// processed. void finalizeModuleInfo(); diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -1147,20 +1147,15 @@ if (!Asm || !MMI->hasDebugInfo()) return; + assert(!CurModule); + CurModule = M; + unsigned NumDebugCUs = std::distance(M->debug_compile_units_begin(), M->debug_compile_units_end()); assert(NumDebugCUs > 0 && "Asm unexpectedly initialized"); assert(MMI->hasDebugInfo() && "DebugInfoAvailabilty unexpectedly not initialized"); SingleCU = NumDebugCUs == 1; - DenseMap> - GVMap; - for (const GlobalVariable &Global : M->globals()) { - SmallVector GVs; - Global.getDebugInfo(GVs); - for (auto *GVE : GVs) - GVMap[GVE->getVariable()].push_back({&Global, GVE->getExpression()}); - } // Create the symbol that designates the start of the unit's contribution // to the string offsets table. In a split DWARF scenario, only the skeleton @@ -1197,30 +1192,11 @@ }); if (!HasNonLocalImportedEntities && CUNode->getEnumTypes().empty() && - CUNode->getRetainedTypes().empty() && - CUNode->getGlobalVariables().empty() && CUNode->getMacros().empty()) + CUNode->getRetainedTypes().empty() && CUNode->getMacros().empty()) continue; DwarfCompileUnit &CU = getOrCreateDwarfCompileUnit(CUNode); - // Global Variables. - for (auto *GVE : CUNode->getGlobalVariables()) { - // Don't bother adding DIGlobalVariableExpressions listed in the CU if we - // already know about the variable and it isn't adding a constant - // expression. - auto &GVMapEntry = GVMap[GVE->getVariable()]; - auto *Expr = GVE->getExpression(); - if (!GVMapEntry.size() || (Expr && Expr->isConstant())) - GVMapEntry.push_back({nullptr, Expr}); - } - - DenseSet Processed; - for (auto *GVE : CUNode->getGlobalVariables()) { - DIGlobalVariable *GV = GVE->getVariable(); - if (Processed.insert(GV).second) - CU.getOrCreateGlobalVariableDIE(GV, sortGlobalExprs(GVMap[GV])); - } - for (auto *Ty : CUNode->getEnumTypes()) CU.getOrCreateTypeDIE(cast(Ty)); @@ -1260,6 +1236,51 @@ } } +void DwarfDebug::createGlobalVariableDefinitions() { + // This function creates definitions for global variables, which may originate + // from static local variables in the source code. For static local variables, + // this step be done before finishing the subprogram definitions (as static + // locals may add a DW_TAG_variable child to the subprogram); and after all + // the subprograms abstract definitions have been created (in this case, the + // DW_TAG_variable child is added to the abstract definition and not to the + // subprogram's DIE). + + if (!Asm || !MMI->hasDebugInfo()) + return; + + DenseMap> + GVMap; + for (const GlobalVariable &Global : CurModule->globals()) { + SmallVector GVs; + Global.getDebugInfo(GVs); + for (auto *GVE : GVs) + GVMap[GVE->getVariable()].push_back({&Global, GVE->getExpression()}); + } + + for (DICompileUnit *CUNode : CurModule->debug_compile_units()) { + if (CUNode->getGlobalVariables().empty()) + continue; + + DwarfCompileUnit &CU = getOrCreateDwarfCompileUnit(CUNode); + for (auto *GVE : CUNode->getGlobalVariables()) { + // Don't bother adding DIGlobalVariableExpressions listed in the CU if we + // already know about the variable and it isn't adding a constant + // expression. + auto &GVMapEntry = GVMap[GVE->getVariable()]; + auto *Expr = GVE->getExpression(); + if (!GVMapEntry.size() || (Expr && Expr->isConstant())) + GVMapEntry.push_back({nullptr, Expr}); + } + + DenseSet Processed; + for (auto *GVE : CUNode->getGlobalVariables()) { + DIGlobalVariable *GV = GVE->getVariable(); + if (Processed.insert(GV).second) + CU.getOrCreateGlobalVariableDIE(GV, sortGlobalExprs(GVMap[GV])); + } + } +} + void DwarfDebug::finalizeModuleInfo() { const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering(); @@ -1409,6 +1430,8 @@ assert(CurFn == nullptr); assert(CurMI == nullptr); + createGlobalVariableDefinitions(); + for (const auto &P : CUMap) { auto &CU = *P.second; CU.createBaseTypeDIEs(); @@ -1482,6 +1505,7 @@ emitDebugPubSections(); // clean up. + CurModule = nullptr; // FIXME: AbstractVariables.clear(); } diff --git a/llvm/test/DebugInfo/AMDGPU/variable-locations.ll b/llvm/test/DebugInfo/AMDGPU/variable-locations.ll --- a/llvm/test/DebugInfo/AMDGPU/variable-locations.ll +++ b/llvm/test/DebugInfo/AMDGPU/variable-locations.ll @@ -13,22 +13,8 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata) -; CHECK: {{.*}}DW_TAG_variable -; CHECK-NEXT: DW_AT_name {{.*}}"GlobA" -; CHECK-NEXT: DW_AT_type -; CHECK-NEXT: DW_AT_external -; CHECK-NEXT: DW_AT_decl_file -; CHECK-NEXT: DW_AT_decl_line -; CHECK-NEXT: DW_AT_location [DW_FORM_block1] (DW_OP_addr 0x0) @GlobA = common addrspace(1) global i32 0, align 4, !dbg !0 -; CHECK: {{.*}}DW_TAG_variable -; CHECK-NEXT: DW_AT_name {{.*}}"GlobB" -; CHECK-NEXT: DW_AT_type -; CHECK-NEXT: DW_AT_external -; CHECK-NEXT: DW_AT_decl_file -; CHECK-NEXT: DW_AT_decl_line -; CHECK-NEXT: DW_AT_location [DW_FORM_block1] (DW_OP_addr 0x0) @GlobB = common addrspace(1) global i32 0, align 4, !dbg !6 ; CHECK: {{.*}}DW_TAG_subprogram @@ -72,6 +58,22 @@ ret void, !dbg !34 } +; CHECK: {{.*}}DW_TAG_variable +; CHECK-NEXT: DW_AT_name {{.*}}"GlobA" +; CHECK-NEXT: DW_AT_type +; CHECK-NEXT: DW_AT_external +; CHECK-NEXT: DW_AT_decl_file +; CHECK-NEXT: DW_AT_decl_line +; CHECK-NEXT: DW_AT_location [DW_FORM_block1] (DW_OP_addr 0x0) + +; CHECK: {{.*}}DW_TAG_variable +; CHECK-NEXT: DW_AT_name {{.*}}"GlobB" +; CHECK-NEXT: DW_AT_type +; CHECK-NEXT: DW_AT_external +; CHECK-NEXT: DW_AT_decl_file +; CHECK-NEXT: DW_AT_decl_line +; CHECK-NEXT: DW_AT_location [DW_FORM_block1] (DW_OP_addr 0x0) + !llvm.dbg.cu = !{!2} !opencl.ocl.version = !{!9} !llvm.module.flags = !{!10, !11} diff --git a/llvm/test/DebugInfo/BPF/extern-void.ll b/llvm/test/DebugInfo/BPF/extern-void.ll --- a/llvm/test/DebugInfo/BPF/extern-void.ll +++ b/llvm/test/DebugInfo/BPF/extern-void.ll @@ -38,7 +38,6 @@ ; ; CHECK: .quad bla2 ; CHECK-NEXT: DW_TAG_const_type -; CHECK-NEXT: DW_TAG_subprogram ; Function Attrs: nounwind readnone speculatable willreturn declare void @llvm.dbg.value(metadata, metadata, metadata) #1 diff --git a/llvm/test/DebugInfo/Generic/cross-cu-linkonce-distinct.ll b/llvm/test/DebugInfo/Generic/cross-cu-linkonce-distinct.ll --- a/llvm/test/DebugInfo/Generic/cross-cu-linkonce-distinct.ll +++ b/llvm/test/DebugInfo/Generic/cross-cu-linkonce-distinct.ll @@ -27,13 +27,13 @@ ; The DISubprogram should show up in compile unit a. ; CHECK: DW_TAG_compile_unit ; CHECK-NOT: DW_TAG -; CHECK: DW_AT_name ("b.cpp") -; CHECK-NOT: DW_TAG_subprogram +; CHECK: DW_AT_name ("a.cpp") +; CHECK: DW_AT_name ("func") ; CHECK: DW_TAG_compile_unit ; CHECK-NOT: DW_TAG -; CHECK: DW_AT_name ("a.cpp") -; CHECK: DW_AT_name ("func") +; CHECK: DW_AT_name ("b.cpp") +; CHECK-NOT: DW_TAG_subprogram source_filename = "test/DebugInfo/Generic/cross-cu-linkonce-distinct.ll" diff --git a/llvm/test/DebugInfo/Generic/debug-names-linkage-name.ll b/llvm/test/DebugInfo/Generic/debug-names-linkage-name.ll --- a/llvm/test/DebugInfo/Generic/debug-names-linkage-name.ll +++ b/llvm/test/DebugInfo/Generic/debug-names-linkage-name.ll @@ -11,9 +11,9 @@ ; We should have all three linkage names in the .debug_info and .debug_names ; ALL: .debug_info contents: -; ALL: DW_AT_linkage_name ("_ZN1n1vE") ; ALL: DW_AT_linkage_name ("_Z1fi") ; ALL: DW_AT_linkage_name ("_Z1gi") +; ALL: DW_AT_linkage_name ("_ZN1n1vE") ; ALL: .debug_names contents: ; ALL: String: {{.*}} "_Z1fi" ; ALL: String: {{.*}} "_Z1gi" diff --git a/llvm/test/DebugInfo/Generic/namespace.ll b/llvm/test/DebugInfo/Generic/namespace.ll --- a/llvm/test/DebugInfo/Generic/namespace.ll +++ b/llvm/test/DebugInfo/Generic/namespace.ll @@ -13,16 +13,13 @@ ; CHECK-NOT: DW_AT_decl_file ; CHECK-NOT: DW_AT_decl_line -; CHECK: [[I:0x[0-9a-f]*]]:{{ *}}DW_TAG_variable -; CHECK: DW_AT_name ("i") -; CHECK: [[VAR_FWD:0x[0-9a-f]*]]:{{ *}}DW_TAG_variable -; CHECK: DW_AT_name ("var_fwd") - ; CHECK: [[FOO:0x[0-9a-f]*]]:{{ *}}DW_TAG_structure_type ; CHECK: DW_AT_name ("foo") ; CHECK: DW_AT_declaration ; CHECK: [[BAR:0x[0-9a-f]*]]:{{ *}}DW_TAG_structure_type ; CHECK: DW_AT_name ("bar") +; CHECK: [[I:0x[0-9a-f]*]]:{{ *}}DW_TAG_variable +; CHECK: DW_AT_name ("i") ; CHECK: DW_TAG_subprogram ; CHECK: DW_AT_MIPS_linkage_name @@ -44,6 +41,9 @@ ; CHECK: DW_AT_name ("func_decl") ; CHECK: DW_AT_declaration +; CHECK: [[VAR_FWD:0x[0-9a-f]*]]:{{ *}}DW_TAG_variable +; CHECK: DW_AT_name ("var_fwd") + ; CHECK: [[FUNC_FWD:0x[0-9a-f]*]]:{{.*}}DW_TAG_subprogram ; CHECK: DW_AT_name ("func_fwd") ; CHECK-NOT: DW_AT_declaration @@ -56,13 +56,14 @@ ; CHECK: DW_TAG_imported_declaration ; CHECK: NULL -; CHECK: DW_TAG_base_type ; CHECK: DW_TAG_imported_module ; CHECK: DW_AT_decl_file ([[F2:.*]]) ; CHECK: DW_AT_decl_line (18) ; CHECK: DW_AT_import ([[NS1]]) ; CHECK: DW_TAG_imported_declaration +; CHECK: DW_TAG_base_type + ; CHECK: DW_TAG_subprogram ; CHECK: DW_TAG_subprogram ; CHECK: DW_AT_MIPS_linkage_name diff --git a/llvm/test/DebugInfo/NVPTX/debug-addr-class.ll b/llvm/test/DebugInfo/NVPTX/debug-addr-class.ll --- a/llvm/test/DebugInfo/NVPTX/debug-addr-class.ll +++ b/llvm/test/DebugInfo/NVPTX/debug-addr-class.ll @@ -84,7 +84,7 @@ !39 = !DILocation(line: 10, column: 1, scope: !17) !40 = !{!22, !24, !26, !28} -; CHECK: .section .debug_abbrev +; CHECK: .section .debug_abbrev ; CHECK-NEXT: { ; CHECK-NEXT:.b8 1 // Abbreviation Code ; CHECK-NEXT:.b8 17 // DW_TAG_compile_unit @@ -106,36 +106,6 @@ ; CHECK-NEXT:.b8 0 // EOM(1) ; CHECK-NEXT:.b8 0 // EOM(2) ; CHECK-NEXT:.b8 2 // Abbreviation Code -; CHECK-NEXT:.b8 52 // DW_TAG_variable -; CHECK-NEXT:.b8 0 // DW_CHILDREN_no -; CHECK-NEXT:.b8 3 // DW_AT_name -; CHECK-NEXT:.b8 8 // DW_FORM_string -; CHECK-NEXT:.b8 73 // DW_AT_type -; CHECK-NEXT:.b8 19 // DW_FORM_ref4 -; CHECK-NEXT:.b8 63 // DW_AT_external -; CHECK-NEXT:.b8 12 // DW_FORM_flag -; CHECK-NEXT:.b8 58 // DW_AT_decl_file -; CHECK-NEXT:.b8 11 // DW_FORM_data1 -; CHECK-NEXT:.b8 59 // DW_AT_decl_line -; CHECK-NEXT:.b8 11 // DW_FORM_data1 -; CHECK-NEXT:.b8 51 // DW_AT_address_class -; CHECK-NEXT:.b8 11 // DW_FORM_data1 -; CHECK-NEXT:.b8 2 // DW_AT_location -; CHECK-NEXT:.b8 10 // DW_FORM_block1 -; CHECK-NEXT:.b8 0 // EOM(1) -; CHECK-NEXT:.b8 0 // EOM(2) -; CHECK-NEXT:.b8 3 // Abbreviation Code -; CHECK-NEXT:.b8 36 // DW_TAG_base_type -; CHECK-NEXT:.b8 0 // DW_CHILDREN_no -; CHECK-NEXT:.b8 3 // DW_AT_name -; CHECK-NEXT:.b8 8 // DW_FORM_string -; CHECK-NEXT:.b8 62 // DW_AT_encoding -; CHECK-NEXT:.b8 11 // DW_FORM_data1 -; CHECK-NEXT:.b8 11 // DW_AT_byte_size -; CHECK-NEXT:.b8 11 // DW_FORM_data1 -; CHECK-NEXT:.b8 0 // EOM(1) -; CHECK-NEXT:.b8 0 // EOM(2) -; CHECK-NEXT:.b8 4 // Abbreviation Code ; CHECK-NEXT:.b8 46 // DW_TAG_subprogram ; CHECK-NEXT:.b8 1 // DW_CHILDREN_yes ; CHECK-NEXT:.b8 17 // DW_AT_low_pc @@ -157,7 +127,7 @@ ; CHECK-NEXT:.b8 12 // DW_FORM_flag ; CHECK-NEXT:.b8 0 // EOM(1) ; CHECK-NEXT:.b8 0 // EOM(2) -; CHECK-NEXT:.b8 5 // Abbreviation Code +; CHECK-NEXT:.b8 3 // Abbreviation Code ; CHECK-NEXT:.b8 5 // DW_TAG_formal_parameter ; CHECK-NEXT:.b8 0 // DW_CHILDREN_no ; CHECK-NEXT:.b8 3 // DW_AT_name @@ -170,6 +140,36 @@ ; CHECK-NEXT:.b8 19 // DW_FORM_ref4 ; CHECK-NEXT:.b8 0 // EOM(1) ; CHECK-NEXT:.b8 0 // EOM(2) +; CHECK-NEXT:.b8 4 // Abbreviation Code +; CHECK-NEXT:.b8 52 // DW_TAG_variable +; CHECK-NEXT:.b8 0 // DW_CHILDREN_no +; CHECK-NEXT:.b8 3 // DW_AT_name +; CHECK-NEXT:.b8 8 // DW_FORM_string +; CHECK-NEXT:.b8 73 // DW_AT_type +; CHECK-NEXT:.b8 19 // DW_FORM_ref4 +; CHECK-NEXT:.b8 63 // DW_AT_external +; CHECK-NEXT:.b8 12 // DW_FORM_flag +; CHECK-NEXT:.b8 58 // DW_AT_decl_file +; CHECK-NEXT:.b8 11 // DW_FORM_data1 +; CHECK-NEXT:.b8 59 // DW_AT_decl_line +; CHECK-NEXT:.b8 11 // DW_FORM_data1 +; CHECK-NEXT:.b8 51 // DW_AT_address_class +; CHECK-NEXT:.b8 11 // DW_FORM_data1 +; CHECK-NEXT:.b8 2 // DW_AT_location +; CHECK-NEXT:.b8 10 // DW_FORM_block1 +; CHECK-NEXT:.b8 0 // EOM(1) +; CHECK-NEXT:.b8 0 // EOM(2) +; CHECK-NEXT:.b8 5 // Abbreviation Code +; CHECK-NEXT:.b8 36 // DW_TAG_base_type +; CHECK-NEXT:.b8 0 // DW_CHILDREN_no +; CHECK-NEXT:.b8 3 // DW_AT_name +; CHECK-NEXT:.b8 8 // DW_FORM_string +; CHECK-NEXT:.b8 62 // DW_AT_encoding +; CHECK-NEXT:.b8 11 // DW_FORM_data1 +; CHECK-NEXT:.b8 11 // DW_AT_byte_size +; CHECK-NEXT:.b8 11 // DW_FORM_data1 +; CHECK-NEXT:.b8 0 // EOM(1) +; CHECK-NEXT:.b8 0 // EOM(2) ; CHECK-NEXT:.b8 6 // Abbreviation Code ; CHECK-NEXT:.b8 15 // DW_TAG_pointer_type ; CHECK-NEXT:.b8 0 // DW_CHILDREN_no @@ -178,9 +178,9 @@ ; CHECK-NEXT:.b8 0 // EOM(1) ; CHECK-NEXT:.b8 0 // EOM(2) ; CHECK-NEXT:.b8 0 // EOM(3) -; CHECK-NEXT: } -; CHECK-NEXT: .section .debug_info -; CHECK-NEXT: { +; CHECK-NEXT: } +; CHECK-NEXT: .section .debug_info +; CHECK-NEXT: { ; CHECK-NEXT:.b32 240 // Length of Unit ; CHECK-NEXT:.b8 2 // DWARF version number ; CHECK-NEXT:.b8 0 @@ -259,46 +259,7 @@ ; CHECK-NEXT:.b8 0 ; CHECK-NEXT:.b64 $L__func_begin0 // DW_AT_low_pc ; CHECK-NEXT:.b64 $L__func_end0 // DW_AT_high_pc -; CHECK-NEXT:.b8 2 // Abbrev [2] 0x65:0x1a DW_TAG_variable -; CHECK-NEXT:.b8 71 // DW_AT_name -; CHECK-NEXT:.b8 76 -; CHECK-NEXT:.b8 79 -; CHECK-NEXT:.b8 66 -; CHECK-NEXT:.b8 65 -; CHECK-NEXT:.b8 76 -; CHECK-NEXT:.b8 0 -; CHECK-NEXT:.b32 127 // DW_AT_type -; CHECK-NEXT:.b8 1 // DW_AT_external -; CHECK-NEXT:.b8 1 // DW_AT_decl_file -; CHECK-NEXT:.b8 3 // DW_AT_decl_line -; CHECK-NEXT:.b8 5 // DW_AT_address_class -; CHECK-NEXT:.b8 9 // DW_AT_location -; CHECK-NEXT:.b8 3 -; CHECK-NEXT:.b64 GLOBAL -; CHECK-NEXT:.b8 3 // Abbrev [3] 0x7f:0x7 DW_TAG_base_type -; CHECK-NEXT:.b8 105 // DW_AT_name -; CHECK-NEXT:.b8 110 -; CHECK-NEXT:.b8 116 -; CHECK-NEXT:.b8 0 -; CHECK-NEXT:.b8 5 // DW_AT_encoding -; CHECK-NEXT:.b8 4 // DW_AT_byte_size -; CHECK-NEXT:.b8 2 // Abbrev [2] 0x86:0x1a DW_TAG_variable -; CHECK-NEXT:.b8 83 // DW_AT_name -; CHECK-NEXT:.b8 72 -; CHECK-NEXT:.b8 65 -; CHECK-NEXT:.b8 82 -; CHECK-NEXT:.b8 69 -; CHECK-NEXT:.b8 68 -; CHECK-NEXT:.b8 0 -; CHECK-NEXT:.b32 127 // DW_AT_type -; CHECK-NEXT:.b8 1 // DW_AT_external -; CHECK-NEXT:.b8 1 // DW_AT_decl_file -; CHECK-NEXT:.b8 4 // DW_AT_decl_line -; CHECK-NEXT:.b8 8 // DW_AT_address_class -; CHECK-NEXT:.b8 9 // DW_AT_location -; CHECK-NEXT:.b8 3 -; CHECK-NEXT:.b64 SHARED -; CHECK-NEXT:.b8 4 // Abbrev [4] 0xa0:0x45 DW_TAG_subprogram +; CHECK-NEXT:.b8 2 // Abbrev [2] 0x65:0x45 DW_TAG_subprogram ; CHECK-NEXT:.b64 $L__func_begin0 // DW_AT_low_pc ; CHECK-NEXT:.b64 $L__func_end0 // DW_AT_high_pc ; CHECK-NEXT:.b8 1 // DW_AT_frame_base @@ -316,32 +277,71 @@ ; CHECK-NEXT:.b8 1 // DW_AT_decl_file ; CHECK-NEXT:.b8 6 // DW_AT_decl_line ; CHECK-NEXT:.b8 1 // DW_AT_external -; CHECK-NEXT:.b8 5 // Abbrev [5] 0xc0:0x9 DW_TAG_formal_parameter +; CHECK-NEXT:.b8 3 // Abbrev [3] 0x85:0x9 DW_TAG_formal_parameter ; CHECK-NEXT:.b8 97 // DW_AT_name ; CHECK-NEXT:.b8 0 ; CHECK-NEXT:.b8 1 // DW_AT_decl_file ; CHECK-NEXT:.b8 6 // DW_AT_decl_line ; CHECK-NEXT:.b32 229 // DW_AT_type -; CHECK-NEXT:.b8 5 // Abbrev [5] 0xc9:0x9 DW_TAG_formal_parameter +; CHECK-NEXT:.b8 3 // Abbrev [3] 0x8e:0x9 DW_TAG_formal_parameter ; CHECK-NEXT:.b8 120 // DW_AT_name ; CHECK-NEXT:.b8 0 ; CHECK-NEXT:.b8 1 // DW_AT_decl_file ; CHECK-NEXT:.b8 6 // DW_AT_decl_line ; CHECK-NEXT:.b32 238 // DW_AT_type -; CHECK-NEXT:.b8 5 // Abbrev [5] 0xd2:0x9 DW_TAG_formal_parameter +; CHECK-NEXT:.b8 3 // Abbrev [3] 0x97:0x9 DW_TAG_formal_parameter ; CHECK-NEXT:.b8 121 // DW_AT_name ; CHECK-NEXT:.b8 0 ; CHECK-NEXT:.b8 1 // DW_AT_decl_file ; CHECK-NEXT:.b8 6 // DW_AT_decl_line ; CHECK-NEXT:.b32 238 // DW_AT_type -; CHECK-NEXT:.b8 5 // Abbrev [5] 0xdb:0x9 DW_TAG_formal_parameter +; CHECK-NEXT:.b8 3 // Abbrev [3] 0xa0:0x9 DW_TAG_formal_parameter ; CHECK-NEXT:.b8 105 // DW_AT_name ; CHECK-NEXT:.b8 0 ; CHECK-NEXT:.b8 1 // DW_AT_decl_file ; CHECK-NEXT:.b8 6 // DW_AT_decl_line -; CHECK-NEXT:.b32 127 // DW_AT_type +; CHECK-NEXT:.b32 196 // DW_AT_type ; CHECK-NEXT:.b8 0 // End Of Children Mark -; CHECK-NEXT:.b8 3 // Abbrev [3] 0xe5:0x9 DW_TAG_base_type +; CHECK-NEXT:.b8 4 // Abbrev [4] 0xaa:0x1a DW_TAG_variable +; CHECK-NEXT:.b8 71 // DW_AT_name +; CHECK-NEXT:.b8 76 +; CHECK-NEXT:.b8 79 +; CHECK-NEXT:.b8 66 +; CHECK-NEXT:.b8 65 +; CHECK-NEXT:.b8 76 +; CHECK-NEXT:.b8 0 +; CHECK-NEXT:.b32 196 // DW_AT_type +; CHECK-NEXT:.b8 1 // DW_AT_external +; CHECK-NEXT:.b8 1 // DW_AT_decl_file +; CHECK-NEXT:.b8 3 // DW_AT_decl_line +; CHECK-NEXT:.b8 5 // DW_AT_address_class +; CHECK-NEXT:.b8 9 // DW_AT_location +; CHECK-NEXT:.b8 3 +; CHECK-NEXT:.b64 GLOBAL +; CHECK-NEXT:.b8 5 // Abbrev [5] 0xc4:0x7 DW_TAG_base_type +; CHECK-NEXT:.b8 105 // DW_AT_name +; CHECK-NEXT:.b8 110 +; CHECK-NEXT:.b8 116 +; CHECK-NEXT:.b8 0 +; CHECK-NEXT:.b8 5 // DW_AT_encoding +; CHECK-NEXT:.b8 4 // DW_AT_byte_size +; CHECK-NEXT:.b8 4 // Abbrev [4] 0xcb:0x1a DW_TAG_variable +; CHECK-NEXT:.b8 83 // DW_AT_name +; CHECK-NEXT:.b8 72 +; CHECK-NEXT:.b8 65 +; CHECK-NEXT:.b8 82 +; CHECK-NEXT:.b8 69 +; CHECK-NEXT:.b8 68 +; CHECK-NEXT:.b8 0 +; CHECK-NEXT:.b32 196 // DW_AT_type +; CHECK-NEXT:.b8 1 // DW_AT_external +; CHECK-NEXT:.b8 1 // DW_AT_decl_file +; CHECK-NEXT:.b8 4 // DW_AT_decl_line +; CHECK-NEXT:.b8 8 // DW_AT_address_class +; CHECK-NEXT:.b8 9 // DW_AT_location +; CHECK-NEXT:.b8 3 +; CHECK-NEXT:.b64 SHARED +; CHECK-NEXT:.b8 5 // Abbrev [5] 0xe5:0x9 DW_TAG_base_type ; CHECK-NEXT:.b8 102 // DW_AT_name ; CHECK-NEXT:.b8 108 ; CHECK-NEXT:.b8 111 @@ -354,5 +354,5 @@ ; CHECK-NEXT:.b32 229 // DW_AT_type ; CHECK-NEXT:.b8 0 // End Of Children Mark ; CHECK-NEXT: } -; CHECK-NEXT: .section .debug_loc { } -; CHECK-NOT: debug_ +; CHECK-NEXT: .section .debug_loc { } +; CHECK-NOT: debug_ \ No newline at end of file diff --git a/llvm/test/DebugInfo/PowerPC/strict-dwarf.ll b/llvm/test/DebugInfo/PowerPC/strict-dwarf.ll --- a/llvm/test/DebugInfo/PowerPC/strict-dwarf.ll +++ b/llvm/test/DebugInfo/PowerPC/strict-dwarf.ll @@ -15,16 +15,27 @@ ; 3: DwarfUnit::addUInt() ; 4: addUInt(Block, (dwarf::Attribute)0, Form, Integer); +; CHECK: DW_TAG_subprogram +; CHECK-NOT: DW_TAG_ +; CHECK: DW_AT_name ("f") +; CHECK: DW_AT_noreturn +; +; CHECK: DW_TAG_variable ; CHECK: DW_AT_name ("var") ; CHECK-NOT: DW_TAG_ ; CHECK: DW_AT_alignment ; CHECK: DW_AT_location (DW_OP_addr 0x0) -; CHECK: DW_AT_noreturn + +; STRICT: DW_TAG_subprogram +; STRICT-NOT: DW_TAG_ +; STRICT: DW_AT_name ("f") +; STRICT-NOT: DW_AT_noreturn ; ; STRICT: DW_AT_name ("var") ; STRICT-NOT: DW_AT_alignment ; STRICT-NOT: DW_TAG_ ; STRICT: DW_AT_location (DW_OP_addr 0x0) +; ; STRICT-NOT: DW_AT_noreturn @_ZL3var = internal global i32 0, align 16, !dbg !0 diff --git a/llvm/test/DebugInfo/X86/2011-09-26-GlobalVarContext.ll b/llvm/test/DebugInfo/X86/2011-09-26-GlobalVarContext.ll --- a/llvm/test/DebugInfo/X86/2011-09-26-GlobalVarContext.ll +++ b/llvm/test/DebugInfo/X86/2011-09-26-GlobalVarContext.ll @@ -46,17 +46,16 @@ ; CHECK: DW_TAG_variable ; CHECK-NOT: DW_TAG -; CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x{{[0-9a-f]*}}] = "GLB") +; CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x{{[0-9a-f]*}}] = "LOC") ; CHECK-NOT: DW_TAG -; CHECK: DW_AT_decl_file [DW_FORM_data1] ("/work/llvm/vanilla/test/DebugInfo{{[/\\]}}test.c") +; CHECK: DW_AT_decl_file [DW_FORM_data1] ("/work/llvm/vanilla/test/DebugInfo{{[/\\]}}test.c") ; CHECK-NOT: DW_TAG -; CHECK: DW_AT_decl_line [DW_FORM_data1] (1) +; CHECK: DW_AT_decl_line [DW_FORM_data1] (4) ; CHECK: DW_TAG_variable ; CHECK-NOT: DW_TAG -; CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x{{[0-9a-f]*}}] = "LOC") +; CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x{{[0-9a-f]*}}] = "GLB") ; CHECK-NOT: DW_TAG -; CHECK: DW_AT_decl_file [DW_FORM_data1] ("/work/llvm/vanilla/test/DebugInfo{{[/\\]}}test.c") +; CHECK: DW_AT_decl_file [DW_FORM_data1] ("/work/llvm/vanilla/test/DebugInfo{{[/\\]}}test.c") ; CHECK-NOT: DW_TAG -; CHECK: DW_AT_decl_line [DW_FORM_data1] (4) - +; CHECK: DW_AT_decl_line [DW_FORM_data1] (1) \ No newline at end of file diff --git a/llvm/test/DebugInfo/X86/DW_AT_calling-convention.ll b/llvm/test/DebugInfo/X86/DW_AT_calling-convention.ll --- a/llvm/test/DebugInfo/X86/DW_AT_calling-convention.ll +++ b/llvm/test/DebugInfo/X86/DW_AT_calling-convention.ll @@ -21,10 +21,6 @@ ; CHECK: .debug_info contents: -; CHECK: DW_TAG_subroutine_type [[subroutine_abbrev]] * -; CHECK-NEXT: DW_AT_type [DW_FORM_ref4] {{.*}} -; CHECK-NEXT: DW_AT_calling_convention [DW_FORM_data1] (DW_CC_BORLAND_msfastcall) - ; CHECK: DW_TAG_subprogram [{{.*}}] * ; CHECK: DW_AT_low_pc ; CHECK: DW_AT_high_pc @@ -37,6 +33,10 @@ ; CHECK: DW_AT_type ; CHECK: DW_AT_external +; CHECK: DW_TAG_subroutine_type [[subroutine_abbrev]] * +; CHECK-NEXT: DW_AT_type [DW_FORM_ref4] {{.*}} +; CHECK-NEXT: DW_AT_calling_convention [DW_FORM_data1] (DW_CC_BORLAND_msfastcall) + ; ModuleID = 't.cpp' source_filename = "t.cpp" target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32" diff --git a/llvm/test/DebugInfo/X86/align_cpp11.ll b/llvm/test/DebugInfo/X86/align_cpp11.ll --- a/llvm/test/DebugInfo/X86/align_cpp11.ll +++ b/llvm/test/DebugInfo/X86/align_cpp11.ll @@ -33,20 +33,6 @@ ; auto Lambda = [i](){}; ; } -; CHECK: DW_TAG_class_type -; CHECK: DW_AT_name{{.*}}"C0" -; CHECK: DW_AT_alignment{{.*}}64 - -; CHECK: DW_TAG_variable -; CHECK: DW_AT_name{{.*}}"s" -; CHECK: DW_AT_alignment{{.*}}2048 - -; CHECK: DW_TAG_structure_type -; CHECK: DW_TAG_member -; CHECK: DW_TAG_member -; CHECK: DW_AT_name{{.*}}"xx" -; CHECK: DW_AT_alignment{{.*}}128 - ; CHECK: DW_TAG_enumeration_type ; CHECK: DW_AT_alignment{{.*}}16 ; CHECK: DW_TAG_enumerator @@ -68,6 +54,20 @@ ; CHECK: DW_TAG_subprogram ; CHECK: DW_TAG_formal_parameter +; CHECK: DW_TAG_class_type +; CHECK: DW_AT_name{{.*}}"C0" +; CHECK: DW_AT_alignment{{.*}}64 + +; CHECK: DW_TAG_variable +; CHECK: DW_AT_name{{.*}}"s" +; CHECK: DW_AT_alignment{{.*}}2048 + +; CHECK: DW_TAG_structure_type +; CHECK: DW_TAG_member +; CHECK: DW_TAG_member +; CHECK: DW_AT_name{{.*}}"xx" +; CHECK: DW_AT_alignment{{.*}}128 + ; CHECK: DW_TAG_class_type ; CHECK: DW_AT_name{{.*}}"C1" ; CHECK: DW_TAG_member diff --git a/llvm/test/DebugInfo/X86/align_objc.ll b/llvm/test/DebugInfo/X86/align_objc.ll --- a/llvm/test/DebugInfo/X86/align_objc.ll +++ b/llvm/test/DebugInfo/X86/align_objc.ll @@ -16,6 +16,13 @@ ; } ; CHECK: DW_TAG_compile_unit + +; CHECK: DW_TAG_subprogram +; CHECK: DW_TAG_variable +; CHECK: DW_TAG_variable +; CHECK: DW_AT_name{{.*}}"i" +; CHECK: DW_AT_alignment{{.*}}32 + ; CHECK: DW_TAG_variable ; CHECK: DW_TAG_typedef ; CHECK: DW_AT_name{{.*}}"S0" @@ -25,12 +32,6 @@ ; CHECK: DW_TAG_member ; CHECK: DW_TAG_base_type -; CHECK: DW_TAG_subprogram -; CHECK: DW_TAG_variable -; CHECK: DW_TAG_variable -; CHECK: DW_AT_name{{.*}}"i" -; CHECK: DW_AT_alignment{{.*}}32 - ; CHECK: DW_TAG_typedef ; CHECK: DW_AT_name{{.*}}"S1" ; CHECK: DW_TAG_structure_type diff --git a/llvm/test/DebugInfo/X86/arange-and-stub.ll b/llvm/test/DebugInfo/X86/arange-and-stub.ll --- a/llvm/test/DebugInfo/X86/arange-and-stub.ll +++ b/llvm/test/DebugInfo/X86/arange-and-stub.ll @@ -5,7 +5,7 @@ ; CHECK: .L_ZTId.DW.stub: ; CHECK: .data -; CHECK-NEXT: .Lsec_end0: +; CHECK-NEXT: .Lsec_end1: source_filename = "test/DebugInfo/X86/arange-and-stub.ll" target triple = "x86_64-linux-gnu" diff --git a/llvm/test/DebugInfo/X86/containing-type-extension-rust.ll b/llvm/test/DebugInfo/X86/containing-type-extension-rust.ll --- a/llvm/test/DebugInfo/X86/containing-type-extension-rust.ll +++ b/llvm/test/DebugInfo/X86/containing-type-extension-rust.ll @@ -2,6 +2,7 @@ ; RUN: llvm-dwarfdump -v -debug-info %t | FileCheck %s ; Check that any type can have a vtable holder. +; CHECK: DW_TAG_structure_type ; CHECK: [[SP:.*]]: DW_TAG_structure_type ; CHECK-NOT: TAG ; CHECK: DW_AT_containing_type [DW_FORM_ref4] ({{.*}} "f64") diff --git a/llvm/test/DebugInfo/X86/debug-info-access.ll b/llvm/test/DebugInfo/X86/debug-info-access.ll --- a/llvm/test/DebugInfo/X86/debug-info-access.ll +++ b/llvm/test/DebugInfo/X86/debug-info-access.ll @@ -74,6 +74,10 @@ ; F f; ; H h; +; CHECK: DW_TAG_subprogram +; CHECK: DW_AT_name {{.*}}"free") +; CHECK-NOT: DW_AT_accessibility + ; CHECK: DW_TAG_member ; CHECK: DW_AT_name {{.*}}"union_priv") ; CHECK-NOT: DW_TAG @@ -142,10 +146,6 @@ ; CHECK: DW_AT_name ("I") ; CHECK: DW_AT_accessibility (DW_ACCESS_private) -; CHECK: DW_TAG_subprogram -; CHECK: DW_AT_name {{.*}}"free") -; CHECK-NOT: DW_AT_accessibility - %union.U = type { i32 } %struct.A = type { i8 } %class.B = type { i32 } diff --git a/llvm/test/DebugInfo/X86/debug-info-static-member.ll b/llvm/test/DebugInfo/X86/debug-info-static-member.ll --- a/llvm/test/DebugInfo/X86/debug-info-static-member.ll +++ b/llvm/test/DebugInfo/X86/debug-info-static-member.ll @@ -105,6 +105,7 @@ ; (for variables) or DW_AT_const_value (for constants). ; ; PRESENT: .debug_info contents: +; PRESENT: NULL ; PRESENT: DW_TAG_variable ; PRESENT-NEXT: DW_AT_specification {{.*}} "a" ; PRESENT-NEXT: DW_AT_location @@ -155,6 +156,7 @@ ; For Darwin gdb: ; DARWINP: .debug_info contents: +; DARWINP: NULL ; DARWINP: DW_TAG_variable ; DARWINP-NEXT: DW_AT_specification {{.*}} "a" ; DARWINP-NEXT: DW_AT_location diff --git a/llvm/test/DebugInfo/X86/dwarf-aranges.ll b/llvm/test/DebugInfo/X86/dwarf-aranges.ll --- a/llvm/test/DebugInfo/X86/dwarf-aranges.ll +++ b/llvm/test/DebugInfo/X86/dwarf-aranges.ll @@ -8,22 +8,22 @@ ; -- alignment -- ; CHECK-NEXT: .zero 4,255 +; - it should have made one span covering all functions in this CU. +; CHECK-NEXT: .quad .Lfunc_begin0 +; CHECK-NEXT: .quad .Lsec_end0-.Lfunc_begin0 + ; - it should have made one span covering all vars in this CU. ; CHECK-NEXT: .quad some_data -; CHECK-NEXT: .quad .Lsec_end0-some_data +; CHECK-NEXT: .quad .Lsec_end1-some_data ; - it should have made one span covering all vars in this CU. ; CHECK-NEXT: .quad some_other -; CHECK-NEXT: .quad .Lsec_end1-some_other +; CHECK-NEXT: .quad .Lsec_end2-some_other ; - it should have made one span for each symbol. ; CHECK-NEXT: .quad some_bss ; CHECK-NEXT: .quad 4 -; - it should have made one span covering all functions in this CU. -; CHECK-NEXT: .quad .Lfunc_begin0 -; CHECK-NEXT: .quad .Lsec_end2-.Lfunc_begin0 - ; -- finish -- ; CHECK-NEXT: # ARange terminator diff --git a/llvm/test/DebugInfo/X86/dwarf-linkage-names.ll b/llvm/test/DebugInfo/X86/dwarf-linkage-names.ll --- a/llvm/test/DebugInfo/X86/dwarf-linkage-names.ll +++ b/llvm/test/DebugInfo/X86/dwarf-linkage-names.ll @@ -17,10 +17,10 @@ ; This assumes the variable will appear before the function. ; LINKAGE1: .section .debug_info -; LINKAGE1: DW_TAG_variable +; LINKAGE1: DW_TAG_subprogram ; LINKAGE1-NOT: DW_TAG ; LINKAGE1: {{DW_AT_(MIPS_)?linkage_name}} -; LINKAGE1: DW_TAG_subprogram +; LINKAGE1: DW_TAG_variable ; LINKAGE1-NOT: DW_TAG ; LINKAGE1: {{DW_AT_(MIPS_)?linkage_name}} ; LINKAGE1: .section diff --git a/llvm/test/DebugInfo/X86/dwarfdump-DIImportedEntity_elements.ll b/llvm/test/DebugInfo/X86/dwarfdump-DIImportedEntity_elements.ll --- a/llvm/test/DebugInfo/X86/dwarfdump-DIImportedEntity_elements.ll +++ b/llvm/test/DebugInfo/X86/dwarfdump-DIImportedEntity_elements.ll @@ -3,21 +3,21 @@ ; RUN: llc %s -filetype=obj -o - | llvm-dwarfdump - | FileCheck %s -; CHECK: [[MYMOD:0x[0-9a-f]+]]: DW_TAG_module -; CHECK: DW_AT_name ("mymod") -; CHECK: [[VAR1:0x[0-9a-f]+]]: DW_TAG_variable -; CHECK: DW_AT_name ("var1") - ; CHECK: DW_TAG_subprogram ; CHECK: DW_AT_name ("main") ; CHECK: DW_TAG_subprogram ; CHECK: DW_AT_name ("use_renamed") ; CHECK: DW_TAG_imported_module -; CHECK: DW_AT_import ([[MYMOD]]) +; CHECK: DW_AT_import ([[MYMOD:0x[0-9a-f]+]]) ; CHECK: DW_TAG_imported_declaration -; CHECK: DW_AT_import ([[VAR1]]) +; CHECK: DW_AT_import ([[VAR1:0x[0-9a-f]+]]) ; CHECK: DW_AT_name ("var4") +; CHECK: [[MYMOD]]: DW_TAG_module +; CHECK: DW_AT_name ("mymod") +; CHECK: [[VAR1]]: DW_TAG_variable +; CHECK: DW_AT_name ("var1") + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;This test case is generated from ;;module mymod diff --git a/llvm/test/DebugInfo/X86/generate-odr-hash.ll b/llvm/test/DebugInfo/X86/generate-odr-hash.ll --- a/llvm/test/DebugInfo/X86/generate-odr-hash.ll +++ b/llvm/test/DebugInfo/X86/generate-odr-hash.ll @@ -53,25 +53,27 @@ ; SINGLE-LABEL: .debug_info contents: ; FISSION-LABEL: .debug_info.dwo contents: ; CHECK: Compile Unit: length = [[CU_SIZE:[0-9a-f]+]] +; CHECK: [[CU_NAME:^0x........]]: DW_TAG_compile_unit -; CHECK: [[BAR:^0x........]]: DW_TAG_structure_type +; CHECK: [[BAR:^0x........]]: DW_TAG_structure_type [{{[0-9]+}}] ([[CU_NAME]]) ; CHECK-NEXT: DW_AT_declaration ; CHECK-NEXT: DW_AT_signature {{.*}} (0x1d02f3be30cc5688) ; CHECK: [[FLUFFY:^0x........]]: DW_TAG_class_type ; CHECK-NEXT: DW_AT_declaration ; CHECK-NEXT: DW_AT_signature {{.*}} (0xb04af47397402e77) +; CHECK: [[WOMBAT:^0x........]]: DW_TAG_structure_type [{{[0-9]+}}] * ([[CU_NAME]]) +; CHECK-NEXT: DW_AT_declaration +; CHECK-NEXT: DW_AT_signature {{.*}} (0xfd756cee88f8a118) + ; Ensure the CU-local type 'walrus' is not placed in a type unit. -; CHECK: [[WALRUS:^0x........]]: DW_TAG_structure_type +; CHECK: [[WALRUS_NAMESPACE:^0x........]]: DW_TAG_namespace [{{[0-9]+}}] * ([[CU_NAME]]) +; CHECK: [[WALRUS:^0x........]]: DW_TAG_structure_type [{{[0-9]+}}] * ([[WALRUS_NAMESPACE]]) ; CHECK-NEXT: DW_AT_name{{.*}}"walrus" ; CHECK-NEXT: DW_AT_byte_size ; CHECK-NEXT: DW_AT_decl_file ; CHECK-NEXT: DW_AT_decl_line -; CHECK: [[WOMBAT:^0x........]]: DW_TAG_structure_type -; CHECK-NEXT: DW_AT_declaration -; CHECK-NEXT: DW_AT_signature {{.*}} (0xfd756cee88f8a118) - ; SINGLE-LABEL: .debug_types contents: ; FISSION: .debug_types.dwo contents: diff --git a/llvm/test/DebugInfo/X86/gnu-public-names.ll b/llvm/test/DebugInfo/X86/gnu-public-names.ll --- a/llvm/test/DebugInfo/X86/gnu-public-names.ll +++ b/llvm/test/DebugInfo/X86/gnu-public-names.ll @@ -77,32 +77,36 @@ ; CHECK: DW_AT_GNU_pubnames (true) ; CHECK-NOT: DW_AT_GNU_pubtypes [ -; CHECK: [[STATIC_MEM_VAR:0x[0-9a-f]+]]: DW_TAG_variable -; CHECK: DW_AT_specification {{.*}} "static_member_variable" +; CHECK: DW_TAG_enumeration +; CHECK: [[UNNAMED_ENUM_ENUMERATOR:0x[0-9a-f]+]]: DW_TAG_enumerator +; CHECK: DW_AT_name ("unnamed_enum_enumerator") +; CHECK: NULL -; CHECK: [[C:0x[0-9a-f]+]]: DW_TAG_structure_type -; CHECK: DW_AT_name ("C") -; CHECK: DW_TAG_member -; CHECK: DW_AT_name ("static_member_variable") -; CHECK: DW_TAG_subprogram -; CHECK: DW_AT_linkage_name -; CHECK: DW_AT_name ("member_function") -; CHECK: DW_TAG_formal_parameter -; CHECK: NULL -; CHECK: DW_TAG_subprogram -; CHECK: DW_AT_linkage_name -; CHECK: DW_AT_name ("static_member_function") +; CHECK: [[UNSIGNED_INT:0x[0-9a-f]+]]: DW_TAG_base_type +; CHECK: DW_AT_name ("unsigned int") + +; CHECK: [[NAMED_ENUM:0x[0-9a-f]+]]: DW_TAG_enumeration +; CHECK: DW_AT_name ("named_enum") +; CHECK: [[NAMED_ENUM_ENUMERATOR:0x[0-9a-f]+]]: DW_TAG_enumerator +; CHECK: DW_AT_name ("named_enum_enumerator") +; CHECK: NULL + +; CHECK: [[NAMED_ENUM_CLASS:0x[0-9a-f]+]]: DW_TAG_enumeration +; CHECK: DW_AT_name ("named_enum_class") +; CHECK: [[NAMED_ENUM_CLASS_ENUMERATOR:0x[0-9a-f]+]]: DW_TAG_enumerator +; CHECK: DW_AT_name ("named_enum_class_enumerator") ; CHECK: NULL ; CHECK: [[INT:0x[0-9a-f]+]]: DW_TAG_base_type ; CHECK: DW_AT_name ("int") -; CHECK: DW_TAG_pointer_type - -; CHECK: [[GLOB_VAR:0x[0-9a-f]+]]: DW_TAG_variable -; CHECK: DW_AT_name ("global_variable") ; CHECK: [[NS:0x[0-9a-f]+]]: DW_TAG_namespace ; CHECK: DW_AT_name ("ns") +; CHECK: DW_TAG_variable +; CHECK: DW_AT_name ("global_namespace_variable_decl") +; CHECK: [[GLOB_NS_FUNC:0x[0-9a-f]+]]: DW_TAG_subprogram +; CHECK: DW_AT_linkage_name +; CHECK: DW_AT_name ("global_namespace_function") ; CHECK: [[GLOB_NS_VAR:0x[0-9a-f]+]]: DW_TAG_variable ; CHECK: DW_AT_name ("global_namespace_variable") ; CHECK-NOT: DW_AT_specification @@ -117,12 +121,38 @@ ; CHECK: DW_AT_name ("D") ; CHECK: DW_TAG_member ; CHECK: NULL -; CHECK: DW_TAG_variable -; CHECK: [[GLOB_NS_FUNC:0x[0-9a-f]+]]: DW_TAG_subprogram +; CHECK: NULL + +; CHECK: DW_TAG_imported_declaration + +; CHECK: [[C:0x[0-9a-f]+]]: DW_TAG_structure_type +; CHECK: DW_AT_name ("C") +; CHECK: DW_TAG_member +; CHECK: DW_AT_name ("static_member_variable") +; CHECK: DW_TAG_subprogram ; CHECK: DW_AT_linkage_name -; CHECK: DW_AT_name ("global_namespace_function") +; CHECK: DW_AT_name ("member_function") +; CHECK: DW_TAG_formal_parameter +; CHECK: NULL +; CHECK: DW_TAG_subprogram +; CHECK: DW_AT_linkage_name +; CHECK: DW_AT_name ("static_member_function") ; CHECK: NULL +; CHECK: DW_TAG_pointer_type + +; CHECK: [[MEM_FUNC:0x[0-9a-f]+]]: DW_TAG_subprogram +; CHECK: DW_AT_specification {{.*}} "_ZN1C15member_functionEv" +; CHECK: DW_TAG_formal_parameter +; CHECK: NULL + +; CHECK: [[STATIC_MEM_FUNC:0x[0-9a-f]+]]: DW_TAG_subprogram +; CHECK: DW_AT_specification {{.*}} "_ZN1C22static_member_functionEv" + +; CHECK: [[GLOBAL_FUNC:0x[0-9a-f]+]]: DW_TAG_subprogram +; CHECK: DW_AT_linkage_name +; CHECK: DW_AT_name ("global_function") + ; CHECK: DW_TAG_subprogram ; CHECK: DW_AT_name ("f3") ; CHECK: [[F3_Z:.*]]: DW_TAG_variable @@ -130,6 +160,15 @@ ; CHECK: DW_AT_location ; CHECK: NULL +; CHECK: DW_TAG_subprogram +; CHECK: DW_AT_name ("f7") + +; CHECK: [[STATIC_MEM_VAR:0x[0-9a-f]+]]: DW_TAG_variable +; CHECK: DW_AT_specification {{.*}} "static_member_variable" + +; CHECK: [[GLOB_VAR:0x[0-9a-f]+]]: DW_TAG_variable +; CHECK: DW_AT_name ("global_variable") + ; CHECK: [[ANON:.*]]: DW_TAG_namespace ; CHECK-NOT: DW_AT_name ; CHECK: [[ANON_I:.*]]: DW_TAG_variable @@ -150,41 +189,6 @@ ; CHECK: NULL ; CHECK: NULL -; CHECK: DW_TAG_enumeration -; CHECK: [[UNNAMED_ENUM_ENUMERATOR:0x[0-9a-f]+]]: DW_TAG_enumerator -; CHECK: DW_AT_name ("unnamed_enum_enumerator") -; CHECK: NULL - -; CHECK: [[UNSIGNED_INT:0x[0-9a-f]+]]: DW_TAG_base_type -; CHECK: DW_AT_name ("unsigned int") - -; CHECK: [[NAMED_ENUM:0x[0-9a-f]+]]: DW_TAG_enumeration -; CHECK: DW_AT_name ("named_enum") -; CHECK: [[NAMED_ENUM_ENUMERATOR:0x[0-9a-f]+]]: DW_TAG_enumerator -; CHECK: DW_AT_name ("named_enum_enumerator") -; CHECK: NULL - -; CHECK: [[NAMED_ENUM_CLASS:0x[0-9a-f]+]]: DW_TAG_enumeration -; CHECK: DW_AT_name ("named_enum_class") -; CHECK: [[NAMED_ENUM_CLASS_ENUMERATOR:0x[0-9a-f]+]]: DW_TAG_enumerator -; CHECK: DW_AT_name ("named_enum_class_enumerator") -; CHECK: NULL - -; CHECK: DW_TAG_imported_declaration - -; CHECK: [[MEM_FUNC:0x[0-9a-f]+]]: DW_TAG_subprogram -; CHECK: DW_AT_specification {{.*}} "_ZN1C15member_functionEv" -; CHECK: DW_TAG_formal_parameter -; CHECK: NULL - -; CHECK: [[STATIC_MEM_FUNC:0x[0-9a-f]+]]: DW_TAG_subprogram -; CHECK: DW_AT_specification {{.*}} "_ZN1C22static_member_functionEv" - -; CHECK: [[GLOBAL_FUNC:0x[0-9a-f]+]]: DW_TAG_subprogram -; CHECK: DW_AT_linkage_name -; CHECK: DW_AT_name ("global_function") - -; CHECK: DW_TAG_subprogram ; CHECK: DW_TAG_pointer_type ; CHECK: DW_TAG_pointer_type ; CHECK: NULL @@ -192,40 +196,40 @@ ; CHECK-LABEL: .debug_gnu_pubnames contents: ; CHECK-NEXT: length = {{.*}}, version = 0x0002, unit_offset = 0x00000000, unit_size = {{.*}} ; CHECK-NEXT: Offset Linkage Kind Name -; CHECK-NEXT: [[GLOBAL_FUNC]] EXTERNAL FUNCTION "global_function" -; CHECK-NEXT: [[NS]] EXTERNAL TYPE "ns" -; CHECK-NEXT: [[OUTER_ANON_C]] STATIC VARIABLE "outer::(anonymous namespace)::c" -; CHECK-NEXT: [[ANON_I]] STATIC VARIABLE "(anonymous namespace)::i" -; CHECK-NEXT: [[GLOB_NS_FUNC]] EXTERNAL FUNCTION "ns::global_namespace_function" +; CHECK-DAG: [[GLOBAL_FUNC]] EXTERNAL FUNCTION "global_function" +; CHECK-DAG: [[NS]] EXTERNAL TYPE "ns" +; CHECK-DAG: [[OUTER_ANON_C]] STATIC VARIABLE "outer::(anonymous namespace)::c" +; CHECK-DAG: [[ANON_I]] STATIC VARIABLE "(anonymous namespace)::i" +; CHECK-DAG: [[GLOB_NS_FUNC]] EXTERNAL FUNCTION "ns::global_namespace_function" ; GCC Doesn't put local statics in pubnames, but it seems not unreasonable and ; comes out naturally from LLVM's implementation, so I'm OK with it for now. If ; it's demonstrated that this is a major size concern or degrades debug info ; consumer behavior, feel free to change it. -; CHECK-NEXT: [[F3_Z]] STATIC VARIABLE "f3::z" -; CHECK-NEXT: [[ANON]] EXTERNAL TYPE "(anonymous namespace)" -; CHECK-NEXT: [[OUTER_ANON]] EXTERNAL TYPE "outer::(anonymous namespace)" -; CHECK-NEXT: [[ANON_INNER_B]] STATIC VARIABLE "(anonymous namespace)::inner::b" -; CHECK-NEXT: [[OUTER]] EXTERNAL TYPE "outer" +; CHECK-DAG: [[F3_Z]] STATIC VARIABLE "f3::z" +; CHECK-DAG: [[ANON]] EXTERNAL TYPE "(anonymous namespace)" +; CHECK-DAG: [[OUTER_ANON]] EXTERNAL TYPE "outer::(anonymous namespace)" +; CHECK-DAG: [[ANON_INNER_B]] STATIC VARIABLE "(anonymous namespace)::inner::b" +; CHECK-DAG: [[OUTER]] EXTERNAL TYPE "outer" ; FIXME: GCC produces enumerators as EXTERNAL, not STATIC -; CHECK-NEXT: [[NAMED_ENUM_CLASS_ENUMERATOR]] STATIC VARIABLE "named_enum_class_enumerator" -; CHECK-NEXT: [[MEM_FUNC]] EXTERNAL FUNCTION "C::member_function" -; CHECK-NEXT: [[GLOB_VAR]] EXTERNAL VARIABLE "global_variable" -; CHECK-NEXT: [[GLOB_NS_VAR]] EXTERNAL VARIABLE "ns::global_namespace_variable" -; CHECK-NEXT: [[ANON_INNER]] EXTERNAL TYPE "(anonymous namespace)::inner" -; CHECK-NEXT: [[D_VAR]] EXTERNAL VARIABLE "ns::d" -; CHECK-NEXT: [[NAMED_ENUM_ENUMERATOR]] STATIC VARIABLE "named_enum_enumerator" -; CHECK-NEXT: [[STATIC_MEM_VAR]] EXTERNAL VARIABLE "C::static_member_variable" -; CHECK-NEXT: [[STATIC_MEM_FUNC]] EXTERNAL FUNCTION "C::static_member_function" -; CHECK-NEXT: [[UNNAMED_ENUM_ENUMERATOR]] STATIC VARIABLE "unnamed_enum_enumerator" +; CHECK-DAG: [[NAMED_ENUM_CLASS_ENUMERATOR]] STATIC VARIABLE "named_enum_class_enumerator" +; CHECK-DAG: [[MEM_FUNC]] EXTERNAL FUNCTION "C::member_function" +; CHECK-DAG: [[GLOB_VAR]] EXTERNAL VARIABLE "global_variable" +; CHECK-DAG: [[GLOB_NS_VAR]] EXTERNAL VARIABLE "ns::global_namespace_variable" +; CHECK-DAG: [[ANON_INNER]] EXTERNAL TYPE "(anonymous namespace)::inner" +; CHECK-DAG: [[D_VAR]] EXTERNAL VARIABLE "ns::d" +; CHECK-DAG: [[NAMED_ENUM_ENUMERATOR]] STATIC VARIABLE "named_enum_enumerator" +; CHECK-DAG: [[STATIC_MEM_VAR]] EXTERNAL VARIABLE "C::static_member_variable" +; CHECK-DAG: [[STATIC_MEM_FUNC]] EXTERNAL FUNCTION "C::static_member_function" +; CHECK-DAG: [[UNNAMED_ENUM_ENUMERATOR]] STATIC VARIABLE "unnamed_enum_enumerator" ; CHECK-LABEL: debug_gnu_pubtypes contents: ; CHECK: Offset Linkage Kind Name -; CHECK-NEXT: [[C]] EXTERNAL TYPE "C" -; CHECK-NEXT: [[UNSIGNED_INT]] STATIC TYPE "unsigned int" -; CHECK-NEXT: [[D]] EXTERNAL TYPE "ns::D" -; CHECK-NEXT: [[NAMED_ENUM]] EXTERNAL TYPE "named_enum" -; CHECK-NEXT: [[INT]] STATIC TYPE "int" -; CHECK-NEXT: [[NAMED_ENUM_CLASS]] EXTERNAL TYPE "named_enum_class" +; CHECK-DAG: [[C]] EXTERNAL TYPE "C" +; CHECK-DAG: [[UNSIGNED_INT]] STATIC TYPE "unsigned int" +; CHECK-DAG: [[D]] EXTERNAL TYPE "ns::D" +; CHECK-DAG: [[NAMED_ENUM]] EXTERNAL TYPE "named_enum" +; CHECK-DAG: [[INT]] STATIC TYPE "int" +; CHECK-DAG: [[NAMED_ENUM_CLASS]] EXTERNAL TYPE "named_enum_class" %struct.C = type { i8 } %"struct.ns::D" = type { i32 } diff --git a/llvm/test/DebugInfo/X86/linkage-name.ll b/llvm/test/DebugInfo/X86/linkage-name.ll --- a/llvm/test/DebugInfo/X86/linkage-name.ll +++ b/llvm/test/DebugInfo/X86/linkage-name.ll @@ -1,7 +1,7 @@ ; RUN: llc -mtriple=x86_64-macosx %s -o %t -filetype=obj ; RUN: llvm-dwarfdump -v -debug-info %t | FileCheck %s -; CHECK: DW_TAG_subprogram [9] * +; CHECK: DW_TAG_subprogram [8] * ; CHECK-NOT: DW_AT_{{(MIPS_)?}}linkage_name ; CHECK: DW_AT_specification diff --git a/llvm/test/DebugInfo/X86/namelist1.ll b/llvm/test/DebugInfo/X86/namelist1.ll --- a/llvm/test/DebugInfo/X86/namelist1.ll +++ b/llvm/test/DebugInfo/X86/namelist1.ll @@ -4,10 +4,12 @@ ; RUN: llc -O0 -mtriple=x86_64-unknown-linux-gnu %s -filetype=obj -o %t.o ; RUN: llvm-dwarfdump %t.o | FileCheck %s ; -; CHECK: [[ITEM1:0x.+]]: DW_TAG_variable -; CHECK: DW_AT_name ("a") ; CHECK: [[ITEM2:0x.+]]: DW_TAG_variable ; CHECK: DW_AT_name ("b") +; CHECK: {{0x.+}}: DW_TAG_variable +; CHECK: DW_AT_const_value +; CHECK: [[ITEM1:0x.+]]: DW_TAG_variable +; CHECK: DW_AT_name ("a") ; CHECK: DW_TAG_namelist ; CHECK: DW_AT_name ("nml") ; CHECK: DW_TAG_namelist_item diff --git a/llvm/test/DebugInfo/X86/prototyped.ll b/llvm/test/DebugInfo/X86/prototyped.ll --- a/llvm/test/DebugInfo/X86/prototyped.ll +++ b/llvm/test/DebugInfo/X86/prototyped.ll @@ -24,11 +24,11 @@ ; void (*x)(void); ; void y(void) { } -; CHECK: DW_TAG_subroutine_type +; CHECK: DW_TAG_subprogram ; CHECK-NOT: {{DW_TAG|NULL}} ; CHECK: DW_AT_prototyped (true) -; CHECK: DW_TAG_subprogram +; CHECK: DW_TAG_subroutine_type ; CHECK-NOT: {{DW_TAG|NULL}} ; CHECK: DW_AT_prototyped (true) diff --git a/llvm/test/DebugInfo/X86/ref_addr_relocation.ll b/llvm/test/DebugInfo/X86/ref_addr_relocation.ll --- a/llvm/test/DebugInfo/X86/ref_addr_relocation.ll +++ b/llvm/test/DebugInfo/X86/ref_addr_relocation.ll @@ -33,12 +33,12 @@ ; Make sure we use relocation for ref_addr on non-darwin platforms. ; CHECK: DW_TAG_compile_unit +; CHECK: DW_TAG_structure_type ; CHECK: DW_TAG_variable ; ELF-ASM: .long [[TYPE:.*]] # DW_AT_type ; DARWIN-ASM2: .long [[TYPE:.*]] ## DW_AT_type ; DARWIN-ASM4: .long [[TYPE:.*]] ## DW_AT_type ; COFF-ASM: .long [[TYPE:.*]] # DW_AT_type -; CHECK: DW_TAG_structure_type ; CHECK: cu_begin1 ; CHECK: DW_TAG_compile_unit ; CHECK-NOT: DW_TAG_structure_type @@ -60,9 +60,9 @@ ; CHECK-DWARF: DW_AT_type [DW_FORM_ref_addr] {{.*}}[[ADDR]] ; CHECK-DWARF2: DW_TAG_compile_unit +; CHECK-DWARF2: [[ADDR:.*]]: DW_TAG_structure_type ; CHECK-DWARF2: DW_TAG_variable -; CHECK-DWARF2: DW_AT_type [DW_FORM_ref4] {{.*}} => {[[ADDR:.*]]} -; CHECK-DWARF2: [[ADDR]]: DW_TAG_structure_type +; CHECK-DWARF2: DW_AT_type [DW_FORM_ref4] {{.*}} => {[[ADDR]]} source_filename = "test/DebugInfo/X86/ref_addr_relocation.ll" diff --git a/llvm/test/DebugInfo/X86/static-local-var.ll b/llvm/test/DebugInfo/X86/static-local-var.ll new file mode 100644 --- /dev/null +++ b/llvm/test/DebugInfo/X86/static-local-var.ll @@ -0,0 +1,149 @@ +; RUN: llc -O0 -mtriple=x86_64-unknown-linux-gnu %s -filetype=obj -o - | llvm-dwarfdump - | FileCheck %s "--implicit-check-not={{NULL|DW_TAG}}" +; +; Test case generated from: +; +; int __attribute__((always_inline)) g(int n) { +; static int x[10]; +; int y = 1; +; return x[n] + y; +; } +; int f(int n) { return g(n); } +; +; Check that the DW_TAG_varaible for `x` is defined only once in the abstract definition of `g` +; +; CHECK: DW_TAG_compile_unit +; +; Definition of `g` +; CHECK: DW_TAG_subprogram +; CHECK: DW_AT_abstract_origin ([[G_ABSTRACT:0x[0-9]+]] "g") +; CHECK: DW_TAG_formal_parameter +; CHECK: DW_AT_abstract_origin ([[N_ABSTRACT:0x[0-9]+]] "n") +; CHECK: DW_TAG_variable +; CHECK: DW_AT_abstract_origin ([[Y_ABSTRACT:0x[0-9]+]] "y") +; CHECK: NULL +; +; Abstract definition of `g` +; CHECK: [[G_ABSTRACT]]: DW_TAG_subprogram +; CHECK: DW_AT_name ("g") +; CHECK: [[N_ABSTRACT]]: DW_TAG_formal_parameter +; CHECK: DW_AT_name ("n") +; CHECK: [[Y_ABSTRACT]]: DW_TAG_variable +; CHECK: DW_AT_name ("y") +; CHECK: DW_TAG_variable +; CHECK: DW_AT_name ("x") +; CHECK: NULL +; +; CHECK: DW_TAG_base_type +; +; Definition of `f` +; CHECK: DW_TAG_subprogram +; CHECK: DW_AT_name ("f") +; CHECK: DW_TAG_formal_parameter +; Inlined definition of `g` +; CHECK: DW_TAG_inlined_subroutine +; CHECK: DW_AT_abstract_origin ([[G_ABSTRACT]] "g") +; CHECK: DW_TAG_formal_parameter +; CHECK: DW_AT_abstract_origin ([[N_ABSTRACT:0x[0-9]+]] "n") +; CHECK: DW_TAG_variable +; CHECK: DW_AT_abstract_origin ([[Y_ABSTRACT:0x[0-9]+]] "y") +; CHECK: NULL +; CHECK: NULL + +; CHECK: DW_TAG_array_type +; CHECK: DW_TAG_subrange_type +; CHECK: NULL +; CHECK: DW_TAG_base_type +; CHECK: NULL + +@g.x = internal global [10 x i32] zeroinitializer, align 16, !dbg !0 + +define dso_local i32 @g(i32 %n) #0 !dbg !2 { +entry: + %n.addr = alloca i32, align 4 + %y = alloca i32, align 4 + store i32 %n, ptr %n.addr, align 4 + call void @llvm.dbg.declare(metadata ptr %n.addr, metadata !21, metadata !DIExpression()), !dbg !22 + call void @llvm.dbg.declare(metadata ptr %y, metadata !23, metadata !DIExpression()), !dbg !24 + store i32 1, ptr %y, align 4, !dbg !24 + %i = load i32, ptr %n.addr, align 4, !dbg !25 + %idxprom = sext i32 %i to i64, !dbg !26 + %arrayidx = getelementptr inbounds [10 x i32], ptr @g.x, i64 0, i64 %idxprom, !dbg !26 + %i1 = load i32, ptr %arrayidx, align 4, !dbg !26 + %i2 = load i32, ptr %y, align 4, !dbg !27 + %add = add nsw i32 %i1, %i2, !dbg !28 + ret i32 %add, !dbg !29 +} + +declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 + +define dso_local i32 @f(i32 %n) #2 !dbg !30 { +entry: + %n.addr.i = alloca i32, align 4 + %y.i = alloca i32, align 4 + %n.addr = alloca i32, align 4 + store i32 %n, ptr %n.addr, align 4 + call void @llvm.dbg.declare(metadata ptr %n.addr, metadata !31, metadata !DIExpression()), !dbg !32 + %0 = load i32, ptr %n.addr, align 4, !dbg !33 + store i32 %0, ptr %n.addr.i, align 4 + call void @llvm.dbg.declare(metadata ptr %n.addr.i, metadata !21, metadata !DIExpression()), !dbg !34 + call void @llvm.dbg.declare(metadata ptr %y.i, metadata !23, metadata !DIExpression()), !dbg !36 + store i32 1, ptr %y.i, align 4, !dbg !36 + %1 = load i32, ptr %n.addr.i, align 4, !dbg !37 + %idxprom.i = sext i32 %1 to i64, !dbg !38 + %arrayidx.i = getelementptr inbounds [10 x i32], ptr @g.x, i64 0, i64 %idxprom.i, !dbg !38 + %2 = load i32, ptr %arrayidx.i, align 4, !dbg !38 + %3 = load i32, ptr %y.i, align 4, !dbg !39 + %add.i = add nsw i32 %2, %3, !dbg !40 + ret i32 %add.i, !dbg !41 +} + +attributes #0 = { alwaysinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) } +attributes #2 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } + +!llvm.dbg.cu = !{!7} +!llvm.module.flags = !{!13, !14, !15, !16, !17, !18, !19} +!llvm.ident = !{!20} + +!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) +!1 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !3, line: 2, type: !10, isLocal: true, isDefinition: true) +!2 = distinct !DISubprogram(name: "g", scope: !3, file: !3, line: 1, type: !4, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !7, retainedNodes: !9) +!3 = !DIFile(filename: "test.c", directory: "/_build", checksumkind: CSK_MD5, checksum: "b0f3c9d2dcba025ece076268b66296cc") +!4 = !DISubroutineType(types: !5) +!5 = !{!6, !6} +!6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!7 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, producer: "clang version 16.0.0 (ssh://git@github.com/llvm/llvm-project.git 911b73bed0eb651a0cee6acc4eff45c275c6c86c)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !8, splitDebugInlining: false, nameTableKind: None) +!8 = !{!0} +!9 = !{} +!10 = !DICompositeType(tag: DW_TAG_array_type, baseType: !6, size: 320, elements: !11) +!11 = !{!12} +!12 = !DISubrange(count: 10) +!13 = !{i32 7, !"Dwarf Version", i32 5} +!14 = !{i32 2, !"Debug Info Version", i32 3} +!15 = !{i32 1, !"wchar_size", i32 4} +!16 = !{i32 8, !"PIC Level", i32 2} +!17 = !{i32 7, !"PIE Level", i32 2} +!18 = !{i32 7, !"uwtable", i32 2} +!19 = !{i32 7, !"frame-pointer", i32 2} +!20 = !{!"clang version 16.0.0 (ssh://git@github.com/llvm/llvm-project.git 911b73bed0eb651a0cee6acc4eff45c275c6c86c)"} +!21 = !DILocalVariable(name: "n", arg: 1, scope: !2, file: !3, line: 1, type: !6) +!22 = !DILocation(line: 1, column: 42, scope: !2) +!23 = !DILocalVariable(name: "y", scope: !2, file: !3, line: 3, type: !6) +!24 = !DILocation(line: 3, column: 5, scope: !2) +!25 = !DILocation(line: 4, column: 10, scope: !2) +!26 = !DILocation(line: 4, column: 8, scope: !2) +!27 = !DILocation(line: 4, column: 15, scope: !2) +!28 = !DILocation(line: 4, column: 13, scope: !2) +!29 = !DILocation(line: 4, column: 1, scope: !2) +!30 = distinct !DISubprogram(name: "f", scope: !3, file: !3, line: 6, type: !4, scopeLine: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !7, retainedNodes: !9) +!31 = !DILocalVariable(name: "n", arg: 1, scope: !30, file: !3, line: 6, type: !6) +!32 = !DILocation(line: 6, column: 11, scope: !30) +!33 = !DILocation(line: 6, column: 25, scope: !30) +!34 = !DILocation(line: 1, column: 42, scope: !2, inlinedAt: !35) +!35 = distinct !DILocation(line: 6, column: 23, scope: !30) +!36 = !DILocation(line: 3, column: 5, scope: !2, inlinedAt: !35) +!37 = !DILocation(line: 4, column: 10, scope: !2, inlinedAt: !35) +!38 = !DILocation(line: 4, column: 8, scope: !2, inlinedAt: !35) +!39 = !DILocation(line: 4, column: 15, scope: !2, inlinedAt: !35) +!40 = !DILocation(line: 4, column: 13, scope: !2, inlinedAt: !35) +!41 = !DILocation(line: 6, column: 16, scope: !30) \ No newline at end of file diff --git a/llvm/test/DebugInfo/X86/string-offsets-multiple-cus.ll b/llvm/test/DebugInfo/X86/string-offsets-multiple-cus.ll --- a/llvm/test/DebugInfo/X86/string-offsets-multiple-cus.ll +++ b/llvm/test/DebugInfo/X86/string-offsets-multiple-cus.ll @@ -42,21 +42,21 @@ ; TYPEUNITS-NOT: NULL ; TYPEUNITS: DW_TAG_enumerator ; TYPEUNITS-NOT: {{DW_TAG|NULL}} -; TYPEUNITS: DW_AT_name [DW_FORM_strx1] (indexed (00000005) string = "b") +; TYPEUNITS: DW_AT_name [DW_FORM_strx1] (indexed (00000004) string = "b") ; TYPEUNITS-NOT: contents: ; TYPEUNITS: DW_TAG_type_unit ; TYPEUNITS-NOT: {{DW_TAG|NULL}} ; TYPEUNITS: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x[[CU1_STROFF]]) ; TYPEUNITS-NOT: NULL ; TYPEUNITS: DW_TAG_enumeration_type -; TYPEUNITS: DW_AT_name [DW_FORM_strx1] (indexed (0000000d) string = "E2") +; TYPEUNITS: DW_AT_name [DW_FORM_strx1] (indexed (0000000b) string = "E2") ; TYPEUNITS-NOT: contents: ; TYPEUNITS: DW_TAG_type_unit ; TYPEUNITS-NOT: {{DW_TAG|NULL}} ; TYPEUNITS: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x[[CU1_STROFF]]) ; TYPEUNITS-NOT: NULL ; TYPEUNITS: DW_TAG_enumeration_type -; TYPEUNITS: DW_AT_name [DW_FORM_strx1] (indexed (00000013) string = "E3") +; TYPEUNITS: DW_AT_name [DW_FORM_strx1] (indexed (00000010) string = "E3") ; CU 1 ; BOTH-NOT: .contents: @@ -71,9 +71,10 @@ ; BOTH-NOT: {{DW_TAG|NULL}} ; BOTH: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x[[CU1_STROFF]]) ; BOTH-NOT: NULL +; BOTH: DW_TAG_enumeration_type ; BOTH: DW_TAG_variable ; BOTH-NOT: {{DW_TAG|NULL}} -; BOTH: DW_AT_name [DW_FORM_strx1] (indexed (00000009) string = "glob2") +; BOTH: DW_AT_name [DW_FORM_strx1] (indexed (00000012) string = "glob2") ; ; CU 3 ; BOTH-NOT: contents: @@ -81,9 +82,10 @@ ; BOTH-NOT: {{DW_TAG|NULL}} ; BOTH: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x[[CU1_STROFF]]) ; BOTH-NOT: NULL +; BOTH: DW_TAG_enumeration_type ; BOTH: DW_TAG_variable ; BOTH-NOT: {{DW_TAG|NULL}} -; BOTH: DW_AT_name [DW_FORM_strx1] (indexed (0000000f) string = "glob3") +; BOTH: DW_AT_name [DW_FORM_strx1] (indexed (00000013) string = "glob3") ; ; Extract the offset of a string to verify that it is referenced in the string ; offsets section. @@ -104,7 +106,16 @@ ; BOTH-NEXT: {{.*:}} ; BOTH-NEXT: {{.*:}} ; BOTH-NEXT: {{.*:}} -; The string with index 9 should be "glob2" +; BOTH-NEXT: {{.*:}} +; BOTH-NEXT: {{.*:}} +; BOTH-NEXT: {{.*:}} +; BOTH-NEXT: {{.*:}} +; BOTH-NEXT: {{.*:}} +; BOTH-NEXT: {{.*:}} +; BOTH-NEXT: {{.*:}} +; BOTH-NEXT: {{.*:}} +; BOTH-NEXT: {{.*:}} +; The string with index 0x12 should be "glob2" ; BOTH-NEXT: {{.*:}} [[GLOB2OFF]] ; ; ModuleID = 'test.bc' diff --git a/llvm/test/DebugInfo/X86/string-offsets-table.ll b/llvm/test/DebugInfo/X86/string-offsets-table.ll --- a/llvm/test/DebugInfo/X86/string-offsets-table.ll +++ b/llvm/test/DebugInfo/X86/string-offsets-table.ll @@ -72,11 +72,11 @@ ; SPLIT-NOT: contents: ; SPLIT: DW_TAG_enumerator ; SPLIT-NOT: {{DW_TAG|NULL}} -; SPLIT: DW_AT_name [DW_FORM_strx1] (indexed (00000001) string = "a") +; SPLIT: DW_AT_name [DW_FORM_strx1] (indexed ({{[0-9]+}}) string = "a") ; SPLIT-NOT: contents: ; SPLIT: DW_TAG_enumerator ; SPLIT-NOT: {{DW_TAG|NULL}} -; SPLIT: DW_AT_name [DW_FORM_strx1] (indexed (00000002) string = "b") +; SPLIT: DW_AT_name [DW_FORM_strx1] (indexed ({{[0-9]+}}) string = "b") ; ; Extract the string offsets referenced in the main file by the skeleton unit. ; SPLIT: .debug_str contents: diff --git a/llvm/test/DebugInfo/X86/subprogram-across-cus.ll b/llvm/test/DebugInfo/X86/subprogram-across-cus.ll --- a/llvm/test/DebugInfo/X86/subprogram-across-cus.ll +++ b/llvm/test/DebugInfo/X86/subprogram-across-cus.ll @@ -35,12 +35,12 @@ ; Check that there are no verifier failures, and that the SP for "main" appears ; in the correct CU. ; CHECK-LABEL: DW_TAG_compile_unit -; CHECK: DW_AT_name ("1.cpp") -; CHECK-NOT: DW_AT_name ("main") -; CHECK-LABEL: DW_TAG_compile_unit ; CHECK: DW_AT_name ("2.cpp") ; CHECK: DW_TAG_subprogram ; CHECK: DW_AT_name ("main") +; CHECK-LABEL: DW_TAG_compile_unit +; CHECK: DW_AT_name ("1.cpp") +; CHECK-NOT: DW_AT_name ("main") source_filename = "ld-temp.o" target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" diff --git a/llvm/test/DebugInfo/X86/template.ll b/llvm/test/DebugInfo/X86/template.ll --- a/llvm/test/DebugInfo/X86/template.ll +++ b/llvm/test/DebugInfo/X86/template.ll @@ -15,35 +15,17 @@ ; VERIFY-NOT: error: -; CHECK: [[INT:0x[0-9a-f]*]]:{{ *}}DW_TAG_base_type -; CHECK-NEXT: DW_AT_name{{.*}} = "int" - -; CHECK: DW_TAG_structure_type -; CHECK: DW_AT_name{{.*}}"y_impl" -; CHECK-NOT: {{TAG|NULL}} -; CHECK: DW_TAG_template_type_parameter - -; CHECK: DW_TAG_variable -; CHECK-NEXT: DW_AT_name{{.*}}"var" -; CHECK-NOT: NULL -; CHECK: DW_TAG_template_type_parameter -; CHECK-NEXT: DW_AT_type{{.*}}=> {[[INT]]} -; CHECK-NEXT: DW_AT_name{{.*}}= "T" - - ; CHECK: DW_AT_name{{.*}}"func<3, &glbl, y_impl, nullptr, E, 1, 2>" ; CHECK-NOT: NULL ; CHECK: DW_TAG_template_value_parameter -; CHECK-NEXT: DW_AT_type{{.*}}=> {[[INT]]} +; CHECK-NEXT: DW_AT_type{{.*}}=> {[[INT:0x[0-9a-f]*]]} ; CHECK-NEXT: DW_AT_name{{.*}}= "x" ; CHECK-NEXT: DW_AT_const_value [DW_FORM_sdata]{{.*}}(3) ; CHECK: DW_TAG_template_value_parameter ; CHECK-NEXT: DW_AT_type{{.*}}=> {[[INTPTR:0x[0-9a-f]*]]} - ; The address of the global 'glbl', followed by DW_OP_stack_value (9f), to use ; the value immediately, rather than indirecting through the address. - ; CHECK-NEXT: DW_AT_location [DW_FORM_exprloc]{{ *}}(DW_OP_addr 0x0, DW_OP_stack_value) ; CHECK-NOT: NULL @@ -71,6 +53,21 @@ ; CHECK-NEXT: DW_AT_type{{.*}}=> {[[INT]]} ; CHECK-NEXT: DW_AT_const_value [DW_FORM_sdata]{{.*}}(2) +; CHECK: [[INT]]:{{ *}}DW_TAG_base_type +; CHECK-NEXT: DW_AT_name{{.*}} = "int" + +; CHECK: DW_TAG_structure_type +; CHECK: DW_AT_name{{.*}}"y_impl" +; CHECK-NOT: {{TAG|NULL}} +; CHECK: DW_TAG_template_type_parameter + +; CHECK: DW_TAG_variable +; CHECK-NEXT: DW_AT_name{{.*}}"var" +; CHECK-NOT: NULL +; CHECK: DW_TAG_template_type_parameter +; CHECK-NEXT: DW_AT_type{{.*}}=> {[[INT]]} +; CHECK-NEXT: DW_AT_name{{.*}}= "T" + ; CHECK: [[INTPTR]]:{{ *}}DW_TAG_pointer_type ; CHECK-NEXT: DW_AT_type{{.*}} => {[[INT]]} diff --git a/llvm/test/DebugInfo/X86/tls.ll b/llvm/test/DebugInfo/X86/tls.ll --- a/llvm/test/DebugInfo/X86/tls.ll +++ b/llvm/test/DebugInfo/X86/tls.ll @@ -30,15 +30,31 @@ ; that here instead of raw assembly printing ; FISSION: .section .debug_info.dwo, +; SINGLE: .section .debug_info, +; DARWIN: .section {{.*}}debug_info, + +; FISSION: DW_TAG_subprogram +; SINGLE: DW_TAG_subprogram +; DARWIN: DW_TAG_subprogram + +; FISSION: DW_TAG_template_value_parameter +; FISSION: .byte 3 # DW_AT_location +; DW_OP_GNU_addr_index +; FISSION-NEXT: .byte 251 +; FISSION-NEXT: .byte 2 +; DW_OP_stack_value +; FISSION-NEXT: .byte 159 + +; FISSION: DW_TAG_variable +; SINGLE: DW_TAG_variable +; DARWIN: DW_TAG_variable + ; 3 bytes of data in this DW_FORM_exprloc representation of the location of 'tls' ; FISSION: .byte 3{{ *}}# DW_AT_location ; DW_OP_GNU_const_index (0xfx == 252) to refer to the debug_addr table ; FISSION-NEXT: .byte 252 -; an index of zero into the debug_addr table -; FISSION-NEXT: .byte 0 - -; SINGLE: .section .debug_info, -; DARWIN: .section {{.*}}debug_info, +; an index of one into the debug_addr table +; FISSION-NEXT: .byte 1 ; 10 bytes of data in this DW_FORM_exprloc representation of the location of 'tls' ; SINGLE-64: .byte 10 # DW_AT_location @@ -66,22 +82,15 @@ ; FISSION: .byte 2 # DW_AT_location ; DW_OP_GNU_addr_index ; FISSION-NEXT: .byte 251 -; FISSION-NEXT: .byte 1 - -; FISSION: DW_TAG_template_value_parameter -; FISSION: .byte 3 # DW_AT_location -; DW_OP_GNU_addr_index -; FISSION-NEXT: .byte 251 -; FISSION-NEXT: .byte 1 -; DW_OP_stack_value -; FISSION-NEXT: .byte 159 +; FISSION-NEXT: .byte 2 -; check that the expected TLS address description is the first thing in the debug_addr section +; check that the expected TLS address description is the second thing in the debug_addr section ; FISSION: .section .debug_addr ; FISSION-NEXT: .Laddr_table_base0: -; FISSION-NEXT: .quad tls@DTPOFF -; FISSION-NEXT: .quad glbl -; FISSION-NOT: .quad glbl +; FISSION-NEXT: .quad .Lfunc_begin0 +; FISSION-NEXT: .quad tls@DTPOFF +; FISSION-NEXT: .quad glbl +; FISSION-NOT: .quad glbl ; Generated from: diff --git a/llvm/test/DebugInfo/X86/tu-to-non-tu.ll b/llvm/test/DebugInfo/X86/tu-to-non-tu.ll --- a/llvm/test/DebugInfo/X86/tu-to-non-tu.ll +++ b/llvm/test/DebugInfo/X86/tu-to-non-tu.ll @@ -78,23 +78,40 @@ ; ref_templ_non_tu_mangled v4; - - ; CHECK-LABEL: Type Unit: + ; CHECK: DW_TAG_class_type ; CHECK-NOT: DW_TAG ; CHECK: DW_AT_name {{.*}}"ref_from_ref_internal_template" - ; CHECK-LABEL: Compile Unit: ; CHECK: DW_TAG_structure_type ; CHECK-NOT: DW_TAG -; CHECK: DW_AT_name {{.*}}"tu_ref_non_tu" +; CHECK: DW_AT_name {{.*}}"non_tu" +; CHECK: NULL ; CHECK: DW_TAG_structure_type ; CHECK-NOT: DW_TAG -; CHECK: DW_AT_name {{.*}}"non_tu" +; CHECK: DW_AT_name {{.*}}"_STN|templ_non_tu|" + +; CHECK: DW_TAG_structure_type +; CHECK-NOT: DW_TAG +; CHECK: DW_AT_name ("templ_non_tu") +; CHECK-NOT: DW_TAG +; CHECK: DW_TAG_template_type_parameter +; CHECK-NEXT: DW_AT_type {{.*}}"long" + +; CHECK: DW_TAG_structure_type +; CHECK-NOT: DW_TAG +; CHECK: DW_AT_name ("_STN|templ_non_tu|") +; CHECK-NOT: DW_TAG +; CHECK: DW_TAG_template_type_parameter +; CHECK-NEXT: DW_AT_type {{.*}}"bool" + +; CHECK: DW_TAG_structure_type +; CHECK-NOT: DW_TAG +; CHECK: DW_AT_name {{.*}}"tu_ref_non_tu" ; CHECK: DW_TAG_structure_type ; CHECK-NOT: DW_TAG @@ -115,29 +132,15 @@ ; CHECK: DW_TAG_structure_type ; CHECK-NOT: DW_TAG ; CHECK: DW_AT_name {{.*}}"ref_templ_non_tu" -; CHECK: DW_TAG_structure_type -; CHECK-NOT: DW_TAG -; CHECK: DW_AT_name {{.*}}"_STN|templ_non_tu|" ; CHECK: DW_TAG_structure_type ; CHECK-NOT: DW_TAG ; CHECK: DW_AT_name {{.*}}"ref_templ_non_tu_simple" -; CHECK: DW_TAG_structure_type -; CHECK-NOT: DW_TAG -; CHECK: DW_AT_name ("templ_non_tu") -; CHECK-NOT: DW_TAG -; CHECK: DW_TAG_template_type_parameter -; CHECK-NEXT: DW_AT_type {{.*}}"long" ; CHECK: DW_TAG_structure_type ; CHECK-NOT: DW_TAG ; CHECK: DW_AT_name {{.*}}"ref_templ_non_tu_mangled" -; CHECK: DW_TAG_structure_type -; CHECK-NOT: DW_TAG -; CHECK: DW_AT_name ("_STN|templ_non_tu|") -; CHECK-NOT: DW_TAG -; CHECK: DW_TAG_template_type_parameter -; CHECK-NEXT: DW_AT_type {{.*}}"bool" + ; CHECK: DW_TAG_class_type ; CHECK-NOT: DW_TAG ; CHECK: DW_AT_name {{.*}}"ref_internal_template" diff --git a/llvm/test/DebugInfo/X86/vla-global.ll b/llvm/test/DebugInfo/X86/vla-global.ll --- a/llvm/test/DebugInfo/X86/vla-global.ll +++ b/llvm/test/DebugInfo/X86/vla-global.ll @@ -1,4 +1,6 @@ ; RUN: llc -mtriple=x86_64-apple-darwin %s -o - -filetype=obj | llvm-dwarfdump - | FileCheck %s +; CHECK: NULL +; CHECK-EMPTY: ; CHECK: 0x00000[[G:.*]]: DW_TAG_variable ; CHECK-NEXT: DW_AT_name ("g") ; CHECK: DW_TAG_array_type diff --git a/llvm/test/DebugInfo/attr-btf_tag.ll b/llvm/test/DebugInfo/attr-btf_tag.ll --- a/llvm/test/DebugInfo/attr-btf_tag.ll +++ b/llvm/test/DebugInfo/attr-btf_tag.ll @@ -42,21 +42,6 @@ !llvm.module.flags = !{!10, !11, !12, !13, !14} !llvm.ident = !{!15} -!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) -!1 = distinct !DIGlobalVariable(name: "g1", scope: !2, file: !3, line: 8, type: !6, isLocal: false, isDefinition: true, annotations: !7) - -; CHECK: DW_TAG_variable -; CHECK-NEXT: DW_AT_name ("g1") -; CHECK: DW_TAG_LLVM_annotation -; CHECK-NEXT: DW_AT_name ("btf_decl_tag") -; CHECK-NEXT: DW_AT_const_value ("tag1") -; CHECK-EMPTY: -; CHECK-NEXT: DW_TAG_LLVM_annotation -; CHECK-NEXT: DW_AT_name ("btf_decl_tag") -; CHECK-NEXT: DW_AT_const_value ("tag2") -; CHECK-EMPTY: -; CHECK-NEXT: NULL - !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 13.0.0 (https://github.com/llvm/llvm-project.git 305231a4f71b68945b4dd92925c76ff49e377c86)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, splitDebugInlining: false, nameTableKind: None) !3 = !DIFile(filename: "t.c", directory: "/tmp/home/yhs/work/tests/llvm/btf_tag") !4 = !{} @@ -96,6 +81,20 @@ ; CHECK-EMPTY: ; CHECK-NEXT: NULL +!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) +!1 = distinct !DIGlobalVariable(name: "g1", scope: !2, file: !3, line: 8, type: !6, isLocal: false, isDefinition: true, annotations: !7) +; CHECK: DW_TAG_variable +; CHECK-NEXT: DW_AT_name ("g1") +; CHECK: DW_TAG_LLVM_annotation +; CHECK-NEXT: DW_AT_name ("btf_decl_tag") +; CHECK-NEXT: DW_AT_const_value ("tag1") +; CHECK-EMPTY: +; CHECK-NEXT: DW_TAG_LLVM_annotation +; CHECK-NEXT: DW_AT_name ("btf_decl_tag") +; CHECK-NEXT: DW_AT_const_value ("tag2") +; CHECK-EMPTY: +; CHECK-NEXT: NULL + !17 = !DISubroutineType(types: !18) !18 = !{!6, !19} !19 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !20, size: 64)