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