77 lines · plain
1; RUN: llc -mtriple=bpfel -filetype=asm -o - %s | FileCheck -check-prefixes=CHECK %s2; RUN: llc -mtriple=bpfeb -filetype=asm -o - %s | FileCheck -check-prefixes=CHECK %s3;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.c12 13; Function Attrs: nounwind14define dso_local i64 @prog() local_unnamed_addr #0 !dbg !7 {15entry:16 %call = tail call i64 @bpf_helper(ptr @do_work) #2, !dbg !1117 ret i64 %call, !dbg !1218}19 20; CHECK: .long 0 # BTF_KIND_FUNC_PROTO(id = 4)21; CHECK-NEXT: .long 218103809 # 0xd00000122; CHECK-NEXT: .long 523; CHECK-NEXT: .long 024; CHECK-NEXT: .long 525; CHECK-NEXT: .long 51 # BTF_KIND_INT(id = 5)26; CHECK-NEXT: .long 16777216 # 0x100000027; CHECK-NEXT: .long 428; CHECK-NEXT: .long 16777248 # 0x100002029; CHECK-NEXT: .long 55 # BTF_KIND_FUNC(id = 6)30; CHECK-NEXT: .long 201326594 # 0xc00000231; CHECK-NEXT: .long 432 33; CHECK: .long 74 # BTF_KIND_DATASEC(id = 10)34; CHECK-NEXT: .long 251658241 # 0xf00000135; CHECK-NEXT: .long 036; CHECK-NEXT: .long 637; CHECK-NEXT: .long do_work38; CHECK-NEXT: .long 039 40; CHECK: .ascii "int" # string offset=5141; CHECK: .ascii "do_work" # string offset=5542; CHECK: .ascii ".callback_fn" # string offset=7443 44declare !dbg !13 dso_local i64 @bpf_helper(ptr) local_unnamed_addr #145 46declare !dbg !17 dso_local i32 @do_work(i32) #1 section ".callback_fn"47 48attributes #0 = { nounwind "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }49attributes #1 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }50attributes #2 = { nounwind }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 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)77