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 4; Source code: 5; #define _(x) (__builtin_preserve_access_index(x)) 6; int get_value(const int *arg); 7; int test(int *arg) { 8; return get_value(_(&arg[4])); 9; } 10; Compilation flag: 11; clang -target bpf -O2 -g -S -emit-llvm -Xclang -disable-llvm-passes test.c 12 13target triple = "bpf" 14 15; Function Attrs: nounwind 16define dso_local i32 @test(ptr %arg) local_unnamed_addr #0 !dbg !10 { 17entry: 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 22} 23 24; CHECK: r1 += 16 25; CHECK: call get_value 26; CHECK: .section .BTF.ext,"",@progbits 27; CHECK-NOT: .long 16 # FieldReloc 28 29declare dso_local i32 @get_value(ptr) local_unnamed_addr #1 30 31; Function Attrs: nounwind readnone 32declare ptr @llvm.preserve.array.access.index.p0.p0(ptr, i32, i32) #2 33 34; Function Attrs: nounwind readnone speculatable willreturn 35declare void @llvm.dbg.value(metadata, metadata, metadata) #3 36 37attributes #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" } 38attributes #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" } 39attributes #2 = { nounwind readnone } 40attributes #3 = { nounwind readnone speculatable willreturn } 41attributes #4 = { nounwind } 42 43!llvm.dbg.cu = !{!0} 44!llvm.module.flags = !{!6, !7, !8} 45!llvm.ident = !{!9} 46 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") 49!2 = !{} 50!3 = !{!4} 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) 59!12 = !{!5, !4} 60!13 = !{!14} 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) 66