1 ; Test misexpect doesn't issue diagnostics when a branch is marked unpredictable
3 ; RUN: llvm-profdata merge %S/Inputs/misexpect-branch-correct.proftext -o %t.profdata
5 ; 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
7 ; CHECK-NOT: warning: {{.*}}
8 ; CHECK-NOT: remark: {{.*}}
11 ; ModuleID = 'misexpect-branch-unpredictable.c'
12 source_filename = "clang/test/Profile/misexpect-branch-unpredictable.c"
13 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
14 target triple = "x86_64-unknown-linux-gnu"
16 @inner_loop = constant i32 100, align 4
17 @outer_loop = constant i32 2000, align 4
19 ; Function Attrs: nounwind
20 define i32 @bar() #0 {
22 %rando = alloca i32, align 4
23 %x = alloca i32, align 4
24 call void @llvm.lifetime.start.p0(i64 4, ptr %rando) #3
25 %call = call i32 (...) @buzz()
26 store i32 %call, ptr %rando, align 4, !tbaa !2
27 call void @llvm.lifetime.start.p0(i64 4, ptr %x) #3
28 store i32 0, ptr %x, align 4, !tbaa !2
29 %0 = load i32, ptr %rando, align 4, !tbaa !2
30 %rem = srem i32 %0, 200000
31 %cmp = icmp eq i32 %rem, 0
32 %lnot = xor i1 %cmp, true
33 %lnot1 = xor i1 %lnot, true
34 %lnot.ext = zext i1 %lnot1 to i32
35 %conv = sext i32 %lnot.ext to i64
36 %tobool = icmp ne i64 %conv, 0
37 br i1 %tobool, label %if.then, label %if.else, !unpredictable !6
39 if.then: ; preds = %entry
40 %1 = load i32, ptr %rando, align 4, !tbaa !2
41 %call2 = call i32 @baz(i32 %1)
42 store i32 %call2, ptr %x, align 4, !tbaa !2
45 if.else: ; preds = %entry
46 %call3 = call i32 @foo(i32 50)
47 store i32 %call3, ptr %x, align 4, !tbaa !2
50 if.end: ; preds = %if.else, %if.then
51 %2 = load i32, ptr %x, align 4, !tbaa !2
52 call void @llvm.lifetime.end.p0(i64 4, ptr %x) #3
53 call void @llvm.lifetime.end.p0(i64 4, ptr %rando) #3
57 ; Function Attrs: argmemonly nounwind willreturn
58 declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
60 declare i32 @buzz(...) #2
62 declare i32 @baz(i32) #2
64 declare i32 @foo(i32) #2
66 ; Function Attrs: argmemonly nounwind willreturn
67 declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
69 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" }
70 attributes #1 = { argmemonly nounwind willreturn }
71 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" }
72 attributes #3 = { nounwind }
74 !llvm.module.flags = !{!0}
77 !0 = !{i32 1, !"wchar_size", i32 4}
78 !1 = !{!"Fuchsia clang version 10.0.0 (153b453014c94291c8c6cf6320b2f46df40f26f3) (based on LLVM 10.0.0svn)"}
80 !3 = !{!"int", !4, i64 0}
81 !4 = !{!"omnipotent char", !5, i64 0}
82 !5 = !{!"Simple C/C++ TBAA"}