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
8 ; void *test(void *p) {
9 ; unsigned long ret = foo();
15 ; clang -target bpf -O2 -S -emit-llvm -Xclang -disable-llvm-passes test.c
17 ; Function Attrs: nounwind
18 define dso_local i8* @test(i8* %p) #0 {
20 %p.addr = alloca i8*, align 8
21 %ret = alloca i64, align 8
22 store i8* %p, i8** %p.addr, align 8, !tbaa !2
23 %0 = bitcast i64* %ret to i8*
24 call void @llvm.lifetime.start.p0i8(i64 8, i8* %0) #3
25 %call = call i64 bitcast (i64 (...)* @foo to i64 ()*)()
26 store i64 %call, i64* %ret, align 8, !tbaa !6
27 %1 = load i64, i64* %ret, align 8, !tbaa !6
28 %cmp = icmp ule i64 %1, 7
29 br i1 %cmp, label %if.then, label %if.end
31 if.then: ; preds = %entry
32 %2 = load i64, i64* %ret, align 8, !tbaa !6
33 %3 = load i8*, i8** %p.addr, align 8, !tbaa !2
34 %add.ptr = getelementptr i8, i8* %3, i64 %2
35 store i8* %add.ptr, i8** %p.addr, align 8, !tbaa !2
38 if.end: ; preds = %if.then, %entry
39 %4 = load i8*, i8** %p.addr, align 8, !tbaa !2
40 %5 = bitcast i64* %ret to i8*
41 call void @llvm.lifetime.end.p0i8(i64 8, i8* %5) #3
44 ; CHECK-COMMON: [[REG6:r[0-9]+]] = r1
45 ; CHECK-COMMON: call foo
47 ; CHECK: if r0 > 7 goto [[LABEL:.*]]
48 ; CHECK: [[REG6]] += r0
50 ; CHECK: r0 = [[REG6]]
52 ; CHECK-DISABLE: [[REG1:r[0-9]+]] = 8
53 ; CHECK-DISABLE: if [[REG1]] > r0 goto [[LABEL:.*]]
54 ; CHECK-DISABLE: r0 = 0
55 ; CHECK-DISABLE: [[LABEL]]:
56 ; CHECK-DISABLE: [[REG6]] += r0
57 ; CHECK-DISABLE: r0 = [[REG6]]
61 ; Function Attrs: argmemonly nounwind willreturn
62 declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #1
64 declare dso_local i64 @foo(...) #2
66 ; Function Attrs: argmemonly nounwind willreturn
67 declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #1
69 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" }
70 attributes #1 = { argmemonly nounwind willreturn }
71 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" }
72 attributes #3 = { nounwind }
74 !llvm.module.flags = !{!0}
77 !0 = !{i32 1, !"wchar_size", i32 4}
78 !1 = !{!"clang version 12.0.0 (https://github.com/llvm/llvm-project.git ca9c5433a6c31e372092fcd8bfd0e4fddd7e8784)"}
80 !3 = !{!"any pointer", !4, i64 0}
81 !4 = !{!"omnipotent char", !5, i64 0}
82 !5 = !{!"Simple C/C++ TBAA"}
84 !7 = !{!"long", !4, i64 0}