1; REQUIRES: bpf-registered-target 2 3;; Verify that llvm-objdump can use .BTF.ext to extract line number 4;; information in disassembly when DWARF is not available. 5 6;; The 'sed' part is needed because llc would look for source file in 7;; order to embed line info when BPF is compiled. 8 9; RUN: sed -e "s,SRC_COMPDIR,%/p/Inputs,g" %s > %t.ll 10 11;; First, check bpfel (little endian): 12;; - compile %t.o 13;; - check llvm-objdump output when both DWARF and BTF are present 14;; - strip debug info from %t.o 15;; - make sure that there are BTF but no DWARF sections in %t.o 16;; - check llvm-objdump output when only BTF is present 17 18; RUN: llc --mtriple bpfel -mcpu=v1 %t.ll --filetype=obj -o %t 19; RUN: llvm-objdump --no-show-raw-insn -S %t | FileCheck %s 20; RUN: llvm-strip --strip-debug %t 21; RUN: llvm-objdump --section-headers %t \ 22; RUN: | FileCheck --implicit-check-not=.debug_ --check-prefix=SECTIONS %s 23; RUN: llvm-objdump --no-show-raw-insn -S %t | FileCheck %s 24 25;; Next, check bpfeb (big endian): 26 27; RUN: llc --mtriple bpfeb -mcpu=v1 %t.ll --filetype=obj -o %t 28; RUN: llvm-strip --strip-debug %t 29; RUN: llvm-objdump --no-show-raw-insn -S %t | FileCheck %s 30 31;; Test case adapted from output of the following command: 32;; 33;; clang -g --target=bpf -emit-llvm -S ./Inputs/test.c 34;; 35;; DIFile::directory is changed to SRC_COMPDIR. 36 37; SECTIONS: .BTF 38; SECTIONS: .BTF.ext 39 40;; Check inlined source code in disassembly: 41 42; CHECK: Disassembly of section .text: 43; CHECK-EMPTY: 44; CHECK-NEXT: [[#%x,]] <foo>: 45; CHECK-NEXT: ; consume(1); 46; CHECK-NEXT: 0: r1 = 0x1 47; CHECK-NEXT: 1: call -0x1 48; CHECK-NEXT: ; consume(2); 49; CHECK-NEXT: 2: r1 = 0x2 50; CHECK-NEXT: 3: call -0x1 51; CHECK-NEXT: ; } 52; CHECK-NEXT: 4: exit 53; CHECK-EMPTY: 54; CHECK-NEXT: [[#%x,]] <bar>: 55; CHECK-NEXT: ; consume(3); 56; CHECK-NEXT: 5: r1 = 0x3 57; CHECK-NEXT: 6: call -0x1 58; CHECK-NEXT: ; } 59; CHECK-NEXT: 7: exit 60; CHECK-EMPTY: 61; CHECK-NEXT: Disassembly of section a: 62; CHECK-EMPTY: 63; CHECK-NEXT: [[#%x,]] <buz>: 64; CHECK-NEXT: ; consume(4); 65; CHECK-NEXT: 0: r1 = 0x4 66; CHECK-NEXT: 1: call -0x1 67; CHECK-NEXT: ; } 68; CHECK-NEXT: 2: exit 69; CHECK-EMPTY: 70; CHECK-NEXT: Disassembly of section b: 71; CHECK-EMPTY: 72; CHECK-NEXT: [[#%x,]] <quux>: 73; CHECK-NEXT: ; consume(5); 74; CHECK-NEXT: 0: r1 = 0x5 75; CHECK-NEXT: 1: call -0x1 76; CHECK-NEXT: ; } 77; CHECK-NEXT: 2: exit 78 79; Function Attrs: noinline nounwind optnone 80define dso_local void @foo() #0 !dbg !7 { 81entry: 82 %call = call i32 @consume(i32 noundef 1), !dbg !11 83 %call1 = call i32 @consume(i32 noundef 2), !dbg !12 84 ret void, !dbg !13 85} 86 87declare dso_local i32 @consume(i32 noundef) #1 88 89; Function Attrs: noinline nounwind optnone 90define dso_local void @bar() #0 !dbg !14 { 91entry: 92 %call = call i32 @consume(i32 noundef 3), !dbg !15 93 ret void, !dbg !16 94} 95 96; Function Attrs: noinline nounwind optnone 97define dso_local void @buz() #0 section "a" !dbg !17 { 98entry: 99 %call = call i32 @consume(i32 noundef 4), !dbg !18 100 ret void, !dbg !19 101} 102 103; Function Attrs: noinline nounwind optnone 104define dso_local void @quux() #0 section "b" !dbg !20 { 105entry: 106 %call = call i32 @consume(i32 noundef 5), !dbg !21 107 ret void, !dbg !22 108} 109 110attributes #0 = { noinline nounwind optnone "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" } 111attributes #1 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" } 112 113!llvm.dbg.cu = !{!0} 114!llvm.module.flags = !{!2, !3, !4, !5} 115!llvm.ident = !{!6} 116 117!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang version 17.0.0 (/home/eddy/work/llvm-project/clang 81674c88f80fa7d9c55d4aee945f844b67f03267)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None) 118!1 = !DIFile(filename: "test.c", directory: "SRC_COMPDIR", checksumkind: CSK_MD5, checksum: "292d67837b080844462efb2a6b004f09") 119!2 = !{i32 7, !"Dwarf Version", i32 5} 120!3 = !{i32 2, !"Debug Info Version", i32 3} 121!4 = !{i32 1, !"wchar_size", i32 4} 122!5 = !{i32 7, !"frame-pointer", i32 2} 123!6 = !{!"clang version 17.0.0 (/home/eddy/work/llvm-project/clang 81674c88f80fa7d9c55d4aee945f844b67f03267)"} 124!7 = distinct !DISubprogram(name: "foo", scope: !8, file: !8, line: 3, type: !9, scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0) 125!8 = !DIFile(filename: "test.c", directory: "SRC_COMPDIR", checksumkind: CSK_MD5, checksum: "292d67837b080844462efb2a6b004f09") 126!9 = !DISubroutineType(types: !10) 127!10 = !{null} 128!11 = !DILocation(line: 4, column: 3, scope: !7) 129!12 = !DILocation(line: 5, column: 3, scope: !7) 130!13 = !DILocation(line: 6, column: 1, scope: !7) 131!14 = distinct !DISubprogram(name: "bar", scope: !8, file: !8, line: 8, type: !9, scopeLine: 8, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0) 132!15 = !DILocation(line: 9, column: 3, scope: !14) 133!16 = !DILocation(line: 10, column: 1, scope: !14) 134!17 = distinct !DISubprogram(name: "buz", scope: !8, file: !8, line: 13, type: !9, scopeLine: 13, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0) 135!18 = !DILocation(line: 14, column: 3, scope: !17) 136!19 = !DILocation(line: 15, column: 1, scope: !17) 137!20 = distinct !DISubprogram(name: "quux", scope: !8, file: !8, line: 18, type: !9, scopeLine: 18, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0) 138!21 = !DILocation(line: 19, column: 3, scope: !20) 139!22 = !DILocation(line: 20, column: 1, scope: !20) 140