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 ; typedef struct v3 { int a; int b; } __v3;
5 ; #define _(x) (__builtin_preserve_access_index(x))
6 ; int get_value(const int *arg);
7 ; __v3 *g __attribute__((section("stats")));
9 ; return get_value(_(&g->b));
12 ; clang -target bpf -O2 -g -S -emit-llvm test.c
14 %struct.v3 = type { i32, i32 }
16 @g = dso_local local_unnamed_addr global %struct.v3* null, section "stats", align 8, !dbg !0
18 ; Function Attrs: nounwind
19 define dso_local i32 @test() local_unnamed_addr #0 !dbg !17 {
21 %0 = load %struct.v3*, %struct.v3** @g, align 8, !dbg !20, !tbaa !21
22 %1 = tail call i32* @llvm.preserve.struct.access.index.p0i32.p0s_struct.v3s(%struct.v3* %0, i32 1, i32 1), !dbg !20, !llvm.preserve.access.index !8
23 %call = tail call i32 @get_value(i32* %1) #3, !dbg !25
24 ret i32 %call, !dbg !26
29 ; CHECK: call get_value
31 ; CHECK: .long 16 # BTF_KIND_STRUCT(id = [[TID1:[0-9]+]])
33 ; CHECK: .ascii ".text" # string offset=10
34 ; CHECK: .ascii "v3" # string offset=16
35 ; CHECK: .ascii "0:1" # string offset=23
37 ; CHECK: .long 16 # FieldReloc
38 ; CHECK-NEXT: .long 10 # Field reloc section string offset=10
40 ; CHECK-NEXT: .long .Ltmp{{[0-9]+}}
41 ; CHECK-NEXT: .long [[TID1]]
42 ; CHECK-NEXT: .long 23
45 declare dso_local i32 @get_value(i32*) local_unnamed_addr #1
47 ; Function Attrs: nounwind readnone
48 declare i32* @llvm.preserve.struct.access.index.p0i32.p0s_struct.v3s(%struct.v3*, i32, i32) #2
50 attributes #0 = { nounwind "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" }
51 attributes #1 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "no-infs-fp-math"="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" }
52 attributes #2 = { nounwind readnone }
53 attributes #3 = { nounwind }
56 !llvm.module.flags = !{!13, !14, !15}
59 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
60 !1 = distinct !DIGlobalVariable(name: "g", scope: !2, file: !3, line: 4, type: !6, isLocal: false, isDefinition: true)
61 !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 10.0.0 (trunk 367256) (llvm/trunk 367266)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, nameTableKind: None)
62 !3 = !DIFile(filename: "test.c", directory: "/tmp/home/yhs/work/tests/llvm/cast")
65 !6 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64)
66 !7 = !DIDerivedType(tag: DW_TAG_typedef, name: "__v3", file: !3, line: 1, baseType: !8)
67 !8 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "v3", file: !3, line: 1, size: 64, elements: !9)
69 !10 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !8, file: !3, line: 1, baseType: !11, size: 32)
70 !11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
71 !12 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !8, file: !3, line: 1, baseType: !11, size: 32, offset: 32)
72 !13 = !{i32 2, !"Dwarf Version", i32 4}
73 !14 = !{i32 2, !"Debug Info Version", i32 3}
74 !15 = !{i32 1, !"wchar_size", i32 4}
75 !16 = !{!"clang version 10.0.0 (trunk 367256) (llvm/trunk 367266)"}
76 !17 = distinct !DISubprogram(name: "test", scope: !3, file: !3, line: 5, type: !18, scopeLine: 5, isDefinition: true, isOptimized: true, unit: !2, retainedNodes: !4)
77 !18 = !DISubroutineType(types: !19)
79 !20 = !DILocation(line: 6, column: 20, scope: !17)
80 !21 = !{!22, !22, i64 0}
81 !22 = !{!"any pointer", !23, i64 0}
82 !23 = !{!"omnipotent char", !24, i64 0}
83 !24 = !{!"Simple C/C++ TBAA"}
84 !25 = !DILocation(line: 6, column: 10, scope: !17)
85 !26 = !DILocation(line: 6, column: 3, scope: !17)