xref: /llvm-project/llvm/test/CodeGen/BPF/CORE/field-reloc-alu32.ll (revision 60228733726e25d011b1f9221e005732191cc077)
1; RUN: opt -O2 %s | llvm-dis > %t1
2; RUN: llc -mattr=+alu32 -filetype=asm -o - %t1 | FileCheck -check-prefixes=CHECK %s
3; Source code:
4;   struct b { int d; int e; } c;
5;   int f() {
6;     return __builtin_preserve_field_info(c.e, 0);
7;   }
8; Compilation flag:
9;   clang -target bpf -O2 -g -S -emit-llvm -Xclang -disable-llvm-passes test.c
10
11target triple = "bpf"
12
13%struct.b = type { i32, i32 }
14
15@c = common dso_local global %struct.b zeroinitializer, align 4, !dbg !0
16
17; Function Attrs: nounwind readnone
18define dso_local i32 @f() local_unnamed_addr #0 !dbg !15 {
19entry:
20  %0 = tail call ptr @llvm.preserve.struct.access.index.p0.p0.bs(ptr elementtype(%struct.b) nonnull @c, i32 1, i32 1), !dbg !18, !llvm.preserve.access.index !6
21  %1 = tail call i32 @llvm.bpf.preserve.field.info.p0(ptr %0, i64 0), !dbg !19
22  ret i32 %1, !dbg !20
23}
24
25; CHECK:             r0 = 4
26; CHECK:             exit
27
28; CHECK:             .long   13                      # BTF_KIND_STRUCT(id = 4)
29
30; CHECK:             .ascii  ".text"                 # string offset=7
31; CHECK:             .byte   98                      # string offset=13
32; CHECK:             .ascii  "0:1"                   # string offset=19
33
34; CHECK:             .long   16                      # FieldReloc
35; CHECK-NEXT:        .long   7                       # Field reloc section string offset=7
36; CHECK-NEXT:        .long   1
37; CHECK-NEXT:        .long   .Ltmp{{[0-9]+}}
38; CHECK-NEXT:        .long   4
39; CHECK-NEXT:        .long   19
40; CHECK-NEXT:        .long   0
41
42; Function Attrs: nounwind readnone
43declare ptr @llvm.preserve.struct.access.index.p0.p0.bs(ptr, i32, i32) #1
44
45; Function Attrs: nounwind readnone
46declare i32 @llvm.bpf.preserve.field.info.p0(ptr, i64) #1
47
48attributes #0 = { nounwind readnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "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" }
49attributes #1 = { nounwind readnone }
50
51!llvm.dbg.cu = !{!2}
52!llvm.module.flags = !{!11, !12, !13}
53!llvm.ident = !{!14}
54
55!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
56!1 = distinct !DIGlobalVariable(name: "c", scope: !2, file: !3, line: 1, type: !6, isLocal: false, isDefinition: true)
57!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 10.0.0 (https://github.com/llvm/llvm-project.git d5509db439a1bb3f0822c42398c8b5921a665478)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, nameTableKind: None)
58!3 = !DIFile(filename: "test.c", directory: "/tmp/home/yhs/work/tests/core")
59!4 = !{}
60!5 = !{!0}
61!6 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "b", file: !3, line: 1, size: 64, elements: !7)
62!7 = !{!8, !10}
63!8 = !DIDerivedType(tag: DW_TAG_member, name: "d", scope: !6, file: !3, line: 1, baseType: !9, size: 32)
64!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
65!10 = !DIDerivedType(tag: DW_TAG_member, name: "e", scope: !6, file: !3, line: 1, baseType: !9, size: 32, offset: 32)
66!11 = !{i32 2, !"Dwarf Version", i32 4}
67!12 = !{i32 2, !"Debug Info Version", i32 3}
68!13 = !{i32 1, !"wchar_size", i32 4}
69!14 = !{!"clang version 10.0.0 (https://github.com/llvm/llvm-project.git d5509db439a1bb3f0822c42398c8b5921a665478)"}
70!15 = distinct !DISubprogram(name: "f", scope: !3, file: !3, line: 2, type: !16, scopeLine: 2, isDefinition: true, isOptimized: true, unit: !2, retainedNodes: !4)
71!16 = !DISubroutineType(types: !17)
72!17 = !{!9}
73!18 = !DILocation(line: 3, column: 42, scope: !15)
74!19 = !DILocation(line: 3, column: 10, scope: !15)
75!20 = !DILocation(line: 3, column: 3, scope: !15)
76