1; Test misexpect checks do not issue diagnostics when profiling weights and 2; branch weights added by llvm.expect agree 3 4; RUN: llvm-profdata merge %S/Inputs/misexpect-branch-correct.proftext -o %t.profdata 5 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 7 8; CHECK-NOT: warning: {{.*}} 9; CHECK-NOT: remark: {{.*}} 10; CHECK: !{!"branch_weights", i32 0, i32 200000} 11 12 13; ModuleID = 'misexpect-branch-correct.c' 14source_filename = "misexpect-branch-correct.c" 15target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 16target triple = "x86_64-unknown-linux-gnu" 17 18@inner_loop = constant i32 100, align 4 19@outer_loop = constant i32 2000, align 4 20 21; Function Attrs: nounwind 22define i32 @bar() #0 { 23entry: 24 %rando = alloca i32, align 4 25 %x = alloca i32, align 4 26 call void @llvm.lifetime.start.p0(i64 4, ptr %rando) #4 27 %call = call i32 (...) @buzz() 28 store i32 %call, ptr %rando, align 4, !tbaa !3 29 call void @llvm.lifetime.start.p0(i64 4, ptr %x) #4 30 store i32 0, ptr %x, align 4, !tbaa !3 31 %0 = load i32, ptr %rando, align 4, !tbaa !3 32 %rem = srem i32 %0, 200000 33 %cmp = icmp eq i32 %rem, 0 34 %lnot = xor i1 %cmp, true 35 %lnot1 = xor i1 %lnot, true 36 %lnot.ext = zext i1 %lnot1 to i32 37 %conv = sext i32 %lnot.ext to i64 38 %expval = call i64 @llvm.expect.i64(i64 %conv, i64 0) 39 %tobool = icmp ne i64 %expval, 0 40 br i1 %tobool, label %if.then, label %if.else 41 42if.then: ; preds = %entry 43 %1 = load i32, ptr %rando, align 4, !tbaa !3 44 %call2 = call i32 @baz(i32 %1) 45 store i32 %call2, ptr %x, align 4, !tbaa !3 46 br label %if.end 47 48if.else: ; preds = %entry 49 %call3 = call i32 @foo(i32 50) 50 store i32 %call3, ptr %x, align 4, !tbaa !3 51 br label %if.end 52 53if.end: ; preds = %if.else, %if.then 54 %2 = load i32, ptr %x, align 4, !tbaa !3 55 call void @llvm.lifetime.end.p0(i64 4, ptr %x) #4 56 call void @llvm.lifetime.end.p0(i64 4, ptr %rando) #4 57 ret i32 %2 58} 59 60; Function Attrs: argmemonly nounwind willreturn 61declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1 62 63declare i32 @buzz(...) #2 64 65; Function Attrs: nounwind readnone willreturn 66declare i64 @llvm.expect.i64(i64, i64) #3 67 68declare i32 @baz(i32) #2 69 70declare i32 @foo(i32) #2 71 72; Function Attrs: argmemonly nounwind willreturn 73declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1 74 75attributes #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" } 76attributes #1 = { argmemonly nounwind willreturn } 77attributes #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" } 78attributes #3 = { nounwind readnone willreturn } 79attributes #4 = { nounwind } 80 81!llvm.module.flags = !{!0, !1} 82!llvm.ident = !{!2} 83 84!0 = !{i32 2, !"Debug Info Version", i32 3} 85!1 = !{i32 1, !"wchar_size", i32 4} 86!2 = !{!"clang version 10.0.0 (c20270bfffc9d6965219de339d66c61e9fe7d82d)"} 87!3 = !{!4, !4, i64 0} 88!4 = !{!"int", !5, i64 0} 89!5 = !{!"omnipotent char", !6, i64 0} 90!6 = !{!"Simple C/C++ TBAA"} 91