248 lines · plain
1; RUN: llc -O0 %s -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o - -minimize-addr-in-v5=Ranges \2; RUN: | llvm-dwarfdump -debug-info -debug-addr -debug-rnglists -v - \3; RUN: | FileCheck --check-prefix=CHECK --check-prefix=RNG \4; RUN: --implicit-check-not=DW_TAG --implicit-check-not=NULL --implicit-check-not=_pc %s5 6; RUN: llc -O0 %s -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o - -minimize-addr-in-v5=Expressions \7; RUN: | llvm-dwarfdump -debug-info -debug-addr -debug-rnglists -v - \8; RUN: | FileCheck --check-prefix=CHECK --check-prefix=EXPRORFORM --check-prefix=EXPR\9; RUN: --implicit-check-not=DW_TAG --implicit-check-not=NULL --implicit-check-not=_pc %s10 11; RUN: llc -O0 %s -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o - -minimize-addr-in-v5=Form \12; RUN: | llvm-dwarfdump -debug-info -debug-addr -debug-rnglists -v - \13; RUN: | FileCheck --check-prefix=CHECK --check-prefix=EXPRORFORM --check-prefix=FORM \14; RUN: --implicit-check-not=DW_TAG --implicit-check-not=NULL --implicit-check-not=_pc %s15 16 17; Generated from the following source. f4 is used to put a hole in the CU18; ranges while keeping f2 and f4 in the same section (as opposed to19; -ffunction-sections, which would produce CU ranges, but each function would20; be in a different section, so unable to share addresses). The call to f1 at21; the start of f3 ensures the range for the inlined subroutine doesn't share22; the starting address with f3 (so it can be improved by using a rnglist to23; allow it to share an address it wouldn't already be sharing).24 25; Without f6 being in another section, technically we could use a non-zero CU26; low_pc that could act as a base address for all the addresses in the CU & avoid27; the need for these forced rnglists - we don't do that currently, but f6 ensures28; that this test will remain meaningful even if that improvement is made in the29; future. (implementing that would require detecting that all the addresses in30; the CU ranges are in the same section, then picking the lowest such address as31; the base address to make all other addresses relative to)32 33; IR from the following, compiled with:34; $ clang -g -c -gdwarf-5 -O135; __attribute__((optnone)) void f1() { }36; __attribute__((always_inline)) inline void f2() {37; f1();38; }39; void f3() {40; f1();41; f2();42; }43; __attribute__((nodebug)) void f4() {44; }45; void f5() {46; }47; __attribute__((section(".other"))) void f6() {48; }49 50; CHECK-LABEL: .debug_info contents:51; CHECK: DW_TAG_compile_unit52; CHECK: DW_AT_low_pc53; CHECK-SAME: (0x0000000000000000)54; RNG: DW_AT_ranges55; RNG-SAME: (indexed (0x4) rangelist = [[CU_RANGE:.*]]56; EXPRORFORM: DW_AT_ranges57; EXPRORFORM-SAME: (indexed (0x0) rangelist = [[CU_RANGE:.*]]58; CHECK: DW_TAG_subprogram59; CHECK: DW_AT_low_pc60; CHECK-SAME: (indexed (00000000) address = 0x0000000000000000 ".text")61; CHECK: DW_AT_high_pc62; CHECK-SAME: (0x00000001)63; CHECK: DW_AT_name64; CHECK-SAME: "f1"65; CHECK: DW_TAG_subprogram66; CHECK: DW_AT_name67; CHECK-SAME: "f2"68; CHECK: DW_TAG_subprogram69; EXPR: DW_AT_low_pc 70; EXPR-SAME: (DW_OP_addrx 0x0, DW_OP_const4u 0x10, DW_OP_plus)71; FORM: DW_AT_low_pc72; FORM-SAME: [DW_FORM_LLVM_addrx_offset] (indexed (00000000) + 0x10 address = 0x0000000000000010 ".text")73; EXPRORFORM: DW_AT_high_pc74; EXPRORFORM-SAME: (0x0000000d)75; RNG: DW_AT_ranges76; RNG-SAME: (indexed (0x0) rangelist = [[F3_RANGE:.*]]77; CHECK: DW_AT_name78; CHECK-SAME: "f3"79; CHECK: DW_TAG_inlined_subroutine80; EXPR: DW_AT_low_pc81; EXPR-SAME: [DW_FORM_exprloc] (DW_OP_addrx 0x0, DW_OP_const4u 0x16, DW_OP_plus)82; FORM: DW_AT_low_pc83; FORM-SAME: [DW_FORM_LLVM_addrx_offset] (indexed (00000000) + 0x16 address = 0x0000000000000016 ".text")84; EXPRORFORM: DW_AT_high_pc85; EXPRORFORM-SAME: (0x00000005)86; RNG: DW_AT_ranges87; RNG-SAME: (indexed (0x1) rangelist = [[INL_RANGE:.*]]88; CHECK: DW_TAG_call_site89; RNG: DW_AT_call_return_pc90; RNG-SAME: (indexed (00000001) address = 0x0000000000000016 ".text")91; EXPR: DW_AT_call_return_pc92; EXPR-SAME: [DW_FORM_exprloc] (DW_OP_addrx 0x0, DW_OP_const4u 0x16, DW_OP_plus)93; FORM: DW_AT_call_return_pc94; FORM-SAME: [DW_FORM_LLVM_addrx_offset] (indexed (00000000) + 0x16 address = 0x0000000000000016 ".text")95; CHECK: DW_TAG_call_site96; RNG: DW_AT_call_return_pc 97; RNG-SAME: (indexed (00000002) address = 0x000000000000001b ".text")98; EXPR: DW_AT_call_return_pc99; EXPR-SAME: [DW_FORM_exprloc] (DW_OP_addrx 0x0, DW_OP_const4u 0x1b, DW_OP_plus)100; FORM: DW_AT_call_return_pc101; FORM-SAME: [DW_FORM_LLVM_addrx_offset] (indexed (00000000) + 0x1b address = 0x000000000000001b ".text")102; CHECK: NULL103; CHECK: DW_TAG_subprogram104; EXPR: DW_AT_low_pc105; EXPR-SAME: [DW_FORM_exprloc] (DW_OP_addrx 0x0, DW_OP_const4u 0x30, DW_OP_plus)106; FORM: DW_AT_low_pc107; FORM-SAME: [DW_FORM_LLVM_addrx_offset] (indexed (00000000) + 0x30 address = 0x0000000000000030 ".text")108; EXPRORFORM: DW_AT_high_pc109; EXPRORFORM-SAME: (0x00000001)110; RNG: DW_AT_ranges111; RNG-SAME: (indexed (0x2) rangelist = [[F5_RANGE:.*]]112; CHECK: DW_AT_name113; CHECK-SAME: "f5"114; CHECK: DW_TAG_subprogram115; CHECK: DW_AT_low_pc [DW_FORM_addrx] (indexed (116; RNG-SAME: 00000003117; EXPRORFORM-SAME: 00000001118; CHECK: ) address = 0x0000000000000000 ".other")119; CHECK: DW_AT_high_pc120; CHECK-SAME: (0x00000008)121; CHECK: DW_AT_name122; CHECK-SAME: "f6"123; CHECK: DW_TAG_inlined_subroutine124; RNG: DW_AT_ranges125; RNG-SAME: (indexed (0x3) rangelist = [[F6_INL_RANGE:.*]]126; EXPR: DW_AT_low_pc127; EXPR-SAME: [DW_FORM_exprloc] (DW_OP_addrx 0x1, DW_OP_const4u 0x1, DW_OP_plus)128; FORM: DW_AT_low_pc129; FORM-SAME: [DW_FORM_LLVM_addrx_offset] (indexed (00000001) + 0x1 address = 0x0000000000000001 ".other")130; EXPRORFORM: DW_AT_high_pc131; EXPRORFORM-SAME: (0x00000005)132; CHECK: DW_TAG_call_site133; CHECK: DW_AT_call_return_pc134; CHECK: NULL135; CHECK: NULL136 137; CHECK-LABEL: .debug_addr contents:138; CHECK: 0x00000000: Address table139; CHECK-NEXT: Addrs: [140; CHECK-NEXT: 0x0000000000000000141; RNG-NEXT: 0x0000000000000016142; RNG-NEXT: 0x000000000000001b143; CHECK-NEXT: 0x0000000000000000144; RNG-NEXT: 0x0000000000000006145; CHECK-NEXT: ]146 147; CHECK-LABEL: .debug_rnglists contents:148; RNG: 0x00000000: range list header: {{.*}}, offset_entry_count = 0x00000005149; EXPRORFORM: 0x00000000: range list header: {{.*}}, offset_entry_count = 0x00000001150; CHECK: ranges:151; RNG-NEXT: [[F3_RANGE]]: [DW_RLE_base_addressx]:152; RNG-SAME: 0x0000000000000000153; RNG-NEXT: [DW_RLE_offset_pair ]154; RNG-NEXT: [DW_RLE_end_of_list ]155 156; RNG-NEXT: [[INL_RANGE]]: [DW_RLE_base_addressx]:157; RNG-SAME: 0x0000000000000000158; RNG-NEXT: [DW_RLE_offset_pair ]159; RNG-NEXT: [DW_RLE_end_of_list ]160 161; RNG-NEXT: [[F5_RANGE]]: [DW_RLE_base_addressx]:162; RNG-SAME: 0x0000000000000000163; RNG-NEXT: [DW_RLE_offset_pair ]164; RNG-NEXT: [DW_RLE_end_of_list ]165 166; RNG-NEXT: [[F6_INL_RANGE]]: [DW_RLE_base_addressx]:167; RNG-SAME: 0x0000000000000003168; RNG-NEXT: [DW_RLE_offset_pair ]169; RNG-NEXT: [DW_RLE_end_of_list ]170 171; CHECK-NEXT: [[CU_RANGE]]: [DW_RLE_base_addressx]:172; CHECK-SAME: 0x0000000000000000173; CHECK-NEXT: [DW_RLE_offset_pair ]174; CHECK-NEXT: [DW_RLE_offset_pair ]175; RNG-NEXT: [DW_RLE_startx_length]:176; RNG-SAME: 0x0000000000000003177; EXPRORFORM-NEXT: [DW_RLE_startx_length]:178; EXPRORFORM-SAME: 0x0000000000000001179; CHECK-NEXT: [DW_RLE_end_of_list ]180 181; Function Attrs: mustprogress noinline nounwind optnone uwtable182define dso_local void @_Z2f1v() local_unnamed_addr #0 !dbg !7 {183entry:184 ret void, !dbg !12185}186 187; Function Attrs: mustprogress nounwind uwtable188define dso_local void @_Z2f3v() local_unnamed_addr #1 !dbg !13 {189entry:190 call void @_Z2f1v(), !dbg !14191 call void @_Z2f1v() #3, !dbg !15192 ret void, !dbg !18193}194 195; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone uwtable willreturn196define dso_local void @_Z2f4v() local_unnamed_addr #2 {197entry:198 ret void199}200 201; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone uwtable willreturn202define dso_local void @_Z2f5v() local_unnamed_addr #2 !dbg !19 {203entry:204 ret void, !dbg !20205}206 207; Function Attrs: mustprogress nounwind uwtable208define dso_local void @_Z2f6v() local_unnamed_addr #1 section ".other" !dbg !21 {209entry:210 call void @_Z2f1v() #3, !dbg !22211 ret void, !dbg !24212}213 214attributes #0 = { mustprogress noinline nounwind optnone uwtable "frame-pointer"="none" "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" }215attributes #1 = { mustprogress nounwind uwtable "frame-pointer"="none" "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" }216attributes #2 = { mustprogress nofree norecurse nosync nounwind readnone uwtable willreturn "frame-pointer"="none" "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" }217attributes #3 = { nounwind }218 219!llvm.dbg.cu = !{!0}220!llvm.module.flags = !{!2, !3, !4, !5}221!llvm.ident = !{!6}222 223!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 14.0.0 (git@github.com:llvm/llvm-project.git e2c3dc6fc76e767f08249f6d2c36e41660a4e331)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)224!1 = !DIFile(filename: "/usr/local/google/home/blaikie/dev/scratch/test.cpp", directory: "/usr/local/google/home/blaikie/dev/llvm/src", checksumkind: CSK_MD5, checksum: "e70db21a276125757057e729999c09c7")225!2 = !{i32 7, !"Dwarf Version", i32 5}226!3 = !{i32 2, !"Debug Info Version", i32 3}227!4 = !{i32 1, !"wchar_size", i32 4}228!5 = !{i32 7, !"uwtable", i32 1}229!6 = !{!"clang version 14.0.0 (git@github.com:llvm/llvm-project.git e2c3dc6fc76e767f08249f6d2c36e41660a4e331)"}230!7 = distinct !DISubprogram(name: "f1", linkageName: "_Z2f1v", scope: !8, file: !8, line: 1, type: !9, scopeLine: 1, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11)231!8 = !DIFile(filename: "scratch/test.cpp", directory: "/usr/local/google/home/blaikie/dev", checksumkind: CSK_MD5, checksum: "e70db21a276125757057e729999c09c7")232!9 = !DISubroutineType(types: !10)233!10 = !{null}234!11 = !{}235!12 = !DILocation(line: 1, column: 38, scope: !7)236!13 = distinct !DISubprogram(name: "f3", linkageName: "_Z2f3v", scope: !8, file: !8, line: 5, type: !9, scopeLine: 5, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11)237!14 = !DILocation(line: 6, column: 3, scope: !13)238!15 = !DILocation(line: 3, column: 3, scope: !16, inlinedAt: !17)239!16 = distinct !DISubprogram(name: "f2", linkageName: "_Z2f2v", scope: !8, file: !8, line: 2, type: !9, scopeLine: 2, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11)240!17 = distinct !DILocation(line: 7, column: 3, scope: !13)241!18 = !DILocation(line: 8, column: 1, scope: !13)242!19 = distinct !DISubprogram(name: "f5", linkageName: "_Z2f5v", scope: !8, file: !8, line: 11, type: !9, scopeLine: 11, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11)243!20 = !DILocation(line: 12, column: 1, scope: !19)244!21 = distinct !DISubprogram(name: "f6", linkageName: "_Z2f6v", scope: !8, file: !8, line: 13, type: !9, scopeLine: 13, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11)245!22 = !DILocation(line: 3, column: 3, scope: !16, inlinedAt: !23)246!23 = distinct !DILocation(line: 14, column: 3, scope: !21)247!24 = !DILocation(line: 15, column: 1, scope: !21)248