1 ; RUN: llvm-profdata merge %S/Inputs/misexpect-branch-correct.proftext -o %t.profdata
3 ; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-test-profile-file=%t.profdata -S -pgo-warn-misexpect -pass-remarks=misexpect 2>&1 | FileCheck %s
6 ; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -pgo-warn-misexpect -pass-remarks=misexpect -S 2>&1 | FileCheck %s
8 ; CHECK-NOT: warning: {{.*}}
9 ; CHECK-NOT: remark: {{.*}}
10 ; CHECK-NOT: !"misexpect"
13 ; ModuleID = 'misexpect-branch-unpredictable.c'
14 source_filename = "clang/test/Profile/misexpect-branch-unpredictable.c"
15 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
16 target triple = "x86_64-unknown-linux-gnu"
18 @inner_loop = constant i32 100, align 4
19 @outer_loop = constant i32 2000, align 4
21 ; Function Attrs: nounwind
22 define i32 @bar() #0 {
24 %rando = alloca i32, align 4
25 %x = alloca i32, align 4
26 %0 = bitcast i32* %rando to i8*
27 call void @llvm.lifetime.start.p0i8(i64 4, i8* %0) #3
28 %call = call i32 (...) @buzz()
29 store i32 %call, i32* %rando, align 4, !tbaa !2
30 %1 = bitcast i32* %x to i8*
31 call void @llvm.lifetime.start.p0i8(i64 4, i8* %1) #3
32 store i32 0, i32* %x, align 4, !tbaa !2
33 %2 = load i32, i32* %rando, align 4, !tbaa !2
34 %rem = srem i32 %2, 200000
35 %cmp = icmp eq i32 %rem, 0
36 %lnot = xor i1 %cmp, true
37 %lnot1 = xor i1 %lnot, true
38 %lnot.ext = zext i1 %lnot1 to i32
39 %conv = sext i32 %lnot.ext to i64
40 %tobool = icmp ne i64 %conv, 0
41 br i1 %tobool, label %if.then, label %if.else, !unpredictable !6
43 if.then: ; preds = %entry
44 %3 = load i32, i32* %rando, align 4, !tbaa !2
45 %call2 = call i32 @baz(i32 %3)
46 store i32 %call2, i32* %x, align 4, !tbaa !2
49 if.else: ; preds = %entry
50 %call3 = call i32 @foo(i32 50)
51 store i32 %call3, i32* %x, align 4, !tbaa !2
54 if.end: ; preds = %if.else, %if.then
55 %4 = load i32, i32* %x, align 4, !tbaa !2
56 %5 = bitcast i32* %x to i8*
57 call void @llvm.lifetime.end.p0i8(i64 4, i8* %5) #3
58 %6 = bitcast i32* %rando to i8*
59 call void @llvm.lifetime.end.p0i8(i64 4, i8* %6) #3
63 ; Function Attrs: argmemonly nounwind willreturn
64 declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #1
66 declare i32 @buzz(...) #2
68 declare i32 @baz(i32) #2
70 declare i32 @foo(i32) #2
72 ; Function Attrs: argmemonly nounwind willreturn
73 declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #1
75 attributes #0 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "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" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
76 attributes #1 = { argmemonly nounwind willreturn }
77 attributes #2 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "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" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
78 attributes #3 = { nounwind }
80 !llvm.module.flags = !{!0}
83 !0 = !{i32 1, !"wchar_size", i32 4}
84 !1 = !{!"Fuchsia clang version 10.0.0 (153b453014c94291c8c6cf6320b2f46df40f26f3) (based on LLVM 10.0.0svn)"}
86 !3 = !{!"int", !4, i64 0}
87 !4 = !{!"omnipotent char", !5, i64 0}
88 !5 = !{!"Simple C/C++ TBAA"}