1; RUN: llc -march=bpfel -filetype=asm -o - %s | FileCheck -check-prefixes=CHECK %s
2; RUN: llc -march=bpfeb -filetype=asm -o - %s | FileCheck -check-prefixes=CHECK %s
3
4; Source code:
5;   void (*a1)(int p1);
6;   struct t1 { void (*a1)(int p1); } b1;
7;   void f1(int p2) { }
8; Compilation flag:
9;   clang -target bpf -O2 -g -S -emit-llvm t.c
10
11%struct.t1 = type { void (i32)* }
12
13@a1 = common dso_local local_unnamed_addr global void (i32)* null, align 8, !dbg !0
14@b1 = common dso_local local_unnamed_addr global %struct.t1 zeroinitializer, align 8, !dbg !6
15
16; Function Attrs: nounwind readnone
17define dso_local void @f1(i32 %p2) local_unnamed_addr #0 !dbg !19 {
18entry:
19  call void @llvm.dbg.value(metadata i32 %p2, metadata !21, metadata !DIExpression()), !dbg !22
20  ret void, !dbg !23
21}
22
23; CHECK:             .section        .BTF,"",@progbits
24; CHECK-NEXT:        .short  60319                   # 0xeb9f
25; CHECK-NEXT:        .byte   1
26; CHECK-NEXT:        .byte   0
27; CHECK-NEXT:        .long   24
28; CHECK-NEXT:        .long   0
29; CHECK-NEXT:        .long   104
30; CHECK-NEXT:        .long   104
31; CHECK-NEXT:        .long   32
32; CHECK-NEXT:        .long   1                       # BTF_KIND_INT(id = 1)
33; CHECK-NEXT:        .long   16777216                # 0x1000000
34; CHECK-NEXT:        .long   4
35; CHECK-NEXT:        .long   16777248                # 0x1000020
36; CHECK-NEXT:        .long   0                       # BTF_KIND_FUNC_PROTO(id = 2)
37; CHECK-NEXT:        .long   218103809               # 0xd000001
38; CHECK-NEXT:        .long   0
39; CHECK-NEXT:        .long   5
40; CHECK-NEXT:        .long   1
41; CHECK-NEXT:        .long   8                       # BTF_KIND_FUNC(id = 3)
42; CHECK-NEXT:        .long   201326593               # 0xc000001
43; CHECK-NEXT:        .long   2
44; CHECK-NEXT:        .long   0                       # BTF_KIND_PTR(id = 4)
45; CHECK-NEXT:        .long   33554432                # 0x2000000
46; CHECK-NEXT:        .long   5
47; CHECK-NEXT:        .long   0                       # BTF_KIND_FUNC_PROTO(id = 5)
48; CHECK-NEXT:        .long   218103809               # 0xd000001
49; CHECK-NEXT:        .long   0
50; CHECK-NEXT:        .long   0
51; CHECK-NEXT:        .long   1
52; CHECK-NEXT:        .long   26                      # BTF_KIND_STRUCT(id = 6)
53; CHECK-NEXT:        .long   67108865                # 0x4000001
54; CHECK-NEXT:        .long   8
55; CHECK-NEXT:        .long   29
56; CHECK-NEXT:        .long   4
57; CHECK-NEXT:        .long   0                       # 0x0
58; CHECK-NEXT:        .byte   0                       # string offset=0
59; CHECK-NEXT:        .ascii  "int"                   # string offset=1
60; CHECK-NEXT:        .byte   0
61; CHECK-NEXT:        .ascii  "p2"                    # string offset=5
62; CHECK-NEXT:        .byte   0
63; CHECK-NEXT:        .ascii  "f1"                    # string offset=8
64; CHECK-NEXT:        .byte   0
65; CHECK-NEXT:        .ascii  ".text"                 # string offset=11
66; CHECK-NEXT:        .byte   0
67; CHECK-NEXT:        .ascii  "/tmp/t.c"              # string offset=17
68; CHECK-NEXT:        .byte   0
69; CHECK-NEXT:        .ascii  "t1"                    # string offset=26
70; CHECK-NEXT:        .byte   0
71; CHECK-NEXT:        .ascii  "a1"                    # string offset=29
72; CHECK-NEXT:        .byte   0
73; CHECK-NEXT:        .section        .BTF.ext,"",@progbits
74; CHECK-NEXT:        .short  60319                   # 0xeb9f
75; CHECK-NEXT:        .byte   1
76; CHECK-NEXT:        .byte   0
77; CHECK-NEXT:        .long   32
78; CHECK-NEXT:        .long   0
79; CHECK-NEXT:        .long   20
80; CHECK-NEXT:        .long   20
81; CHECK-NEXT:        .long   28
82; CHECK-NEXT:        .long   48
83; CHECK-NEXT:        .long   0
84; CHECK-NEXT:        .long   8                       # FuncInfo
85; CHECK-NEXT:        .long   11                      # FuncInfo section string offset=11
86; CHECK-NEXT:        .long   1
87; CHECK-NEXT:        .long   .Lfunc_begin0
88; CHECK-NEXT:        .long   3
89; CHECK-NEXT:        .long   16                      # LineInfo
90; CHECK-NEXT:        .long   11                      # LineInfo section string offset=11
91; CHECK-NEXT:        .long   1
92; CHECK-NEXT:        .long   .Ltmp{{[0-9]+}}
93; CHECK-NEXT:        .long   17
94; CHECK-NEXT:        .long   0
95; CHECK-NEXT:        .long   3091                    # Line 3 Col 19
96
97; Function Attrs: nounwind readnone speculatable
98declare void @llvm.dbg.value(metadata, metadata, metadata) #1
99
100attributes #0 = { nounwind readnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "frame-pointer"="all" "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" }
101attributes #1 = { nounwind readnone speculatable }
102
103!llvm.dbg.cu = !{!2}
104!llvm.module.flags = !{!15, !16, !17}
105!llvm.ident = !{!18}
106
107!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
108!1 = distinct !DIGlobalVariable(name: "a1", scope: !2, file: !3, line: 1, type: !11, isLocal: false, isDefinition: true)
109!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 8.0.0 (trunk 345296) (llvm/trunk 345297)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, nameTableKind: None)
110!3 = !DIFile(filename: "t.c", directory: "/tmp")
111!4 = !{}
112!5 = !{!0, !6}
113!6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression())
114!7 = distinct !DIGlobalVariable(name: "b1", scope: !2, file: !3, line: 2, type: !8, isLocal: false, isDefinition: true)
115!8 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "t1", file: !3, line: 2, size: 64, elements: !9)
116!9 = !{!10}
117!10 = !DIDerivedType(tag: DW_TAG_member, name: "a1", scope: !8, file: !3, line: 2, baseType: !11, size: 64)
118!11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64)
119!12 = !DISubroutineType(types: !13)
120!13 = !{null, !14}
121!14 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
122!15 = !{i32 2, !"Dwarf Version", i32 4}
123!16 = !{i32 2, !"Debug Info Version", i32 3}
124!17 = !{i32 1, !"wchar_size", i32 4}
125!18 = !{!"clang version 8.0.0 (trunk 345296) (llvm/trunk 345297)"}
126!19 = distinct !DISubprogram(name: "f1", scope: !3, file: !3, line: 3, type: !12, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: true, unit: !2, retainedNodes: !20)
127!20 = !{!21}
128!21 = !DILocalVariable(name: "p2", arg: 1, scope: !19, file: !3, line: 3, type: !14)
129!22 = !DILocation(line: 3, column: 13, scope: !19)
130!23 = !DILocation(line: 3, column: 19, scope: !19)
131