1 ; RUN: opt -O2 -mtriple=bpf-pc-linux %s | llvm-dis > %t1
2 ; RUN: llc %t1 -o - | FileCheck -check-prefixes=CHECK-COMMON,CHECK %s
3 ; RUN: opt -O2 -mtriple=bpf-pc-linux -bpf-disable-avoid-speculation %s | llvm-dis > %t1
4 ; RUN: llc %t1 -o - | FileCheck -check-prefixes=CHECK-COMMON,CHECK-DISABLE %s
9 ; unsigned ret = foo();
15 ; clang -target bpf -O2 -S -emit-llvm -Xclang -disable-llvm-passes test.c
17 ; Function Attrs: nounwind
18 define dso_local ptr @test(ptr %p) #0 {
20 %p.addr = alloca ptr, align 8
21 %ret = alloca i32, align 4
22 store ptr %p, ptr %p.addr, align 8, !tbaa !2
23 call void @llvm.lifetime.start.p0(i64 4, ptr %ret) #3
24 %call = call i32 @foo()
25 store i32 %call, ptr %ret, align 4, !tbaa !6
26 %0 = load i32, ptr %ret, align 4, !tbaa !6
27 %cmp = icmp ule i32 %0, 7
28 br i1 %cmp, label %if.then, label %if.end
30 if.then: ; preds = %entry
31 %1 = load i32, ptr %ret, align 4, !tbaa !6
32 %2 = load ptr, ptr %p.addr, align 8, !tbaa !2
33 %idx.ext = zext i32 %1 to i64
34 %add.ptr = getelementptr i8, ptr %2, i64 %idx.ext
35 store ptr %add.ptr, ptr %p.addr, align 8, !tbaa !2
38 if.end: ; preds = %if.then, %entry
39 %3 = load ptr, ptr %p.addr, align 8, !tbaa !2
40 call void @llvm.lifetime.end.p0(i64 4, ptr %ret) #3
44 ; CHECK-COMMON: [[REG6:r[0-9]+]] = r1
45 ; CHECK-COMMON: call foo
49 ; CHECK: if r0 > 7 goto [[LABEL:.*]]
50 ; CHECK: [[REG6]] += r0
52 ; CHECK: r0 = [[REG6]]
54 ; CHECK-DISABLE: [[REG1:r[0-9]+]] = r0
55 ; CHECK-DISABLE: [[REG1]] <<= 32
56 ; CHECK-DISABLE: [[REG1]] >>= 32
57 ; CHECK-DISABLE: [[REG2:r[0-9]+]] = 8
58 ; CHECK-DISABLE: if [[REG2]] > [[REG1]] goto [[LABEL:.*]]
59 ; CHECK-DISABLE: r0 = 0
60 ; CHECK-DISABLE: [[LABEL]]:
61 ; CHECK-DISABLE: r0 <<= 32
62 ; CHECK-DISABLE: r0 >>= 32
63 ; CHECK-DISABLE: [[REG6]] += r0
64 ; CHECK-DISABLE: r0 = [[REG6]]
68 ; Function Attrs: argmemonly nounwind willreturn
69 declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
71 declare dso_local i32 @foo(...) #2
73 ; Function Attrs: argmemonly nounwind willreturn
74 declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
76 attributes #0 = { nounwind "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"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
77 attributes #1 = { argmemonly nounwind willreturn }
78 attributes #2 = { "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"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
79 attributes #3 = { nounwind }
81 !llvm.module.flags = !{!0}
84 !0 = !{i32 1, !"wchar_size", i32 4}
85 !1 = !{!"clang version 12.0.0 (https://github.com/llvm/llvm-project.git ca9c5433a6c31e372092fcd8bfd0e4fddd7e8784)"}
87 !3 = !{!"any pointer", !4, i64 0}
88 !4 = !{!"omnipotent char", !5, i64 0}
89 !5 = !{!"Simple C/C++ TBAA"}
91 !7 = !{!"int", !4, i64 0}