1 ; Test that misexpect diagnostics handle stripped debug info gracefully
3 ; RUN: llvm-profdata merge %S/Inputs/misexpect-branch.proftext -o %t.profdata
5 ; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -pgo-warn-misexpect -S 2>&1 | FileCheck %s --check-prefix=WARNING
6 ; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=REMARK
7 ; 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 --check-prefix=BOTH
8 ; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -S 2>&1 | FileCheck %s --check-prefix=DISABLED
10 ; WARNING-DAG: warning: <unknown>:0:0: 19.98%
11 ; WARNING-NOT: remark: <unknown>:0:0: Potential performance regression from use of the llvm.expect intrinsic: Annotation was correct on 19.98% (399668 / 2000000) of profiled executions.
13 ; REMARK-NOT: warning: <unknown>:0:0: 19.98%
14 ; REMARK-DAG: remark: <unknown>:0:0: Potential performance regression from use of the llvm.expect intrinsic: Annotation was correct on 19.98% (399668 / 2000000) of profiled executions.
16 ; BOTH-DAG: warning: <unknown>:0:0: 19.98%
17 ; BOTH-DAG: remark: <unknown>:0:0: Potential performance regression from use of the llvm.expect intrinsic: Annotation was correct on 19.98% (399668 / 2000000) of profiled executions.
19 ; DISABLED-NOT: warning: <unknown>:0:0: 19.98%
20 ; DISABLED-NOT: remark: <unknown>:0:0: Potential performance regression from use of the llvm.expect intrinsic: Annotation was correct on 19.98% (399668 / 2000000) of profiled executions.
23 ; ModuleID = 'misexpect-branch.c'
24 source_filename = "misexpect-branch.c"
25 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
26 target triple = "x86_64-unknown-linux-gnu"
28 @inner_loop = constant i32 100, align 4
29 @outer_loop = constant i32 2000, align 4
31 ; Function Attrs: nounwind
32 define i32 @bar() #0 {
34 %rando = alloca i32, align 4
35 %x = alloca i32, align 4
36 call void @llvm.lifetime.start.p0(i64 4, ptr %rando) #4
37 %call = call i32 (...) @buzz()
38 store i32 %call, ptr %rando, align 4, !tbaa !3
39 call void @llvm.lifetime.start.p0(i64 4, ptr %x) #4
40 store i32 0, ptr %x, align 4, !tbaa !3
41 %0 = load i32, ptr %rando, align 4, !tbaa !3
42 %rem = srem i32 %0, 200000
43 %cmp = icmp eq i32 %rem, 0
44 %lnot = xor i1 %cmp, true
45 %lnot1 = xor i1 %lnot, true
46 %lnot.ext = zext i1 %lnot1 to i32
47 %conv = sext i32 %lnot.ext to i64
48 %expval = call i64 @llvm.expect.i64(i64 %conv, i64 1)
49 %tobool = icmp ne i64 %expval, 0
50 br i1 %tobool, label %if.then, label %if.else
52 if.then: ; preds = %entry
53 %1 = load i32, ptr %rando, align 4, !tbaa !3
54 %call2 = call i32 @baz(i32 %1)
55 store i32 %call2, ptr %x, align 4, !tbaa !3
58 if.else: ; preds = %entry
59 %call3 = call i32 @foo(i32 50)
60 store i32 %call3, ptr %x, align 4, !tbaa !3
63 if.end: ; preds = %if.else, %if.then
64 %2 = load i32, ptr %x, align 4, !tbaa !3
65 call void @llvm.lifetime.end.p0(i64 4, ptr %x) #4
66 call void @llvm.lifetime.end.p0(i64 4, ptr %rando) #4
70 ; Function Attrs: argmemonly nounwind willreturn
71 declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
73 declare i32 @buzz(...) #2
75 ; Function Attrs: nounwind readnone willreturn
76 declare i64 @llvm.expect.i64(i64, i64) #3
78 declare i32 @baz(i32) #2
80 declare i32 @foo(i32) #2
82 ; Function Attrs: argmemonly nounwind willreturn
83 declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
85 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" }
86 attributes #1 = { argmemonly nounwind willreturn }
87 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" }
88 attributes #3 = { nounwind readnone willreturn }
89 attributes #4 = { nounwind }
91 !llvm.module.flags = !{!0, !1}
94 !0 = !{i32 2, !"Debug Info Version", i32 3}
95 !1 = !{i32 1, !"wchar_size", i32 4}
96 !2 = !{!"clang version 10.0.0 (trunk c20270bfffc9d6965219de339d66c61e9fe7d82d)"}
98 !4 = !{!"int", !5, i64 0}
99 !5 = !{!"omnipotent char", !6, i64 0}
100 !6 = !{!"Simple C/C++ TBAA"}