94 lines · plain
1; Test that misexpect diagnostics handle stripped debug info gracefully2 3; RUN: llvm-profdata merge %S/Inputs/misexpect-branch.proftext -o %t.profdata4 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=WARNING6; 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=REMARK7; 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=BOTH8; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -S 2>&1 | FileCheck %s --check-prefix=DISABLED9 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.12 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.15 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.18 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.21 22; ModuleID = 'misexpect-branch.c'23source_filename = "misexpect-branch.c"24target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"25target triple = "x86_64-unknown-linux-gnu"26 27@inner_loop = constant i32 100, align 428@outer_loop = constant i32 2000, align 429 30; Function Attrs: nounwind31define i32 @bar() {32entry:33 %rando = alloca i32, align 434 %x = alloca i32, align 435 call void @llvm.lifetime.start.p0(ptr %rando)36 %call = call i32 (...) @buzz()37 store i32 %call, ptr %rando, align 4, !tbaa !338 call void @llvm.lifetime.start.p0(ptr %x)39 store i32 0, ptr %x, align 4, !tbaa !340 %0 = load i32, ptr %rando, align 4, !tbaa !341 %rem = srem i32 %0, 20000042 %cmp = icmp eq i32 %rem, 043 %lnot = xor i1 %cmp, true44 %lnot1 = xor i1 %lnot, true45 %lnot.ext = zext i1 %lnot1 to i3246 %conv = sext i32 %lnot.ext to i6447 %expval = call i64 @llvm.expect.i64(i64 %conv, i64 1)48 %tobool = icmp ne i64 %expval, 049 br i1 %tobool, label %if.then, label %if.else50 51if.then: ; preds = %entry52 %1 = load i32, ptr %rando, align 4, !tbaa !353 %call2 = call i32 @baz(i32 %1)54 store i32 %call2, ptr %x, align 4, !tbaa !355 br label %if.end56 57if.else: ; preds = %entry58 %call3 = call i32 @foo(i32 50)59 store i32 %call3, ptr %x, align 4, !tbaa !360 br label %if.end61 62if.end: ; preds = %if.else, %if.then63 %2 = load i32, ptr %x, align 4, !tbaa !364 call void @llvm.lifetime.end.p0(ptr %x)65 call void @llvm.lifetime.end.p0(ptr %rando)66 ret i32 %267}68 69; Function Attrs: argmemonly nounwind willreturn70declare void @llvm.lifetime.start.p0(ptr nocapture)71 72declare i32 @buzz(...)73 74; Function Attrs: nounwind readnone willreturn75declare i64 @llvm.expect.i64(i64, i64)76 77declare i32 @baz(i32)78 79declare i32 @foo(i32)80 81; Function Attrs: argmemonly nounwind willreturn82declare void @llvm.lifetime.end.p0(ptr nocapture)83 84!llvm.module.flags = !{!0, !1}85!llvm.ident = !{!2}86 87!0 = !{i32 2, !"Debug Info Version", i32 3}88!1 = !{i32 1, !"wchar_size", i32 4}89!2 = !{!"clang version 10.0.0 (trunk c20270bfffc9d6965219de339d66c61e9fe7d82d)"}90!3 = !{!4, !4, i64 0}91!4 = !{!"int", !5, i64 0}92!5 = !{!"omnipotent char", !6, i64 0}93!6 = !{!"Simple C/C++ TBAA"}94