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 5; 6; Source: 7; unsigned foo(); 8; void *test(void *p) { 9; unsigned ret = foo(); 10; if (ret <= 7) 11; p += ret; 12; return p; 13; } 14; Compilation flag: 15; clang -target bpf -O2 -S -emit-llvm -Xclang -disable-llvm-passes test.c 16 17; Function Attrs: nounwind 18define dso_local i8* @test(i8* %p) #0 { 19entry: 20 %p.addr = alloca i8*, align 8 21 %ret = alloca i32, align 4 22 store i8* %p, i8** %p.addr, align 8, !tbaa !2 23 %0 = bitcast i32* %ret to i8* 24 call void @llvm.lifetime.start.p0i8(i64 4, i8* %0) #3 25 %call = call i32 bitcast (i32 (...)* @foo to i32 ()*)() 26 store i32 %call, i32* %ret, align 4, !tbaa !6 27 %1 = load i32, i32* %ret, align 4, !tbaa !6 28 %cmp = icmp ule i32 %1, 7 29 br i1 %cmp, label %if.then, label %if.end 30 31if.then: ; preds = %entry 32 %2 = load i32, i32* %ret, align 4, !tbaa !6 33 %3 = load i8*, i8** %p.addr, align 8, !tbaa !2 34 %idx.ext = zext i32 %2 to i64 35 %add.ptr = getelementptr i8, i8* %3, i64 %idx.ext 36 store i8* %add.ptr, i8** %p.addr, align 8, !tbaa !2 37 br label %if.end 38 39if.end: ; preds = %if.then, %entry 40 %4 = load i8*, i8** %p.addr, align 8, !tbaa !2 41 %5 = bitcast i32* %ret to i8* 42 call void @llvm.lifetime.end.p0i8(i64 4, i8* %5) #3 43 ret i8* %4 44} 45 46; CHECK-COMMON: [[REG6:r[0-9]+]] = r1 47; CHECK-COMMON: call foo 48 49; CHECK: r0 <<= 32 50; CHECK: r0 >>= 32 51; CHECK: if r0 > 7 goto [[LABEL:.*]] 52; CHECK: [[REG6]] += r0 53; CHECK: [[LABEL]]: 54; CHECK: r0 = [[REG6]] 55 56; CHECK-DISABLE: [[REG1:r[0-9]+]] = r0 57; CHECK-DISABLE: [[REG1]] <<= 32 58; CHECK-DISABLE: [[REG1]] >>= 32 59; CHECK-DISABLE: r0 = [[REG6]] 60; CHECK-DISABLE: r0 += [[REG1]] 61; CHECK-DISABLE: [[REG2:r[0-9]+]] = 8 62; CHECK-DISABLE: if [[REG2]] > [[REG1]] goto [[LABEL:.*]] 63; CHECK-DISABLE: r0 = [[REG6]] 64; CHECK-DISABLE: [[LABEL]]: 65 66; CHECK-COMMON: exit 67 68; Function Attrs: argmemonly nounwind willreturn 69declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #1 70 71declare dso_local i32 @foo(...) #2 72 73; Function Attrs: argmemonly nounwind willreturn 74declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #1 75 76attributes #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" } 77attributes #1 = { argmemonly nounwind willreturn } 78attributes #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" } 79attributes #3 = { nounwind } 80 81!llvm.module.flags = !{!0} 82!llvm.ident = !{!1} 83 84!0 = !{i32 1, !"wchar_size", i32 4} 85!1 = !{!"clang version 12.0.0 (https://github.com/llvm/llvm-project.git ca9c5433a6c31e372092fcd8bfd0e4fddd7e8784)"} 86!2 = !{!3, !3, i64 0} 87!3 = !{!"any pointer", !4, i64 0} 88!4 = !{!"omnipotent char", !5, i64 0} 89!5 = !{!"Simple C/C++ TBAA"} 90!6 = !{!7, !7, i64 0} 91!7 = !{!"int", !4, i64 0} 92