140 lines · plain
1; REQUIRES: bpf-registered-target2 3;; Verify that llvm-objdump can use .BTF.ext to extract line number4;; information in disassembly when DWARF is not available.5 6;; The 'sed' part is needed because llc would look for source file in7;; order to embed line info when BPF is compiled.8 9; RUN: sed -e "s,SRC_COMPDIR,%/p/Inputs,g" %s > %t.ll10 11;; First, check bpfel (little endian):12;; - compile %t.o13;; - check llvm-objdump output when both DWARF and BTF are present14;; - strip debug info from %t.o15;; - make sure that there are BTF but no DWARF sections in %t.o16;; - check llvm-objdump output when only BTF is present17 18; RUN: llc --mtriple bpfel -mcpu=v1 %t.ll --filetype=obj -o %t19; RUN: llvm-objdump --no-show-raw-insn -S %t | FileCheck %s20; RUN: llvm-strip --strip-debug %t21; RUN: llvm-objdump --section-headers %t \22; RUN: | FileCheck --implicit-check-not=.debug_ --check-prefix=SECTIONS %s23; RUN: llvm-objdump --no-show-raw-insn -S %t | FileCheck %s24 25;; Next, check bpfeb (big endian):26 27; RUN: llc --mtriple bpfeb -mcpu=v1 %t.ll --filetype=obj -o %t28; RUN: llvm-strip --strip-debug %t29; RUN: llvm-objdump --no-show-raw-insn -S %t | FileCheck %s30 31;; Test case adapted from output of the following command:32;;33;; clang -g --target=bpf -emit-llvm -S ./Inputs/test.c34;;35;; DIFile::directory is changed to SRC_COMPDIR.36 37; SECTIONS: .BTF38; SECTIONS: .BTF.ext39 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 = 0x147; CHECK-NEXT: 1: call -0x148; CHECK-NEXT: ; consume(2);49; CHECK-NEXT: 2: r1 = 0x250; CHECK-NEXT: 3: call -0x151; CHECK-NEXT: ; }52; CHECK-NEXT: 4: exit53; CHECK-EMPTY:54; CHECK-NEXT: [[#%x,]] <bar>:55; CHECK-NEXT: ; consume(3);56; CHECK-NEXT: 5: r1 = 0x357; CHECK-NEXT: 6: call -0x158; CHECK-NEXT: ; }59; CHECK-NEXT: 7: exit60; 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 = 0x466; CHECK-NEXT: 1: call -0x167; CHECK-NEXT: ; }68; CHECK-NEXT: 2: exit69; 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 = 0x575; CHECK-NEXT: 1: call -0x176; CHECK-NEXT: ; }77; CHECK-NEXT: 2: exit78 79; Function Attrs: noinline nounwind optnone80define dso_local void @foo() #0 !dbg !7 {81entry:82 %call = call i32 @consume(i32 noundef 1), !dbg !1183 %call1 = call i32 @consume(i32 noundef 2), !dbg !1284 ret void, !dbg !1385}86 87declare dso_local i32 @consume(i32 noundef) #188 89; Function Attrs: noinline nounwind optnone90define dso_local void @bar() #0 !dbg !14 {91entry:92 %call = call i32 @consume(i32 noundef 3), !dbg !1593 ret void, !dbg !1694}95 96; Function Attrs: noinline nounwind optnone97define dso_local void @buz() #0 section "a" !dbg !17 {98entry:99 %call = call i32 @consume(i32 noundef 4), !dbg !18100 ret void, !dbg !19101}102 103; Function Attrs: noinline nounwind optnone104define dso_local void @quux() #0 section "b" !dbg !20 {105entry:106 %call = call i32 @consume(i32 noundef 5), !dbg !21107 ret void, !dbg !22108}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