1; RUN: llc -march=bpfel -filetype=obj -o - %s | llvm-readelf -x ".BTF" -x ".BTF.ext" | FileCheck -check-prefixes=CHECK,CHECK-EL %s
2; RUN: llc -march=bpfeb -filetype=obj -o - %s | llvm-readelf -x ".BTF" -x ".BTF.ext" | FileCheck -check-prefixes=CHECK,CHECK-EB %s
3
4; Source code:
5;   int f(int a) { return a; }
6; Compilation flag:
7;   clang -target bpf -O2 -g -gdwarf-5 -gembed-source -S -emit-llvm t.c
8
9; Function Attrs: nounwind readnone
10define dso_local i32 @f(i32 returned %a) local_unnamed_addr #0 !dbg !7 {
11entry:
12  call void @llvm.dbg.value(metadata i32 %a, metadata !12, metadata !DIExpression()), !dbg !13
13  ret i32 %a, !dbg !14
14}
15
16; CHECK:    '.BTF'
17; CHECK-EL: 0x00000000 9feb0100 18000000 00000000 30000000
18; CHECK-EL: 0x00000010 30000000 33000000 01000000 00000001
19; CHECK-EL: 0x00000020 04000000 20000001 00000000 0100000d
20; CHECK-EL: 0x00000030 01000000 05000000 01000000 07000000
21; CHECK-EL: 0x00000040 0000000c 02000000 00696e74 00610066
22; CHECK-EB: 0x00000000 eb9f0100 00000018 00000000 00000030
23; CHECK-EB: 0x00000010 00000030 00000033 00000001 01000000
24; CHECK-EB: 0x00000020 00000004 01000020 00000000 0d000001
25; CHECK-EB: 0x00000030 00000001 00000005 00000001 00000007
26; CHECK-EB: 0x00000040 0c000000 00000002 00696e74 00610066
27; CHECK:    0x00000050 002e7465 7874002f 746d702f 742e6300
28; CHECK:    0x00000060 696e7420 6628696e 74206129 207b2072
29; CHECK:    0x00000070 65747572 6e20613b 207d00
30; CHECK:    '.BTF.ext'
31; CHECK-EL: 0x00000000 9feb0100 28000000 00000000 14000000
32; CHECK-EL: 0x00000010 14000000 2c000000 40000000 00000000
33; CHECK-EL: 0x00000020 40000000 00000000 08000000 09000000
34; CHECK-EL: 0x00000030 01000000 00000000 03000000 10000000
35; CHECK-EL: 0x00000040 09000000 02000000 00000000 0f000000
36; CHECK-EL: 0x00000050 18000000 00040000 08000000 0f000000
37; CHECK-EL: 0x00000060 18000000 10040000
38; CHECK-EB: 0x00000000 eb9f0100 00000028 00000000 00000014
39; CHECK-EB: 0x00000010 00000014 0000002c 00000040 00000000
40; CHECK-EB: 0x00000020 00000040 00000000 00000008 00000009
41; CHECK-EB: 0x00000030 00000001 00000000 00000003 00000010
42; CHECK-EB: 0x00000040 00000009 00000002 00000000 0000000f
43; CHECK-EB: 0x00000050 00000018 00000400 00000008 0000000f
44; CHECK-EB: 0x00000060 00000018 00000410
45
46; Function Attrs: nounwind readnone speculatable
47declare void @llvm.dbg.value(metadata, metadata, metadata) #1
48
49attributes #0 = { nounwind readnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
50attributes #1 = { nounwind readnone speculatable }
51
52!llvm.dbg.cu = !{!0}
53!llvm.module.flags = !{!3, !4, !5}
54!llvm.ident = !{!6}
55
56!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 8.0.0 (trunk 344789) (llvm/trunk 344782)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
57!1 = !DIFile(filename: "t.c", directory: "/tmp", checksumkind: CSK_MD5, checksum: "1924f0d78deb326ceb76cd8e9f450775", source: "int f(int a) { return a; }\0A")
58!2 = !{}
59!3 = !{i32 2, !"Dwarf Version", i32 5}
60!4 = !{i32 2, !"Debug Info Version", i32 3}
61!5 = !{i32 1, !"wchar_size", i32 4}
62!6 = !{!"clang version 8.0.0 (trunk 344789) (llvm/trunk 344782)"}
63!7 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 1, type: !8, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, isOptimized: true, unit: !0, retainedNodes: !11)
64!8 = !DISubroutineType(types: !9)
65!9 = !{!10, !10}
66!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
67!11 = !{!12}
68!12 = !DILocalVariable(name: "a", arg: 1, scope: !7, file: !1, line: 1, type: !10)
69!13 = !DILocation(line: 1, column: 11, scope: !7)
70!14 = !DILocation(line: 1, column: 16, scope: !7)
71