Bump version to 19.1.0-rc3
[llvm-project.git] / llvm / test / CodeGen / BPF / BTF / extern-func-ptr.ll
blobaba36e94461ecef53c3ddb03dfb79bafedbdf121
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
4 ; Source code:
5 ;   extern int do_work(int) __attribute__((section(".callback_fn")));
6 ;   long bpf_helper(ptr callback_fn);
7 ;   long prog() {
8 ;       return bpf_helper(&do_work);
9 ;   }
10 ; Compilation flag:
11 ;   clang -target bpf -O2 -g -S -emit-llvm test.c
13 ; Function Attrs: nounwind
14 define dso_local i64 @prog() local_unnamed_addr #0 !dbg !7 {
15 entry:
16   %call = tail call i64 @bpf_helper(ptr @do_work) #2, !dbg !11
17   ret i64 %call, !dbg !12
20 ; CHECK:             .long   0                               # BTF_KIND_FUNC_PROTO(id = 4)
21 ; CHECK-NEXT:        .long   218103809                       # 0xd000001
22 ; CHECK-NEXT:        .long   5
23 ; CHECK-NEXT:        .long   0
24 ; CHECK-NEXT:        .long   5
25 ; CHECK-NEXT:        .long   51                              # BTF_KIND_INT(id = 5)
26 ; CHECK-NEXT:        .long   16777216                        # 0x1000000
27 ; CHECK-NEXT:        .long   4
28 ; CHECK-NEXT:        .long   16777248                        # 0x1000020
29 ; CHECK-NEXT:        .long   55                              # BTF_KIND_FUNC(id = 6)
30 ; CHECK-NEXT:        .long   201326594                       # 0xc000002
31 ; CHECK-NEXT:        .long   4
33 ; CHECK:             .long   74                              # BTF_KIND_DATASEC(id = 10)
34 ; CHECK-NEXT:        .long   251658241                       # 0xf000001
35 ; CHECK-NEXT:        .long   0
36 ; CHECK-NEXT:        .long   6
37 ; CHECK-NEXT:        .long   do_work
38 ; CHECK-NEXT:        .long   0
40 ; CHECK:             .ascii  "int"                           # string offset=51
41 ; CHECK:             .ascii  "do_work"                       # string offset=55
42 ; CHECK:             .ascii  ".callback_fn"                  # string offset=74
44 declare !dbg !13 dso_local i64 @bpf_helper(ptr) local_unnamed_addr #1
46 declare !dbg !17 dso_local i32 @do_work(i32) #1 section ".callback_fn"
48 attributes #0 = { nounwind "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
49 attributes #1 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
50 attributes #2 = { nounwind }
52 !llvm.dbg.cu = !{!0}
53 !llvm.module.flags = !{!3, !4, !5}
54 !llvm.ident = !{!6}
56 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 13.0.0 (https://github.com/llvm/llvm-project.git aa382ed8a38d5efa118e1b2617544f5c253658a9)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
57 !1 = !DIFile(filename: "test.c", directory: "/tmp/home/yhs/btf/core")
58 !2 = !{}
59 !3 = !{i32 7, !"Dwarf Version", i32 4}
60 !4 = !{i32 2, !"Debug Info Version", i32 3}
61 !5 = !{i32 1, !"wchar_size", i32 4}
62 !6 = !{!"clang version 13.0.0 (https://github.com/llvm/llvm-project.git aa382ed8a38d5efa118e1b2617544f5c253658a9)"}
63 !7 = distinct !DISubprogram(name: "prog", scope: !1, file: !1, line: 3, type: !8, scopeLine: 3, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)
64 !8 = !DISubroutineType(types: !9)
65 !9 = !{!10}
66 !10 = !DIBasicType(name: "long int", size: 64, encoding: DW_ATE_signed)
67 !11 = !DILocation(line: 4, column: 12, scope: !7)
68 !12 = !DILocation(line: 4, column: 5, scope: !7)
69 !13 = !DISubprogram(name: "bpf_helper", scope: !1, file: !1, line: 2, type: !14, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
70 !14 = !DISubroutineType(types: !15)
71 !15 = !{!10, !16}
72 !16 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64)
73 !17 = !DISubprogram(name: "do_work", scope: !1, file: !1, line: 1, type: !18, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
74 !18 = !DISubroutineType(types: !19)
75 !19 = !{!20, !20}
76 !20 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)