1 ; RUN: opt -O2 %s | llvm-dis > %t1
2 ; RUN: llc -filetype=asm -o - %t1 | FileCheck -check-prefixes=CHECK %s
3 ; RUN: llc -mattr=+alu32 -filetype=asm -o - %t1 | FileCheck -check-prefixes=CHECK %s
5 ; #define _(x) (__builtin_preserve_access_index(x))
6 ; int get_value(const int *arg);
8 ; return get_value(_(&arg[4]));
11 ; clang -target bpf -O2 -g -S -emit-llvm -Xclang -disable-llvm-passes test.c
15 ; Function Attrs: nounwind
16 define dso_local i32 @test(ptr %arg) local_unnamed_addr #0 !dbg !10 {
18 call void @llvm.dbg.value(metadata ptr %arg, metadata !14, metadata !DIExpression()), !dbg !15
19 %0 = tail call ptr @llvm.preserve.array.access.index.p0.p0(ptr elementtype(i32) %arg, i32 0, i32 4), !dbg !16, !llvm.preserve.access.index !4
20 %call = tail call i32 @get_value(ptr %0) #4, !dbg !17
21 ret i32 %call, !dbg !18
25 ; CHECK: call get_value
26 ; CHECK: .section .BTF.ext,"",@progbits
27 ; CHECK-NOT: .long 16 # FieldReloc
29 declare dso_local i32 @get_value(ptr) local_unnamed_addr #1
31 ; Function Attrs: nounwind readnone
32 declare ptr @llvm.preserve.array.access.index.p0.p0(ptr, i32, i32) #2
34 ; Function Attrs: nounwind readnone speculatable willreturn
35 declare void @llvm.dbg.value(metadata, metadata, metadata) #3
37 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" }
38 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" }
39 attributes #2 = { nounwind readnone }
40 attributes #3 = { nounwind readnone speculatable willreturn }
41 attributes #4 = { nounwind }
44 !llvm.module.flags = !{!6, !7, !8}
47 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 10.0.0 (trunk 367256) (llvm/trunk 367266)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, nameTableKind: None)
48 !1 = !DIFile(filename: "test.c", directory: "/tmp/home/yhs/work/tests/llvm/cast")
51 !4 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !5, size: 64)
52 !5 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
53 !6 = !{i32 2, !"Dwarf Version", i32 4}
54 !7 = !{i32 2, !"Debug Info Version", i32 3}
55 !8 = !{i32 1, !"wchar_size", i32 4}
56 !9 = !{!"clang version 10.0.0 (trunk 367256) (llvm/trunk 367266)"}
57 !10 = distinct !DISubprogram(name: "test", scope: !1, file: !1, line: 3, type: !11, scopeLine: 3, flags: DIFlagPrototyped, isDefinition: true, isOptimized: true, unit: !0, retainedNodes: !13)
58 !11 = !DISubroutineType(types: !12)
61 !14 = !DILocalVariable(name: "arg", arg: 1, scope: !10, file: !1, line: 3, type: !4)
62 !15 = !DILocation(line: 0, scope: !10)
63 !16 = !DILocation(line: 4, column: 20, scope: !10)
64 !17 = !DILocation(line: 4, column: 10, scope: !10)
65 !18 = !DILocation(line: 4, column: 3, scope: !10)