244 lines · plain
1; RUN: llc -O0 %s -mtriple=msp430 -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=msp430 -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=msp430 -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; Ported from X86 test to cover 2-byte address size case17; Check that 16-bit addresses of MSP430 are properly stored18; in 32-bit DWARF fields19 20; Generated from the following source. f4 is used to put a hole in the CU21; ranges while keeping f2 and f4 in the same section (as opposed to22; -ffunction-sections, which would produce CU ranges, but each function would23; be in a different section, so unable to share addresses). The call to f1 at24; the start of f3 ensures the range for the inlined subroutine doesn't share25; the starting address with f3 (so it can be improved by using a rnglist to26; allow it to share an address it wouldn't already be sharing).27 28; Without f6 being in another section, technically we could use a non-zero CU29; low_pc that could act as a base address for all the addresses in the CU & avoid30; the need for these forced rnglists - we don't do that currently, but f6 ensures31; that this test will remain meaningful even if that improvement is made in the32; future. (implementing that would require detecting that all the addresses in33; the CU ranges are in the same section, then picking the lowest such address as34; the base address to make all other addresses relative to)35 36; IR from the following, compiled with:37; $ clang -g -c -gdwarf-5 -O138; __attribute__((optnone)) void f1() { }39; __attribute__((always_inline)) inline void f2() {40; f1();41; }42; void f3() {43; f1();44; f2();45; }46; __attribute__((nodebug)) void f4() {47; }48; void f5() {49; }50; __attribute__((section(".other"))) void f6() {51; }52 53; CHECK-LABEL: .debug_info contents:54; CHECK: DW_TAG_compile_unit55; CHECK: DW_AT_low_pc56; CHECK-SAME: (0x00000000)57; RNG: DW_AT_ranges58; RNG-SAME: (indexed (0x3) rangelist = [[CU_RANGE:.*]]59; EXPRORFORM: DW_AT_ranges60; EXPRORFORM-SAME: (indexed (0x0) rangelist = [[CU_RANGE:.*]]61; CHECK: DW_TAG_subprogram62; CHECK: DW_AT_low_pc63; CHECK-SAME: (indexed (00000000) address = 0x00000000 ".text")64; CHECK: DW_AT_high_pc65; CHECK-SAME: (0x00000002)66; CHECK: DW_AT_name67; CHECK-SAME: "f1"68; CHECK: DW_TAG_subprogram69; CHECK: DW_AT_name70; CHECK-SAME: "f2"71; CHECK: DW_TAG_subprogram72; EXPR: DW_AT_low_pc73; EXPR-SAME: (DW_OP_addrx 0x0, DW_OP_const4u 0x2, DW_OP_plus)74; FORM: DW_AT_low_pc75; FORM-SAME: [DW_FORM_LLVM_addrx_offset] (indexed (00000000) + 0x2 address = 0x00000002 ".text")76; EXPRORFORM: DW_AT_high_pc77; EXPRORFORM-SAME: (0x0000000a)78; RNG: DW_AT_ranges79; RNG-SAME: (indexed (0x0) rangelist = [[F3_RANGE:.*]]80; CHECK: DW_AT_name81; CHECK-SAME: "f3"82; CHECK: DW_TAG_inlined_subroutine83; EXPR: DW_AT_low_pc84; EXPR-SAME: [DW_FORM_exprloc] (DW_OP_addrx 0x0, DW_OP_const4u 0x6, DW_OP_plus)85; FORM: DW_AT_low_pc86; FORM-SAME: [DW_FORM_LLVM_addrx_offset] (indexed (00000000) + 0x6 address = 0x00000006 ".text")87; EXPRORFORM: DW_AT_high_pc88; EXPRORFORM-SAME: (0x00000004)89; RNG: DW_AT_ranges90; RNG-SAME: (indexed (0x1) rangelist = [[INL_RANGE:.*]]91; CHECK: DW_TAG_call_site92; RNG: DW_AT_call_return_pc93; RNG-SAME: (indexed (00000001) address = 0x00000006 ".text")94; EXPR: DW_AT_call_return_pc95; EXPR-SAME: [DW_FORM_exprloc] (DW_OP_addrx 0x0, DW_OP_const4u 0x6, DW_OP_plus)96; FORM: DW_AT_call_return_pc97; FORM-SAME: [DW_FORM_LLVM_addrx_offset] (indexed (00000000) + 0x6 address = 0x00000006 ".text")98; CHECK: DW_TAG_call_site99; RNG: DW_AT_call_return_pc100; RNG-SAME: (indexed (00000002) address = 0x0000000a ".text")101; EXPR: DW_AT_call_return_pc102; EXPR-SAME: [DW_FORM_exprloc] (DW_OP_addrx 0x0, DW_OP_const4u 0xa, DW_OP_plus)103; FORM: DW_AT_call_return_pc104; FORM-SAME: [DW_FORM_LLVM_addrx_offset] (indexed (00000000) + 0xa address = 0x0000000a ".text")105; CHECK: NULL106; CHECK: DW_TAG_subprogram107; EXPR: DW_AT_low_pc108; EXPR-SAME: [DW_FORM_exprloc] (DW_OP_addrx 0x0, DW_OP_const4u 0xe, DW_OP_plus)109; FORM: DW_AT_low_pc110; FORM-SAME: [DW_FORM_LLVM_addrx_offset] (indexed (00000000) + 0xe address = 0x0000000e ".text")111; EXPRORFORM: DW_AT_high_pc112; EXPRORFORM-SAME: (0x00000002)113; RNG: DW_AT_ranges114; RNG-SAME: (indexed (0x2) rangelist = [[F5_RANGE:.*]]115; CHECK: DW_AT_name116; CHECK-SAME: "f5"117; CHECK: DW_TAG_subprogram118; CHECK: DW_AT_low_pc [DW_FORM_addrx] (indexed (119; RNG-SAME: 00000003120; EXPRORFORM-SAME: 00000001121; CHECK: ) address = 0x00000000 ".other")122; CHECK: DW_AT_high_pc123; CHECK-SAME: (0x00000006)124; CHECK: DW_AT_name125; CHECK-SAME: "f6"126; CHECK: DW_TAG_inlined_subroutine127; RNG: DW_AT_low_pc128; RNG-SAME: (indexed (00000003) address = 0x00000000 ".other")129; EXPRORFORM: DW_AT_low_pc130; EXPRORFORM-SAME: (indexed (00000001) address = 0x00000000 ".other")131; CHECK: DW_AT_high_pc132; CHECK-SAME: (0x00000004)133; CHECK: DW_TAG_call_site134; CHECK: DW_AT_call_return_pc135; CHECK: NULL136; CHECK: NULL137 138; CHECK-LABEL: .debug_addr contents:139; CHECK: 0x00000000: Address table140; CHECK-NEXT: Addrs: [141; CHECK-NEXT: 0x00000000142; RNG-NEXT: 0x00000006143; RNG-NEXT: 0x0000000a144; CHECK-NEXT: 0x00000000145; RNG-NEXT: 0x00000004146; CHECK-NEXT: ]147 148; CHECK-LABEL: .debug_rnglists contents:149; RNG: 0x00000000: range list header: {{.*}}, offset_entry_count = 0x00000004150; EXPRORFORM: 0x00000000: range list header: {{.*}}, offset_entry_count = 0x00000001151; CHECK: ranges:152; RNG-NEXT: [[F3_RANGE]]: [DW_RLE_base_addressx]:153; RNG-SAME: 0x00000000154; RNG-NEXT: [DW_RLE_offset_pair ]155; RNG-NEXT: [DW_RLE_end_of_list ]156 157; RNG-NEXT: [[INL_RANGE]]: [DW_RLE_base_addressx]:158; RNG-SAME: 0x00000000159; RNG-NEXT: [DW_RLE_offset_pair ]160; RNG-NEXT: [DW_RLE_end_of_list ]161 162; RNG-NEXT: [[F5_RANGE]]: [DW_RLE_base_addressx]:163; RNG-SAME: 0x00000000164; RNG-NEXT: [DW_RLE_offset_pair ]165; RNG-NEXT: [DW_RLE_end_of_list ]166 167; CHECK-NEXT: [[CU_RANGE]]: [DW_RLE_base_addressx]:168; CHECK-SAME: 0x00000000169; CHECK-NEXT: [DW_RLE_offset_pair ]170; CHECK-NEXT: [DW_RLE_offset_pair ]171; RNG-NEXT: [DW_RLE_startx_length]:172; RNG-SAME: 0x00000003173; EXPRORFORM-NEXT: [DW_RLE_startx_length]:174; EXPRORFORM-SAME: 0x00000001175; CHECK-NEXT: [DW_RLE_end_of_list ]176 177; Function Attrs: mustprogress noinline nounwind optnone uwtable178define dso_local void @_Z2f1v() local_unnamed_addr #0 !dbg !7 {179entry:180 ret void, !dbg !12181}182 183; Function Attrs: mustprogress nounwind uwtable184define dso_local void @_Z2f3v() local_unnamed_addr #1 !dbg !13 {185entry:186 call void @_Z2f1v(), !dbg !14187 call void @_Z2f1v() #3, !dbg !15188 ret void, !dbg !18189}190 191; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone uwtable willreturn192define dso_local void @_Z2f4v() local_unnamed_addr #2 {193entry:194 ret void195}196 197; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone uwtable willreturn198define dso_local void @_Z2f5v() local_unnamed_addr #2 !dbg !19 {199entry:200 ret void, !dbg !20201}202 203; Function Attrs: mustprogress nounwind uwtable204define dso_local void @_Z2f6v() local_unnamed_addr #1 section ".other" !dbg !21 {205entry:206 call void @_Z2f1v() #3, !dbg !22207 ret void, !dbg !24208}209 210attributes #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" }211attributes #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" }212attributes #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" }213attributes #3 = { nounwind }214 215!llvm.dbg.cu = !{!0}216!llvm.module.flags = !{!2, !3, !4, !5}217!llvm.ident = !{!6}218 219!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)220!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")221!2 = !{i32 7, !"Dwarf Version", i32 5}222!3 = !{i32 2, !"Debug Info Version", i32 3}223!4 = !{i32 1, !"wchar_size", i32 4}224!5 = !{i32 7, !"uwtable", i32 1}225!6 = !{!"clang version 14.0.0 (git@github.com:llvm/llvm-project.git e2c3dc6fc76e767f08249f6d2c36e41660a4e331)"}226!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)227!8 = !DIFile(filename: "scratch/test.cpp", directory: "/usr/local/google/home/blaikie/dev", checksumkind: CSK_MD5, checksum: "e70db21a276125757057e729999c09c7")228!9 = !DISubroutineType(types: !10)229!10 = !{null}230!11 = !{}231!12 = !DILocation(line: 1, column: 38, scope: !7)232!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)233!14 = !DILocation(line: 6, column: 3, scope: !13)234!15 = !DILocation(line: 3, column: 3, scope: !16, inlinedAt: !17)235!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)236!17 = distinct !DILocation(line: 7, column: 3, scope: !13)237!18 = !DILocation(line: 8, column: 1, scope: !13)238!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)239!20 = !DILocation(line: 12, column: 1, scope: !19)240!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)241!22 = !DILocation(line: 3, column: 3, scope: !16, inlinedAt: !23)242!23 = distinct !DILocation(line: 14, column: 3, scope: !21)243!24 = !DILocation(line: 15, column: 1, scope: !21)244