xref: /llvm-project/llvm/test/Transforms/PGOProfile/misexpect-branch-unpredictable.ll (revision 9ff36df5a4a7d52c51e950522870bb64912688d2)
1; Test misexpect doesn't issue diagnostics when a branch is marked unpredictable
2
3; RUN: llvm-profdata merge %S/Inputs/misexpect-branch-correct.proftext -o %t.profdata
4
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
6
7; CHECK-NOT: warning: {{.*}}
8; CHECK-NOT: remark: {{.*}}
9
10
11; ModuleID = 'misexpect-branch-unpredictable.c'
12source_filename = "clang/test/Profile/misexpect-branch-unpredictable.c"
13target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
14target triple = "x86_64-unknown-linux-gnu"
15
16@inner_loop = constant i32 100, align 4
17@outer_loop = constant i32 2000, align 4
18
19; Function Attrs: nounwind
20define i32 @bar() #0 {
21entry:
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
38
39if.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
43  br label %if.end
44
45if.else:                                          ; preds = %entry
46  %call3 = call i32 @foo(i32 50)
47  store i32 %call3, ptr %x, align 4, !tbaa !2
48  br label %if.end
49
50if.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
54  ret i32 %2
55}
56
57; Function Attrs: argmemonly nounwind willreturn
58declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
59
60declare i32 @buzz(...) #2
61
62declare i32 @baz(i32) #2
63
64declare i32 @foo(i32) #2
65
66; Function Attrs: argmemonly nounwind willreturn
67declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
68
69attributes #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" }
70attributes #1 = { argmemonly nounwind willreturn }
71attributes #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" }
72attributes #3 = { nounwind }
73
74!llvm.module.flags = !{!0}
75!llvm.ident = !{!1}
76
77!0 = !{i32 1, !"wchar_size", i32 4}
78!1 = !{!"Fuchsia clang version 10.0.0 (153b453014c94291c8c6cf6320b2f46df40f26f3) (based on LLVM 10.0.0svn)"}
79!2 = !{!3, !3, i64 0}
80!3 = !{!"int", !4, i64 0}
81!4 = !{!"omnipotent char", !5, i64 0}
82!5 = !{!"Simple C/C++ TBAA"}
83!6 = !{}
84