1 ; REQUIRES: bpf-registered-target
3 ;; Verify that llvm-objdump can use .BTF.ext to show CO-RE relocation data.
5 ; RUN: llc --mtriple bpfel %s --filetype=obj -o - | \
6 ; RUN: llvm-objdump --no-addresses --no-show-raw-insn -dr - | \
9 ; RUN: llc --mtriple bpfeb %s --filetype=obj -o - | \
10 ; RUN: llvm-objdump --no-addresses --no-show-raw-insn -dr - | \
13 ;; Input generated from the following C code:
15 ;; #define __pai __attribute__((preserve_access_index))
17 ;; struct bar { int a; } __pai;
18 ;; volatile unsigned long g;
20 ;; struct bar *bar = (void *)0;
21 ;; g = __builtin_preserve_field_info(bar->a, 1);
22 ;; g = __builtin_preserve_field_info(bar->a, 2);
23 ;; g = __builtin_preserve_field_info(bar->a, 3);
24 ;; g = __builtin_preserve_field_info(bar->a, 4);
25 ;; g = __builtin_preserve_field_info(bar->a, 5);
28 ;; Using the following command:
30 ;; clang --target=bpf -g -O2 -emit-llvm -S t.c
32 ; CHECK: CO-RE <byte_sz> [[[#]]] struct bar::a
33 ; CHECK: CO-RE <field_exists> [[[#]]] struct bar::a
34 ; CHECK: CO-RE <signed> [[[#]]] struct bar::a
35 ; CHECK: CO-RE <lshift_u64> [[[#]]] struct bar::a
36 ; CHECK: CO-RE <rshift_u64> [[[#]]] struct bar::a
38 @g = dso_local global i64 0, align 8, !dbg !0
39 @"llvm.bar:1:4$0:0" = external global i32, !llvm.preserve.access.index !7 #0
40 @"llvm.bar:2:1$0:0" = external global i32, !llvm.preserve.access.index !7 #0
41 @"llvm.bar:3:1$0:0" = external global i32, !llvm.preserve.access.index !7 #0
42 @"llvm.bar:4:32$0:0" = external global i32, !llvm.preserve.access.index !7 #0
43 @"llvm.bar:5:32$0:0" = external global i32, !llvm.preserve.access.index !7 #0
45 ; Function Attrs: nofree nounwind memory(readwrite, argmem: none)
46 define dso_local void @root() local_unnamed_addr #1 !dbg !16 {
48 call void @llvm.dbg.value(metadata ptr null, metadata !20, metadata !DIExpression()), !dbg !22
49 %0 = load i32, ptr @"llvm.bar:1:4$0:0", align 4
50 %1 = tail call i32 @llvm.bpf.passthrough.i32.i32(i32 0, i32 %0)
51 %conv = zext i32 %1 to i64, !dbg !23
52 store volatile i64 %conv, ptr @g, align 8, !dbg !24, !tbaa !25
53 %2 = load i32, ptr @"llvm.bar:2:1$0:0", align 4
54 %3 = tail call i32 @llvm.bpf.passthrough.i32.i32(i32 1, i32 %2)
55 %conv1 = zext i32 %3 to i64, !dbg !29
56 store volatile i64 %conv1, ptr @g, align 8, !dbg !30, !tbaa !25
57 %4 = load i32, ptr @"llvm.bar:3:1$0:0", align 4
58 %5 = tail call i32 @llvm.bpf.passthrough.i32.i32(i32 2, i32 %4)
59 %conv2 = zext i32 %5 to i64, !dbg !31
60 store volatile i64 %conv2, ptr @g, align 8, !dbg !32, !tbaa !25
61 %6 = load i32, ptr @"llvm.bar:4:32$0:0", align 4
62 %7 = tail call i32 @llvm.bpf.passthrough.i32.i32(i32 3, i32 %6)
63 %conv3 = zext i32 %7 to i64, !dbg !33
64 store volatile i64 %conv3, ptr @g, align 8, !dbg !34, !tbaa !25
65 %8 = load i32, ptr @"llvm.bar:5:32$0:0", align 4
66 %9 = tail call i32 @llvm.bpf.passthrough.i32.i32(i32 4, i32 %8)
67 %conv4 = zext i32 %9 to i64, !dbg !35
68 store volatile i64 %conv4, ptr @g, align 8, !dbg !36, !tbaa !25
72 ; Function Attrs: nofree nosync nounwind memory(none)
73 declare i32 @llvm.bpf.passthrough.i32.i32(i32, i32) #2
75 ; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
76 declare void @llvm.dbg.value(metadata, metadata, metadata) #3
78 attributes #0 = { "btf_ama" }
79 attributes #1 = { nofree nounwind memory(readwrite, argmem: none) "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
80 attributes #2 = { nofree nosync nounwind memory(none) }
81 attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
84 !llvm.module.flags = !{!11, !12, !13, !14}
87 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
88 !1 = distinct !DIGlobalVariable(name: "g", scope: !2, file: !3, line: 4, type: !5, isLocal: false, isDefinition: true)
89 !2 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, producer: "clang version 17.0.0 (/home/eddy/work/llvm-project/clang 2f8c5c0afd1d79a771dd74c8fb1e5bbae6d04eb7)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, globals: !4, splitDebugInlining: false, nameTableKind: None)
90 !3 = !DIFile(filename: "t.c", directory: "/home/eddy/work/tmp", checksumkind: CSK_MD5, checksum: "ff78616039301f51cd56ee6ea1377b86")
92 !5 = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: !6)
93 !6 = !DIBasicType(name: "unsigned long", size: 64, encoding: DW_ATE_unsigned)
94 !7 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "bar", file: !3, line: 3, size: 32, elements: !8)
96 !9 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !7, file: !3, line: 3, baseType: !10, size: 32)
97 !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
98 !11 = !{i32 7, !"Dwarf Version", i32 5}
99 !12 = !{i32 2, !"Debug Info Version", i32 3}
100 !13 = !{i32 1, !"wchar_size", i32 4}
101 !14 = !{i32 7, !"frame-pointer", i32 2}
102 !15 = !{!"clang version 17.0.0 (/home/eddy/work/llvm-project/clang 2f8c5c0afd1d79a771dd74c8fb1e5bbae6d04eb7)"}
103 !16 = distinct !DISubprogram(name: "root", scope: !3, file: !3, line: 5, type: !17, scopeLine: 5, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !19)
104 !17 = !DISubroutineType(types: !18)
107 !20 = !DILocalVariable(name: "bar", scope: !16, file: !3, line: 6, type: !21)
108 !21 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64)
109 !22 = !DILocation(line: 0, scope: !16)
110 !23 = !DILocation(line: 7, column: 7, scope: !16)
111 !24 = !DILocation(line: 7, column: 5, scope: !16)
112 !25 = !{!26, !26, i64 0}
113 !26 = !{!"long", !27, i64 0}
114 !27 = !{!"omnipotent char", !28, i64 0}
115 !28 = !{!"Simple C/C++ TBAA"}
116 !29 = !DILocation(line: 8, column: 7, scope: !16)
117 !30 = !DILocation(line: 8, column: 5, scope: !16)
118 !31 = !DILocation(line: 9, column: 7, scope: !16)
119 !32 = !DILocation(line: 9, column: 5, scope: !16)
120 !33 = !DILocation(line: 10, column: 7, scope: !16)
121 !34 = !DILocation(line: 10, column: 5, scope: !16)
122 !35 = !DILocation(line: 11, column: 7, scope: !16)
123 !36 = !DILocation(line: 11, column: 5, scope: !16)
124 !37 = !DILocation(line: 12, column: 1, scope: !16)