brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.7 KiB · 38c27b9 Raw
173 lines · plain
1; Test misexpect handles switch statements when debug information is stripped2 3; RUN: llvm-profdata merge %S/Inputs/misexpect-switch.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: 0.00%11; WARNING-NOT: remark: <unknown>:0:0: Potential performance regression from use of the llvm.expect intrinsic: Annotation was correct on 0.00% (0 / 27943) of profiled executions.12 13; REMARK-NOT: warning: <unknown>:0:0: 0.00%14; REMARK-DAG: remark: <unknown>:0:0: Potential performance regression from use of the llvm.expect intrinsic: Annotation was correct on 0.00% (0 / 27943) of profiled executions.15 16; BOTH-DAG: warning: <unknown>:0:0: 0.00%17; BOTH-DAG: remark: <unknown>:0:0: Potential performance regression from use of the llvm.expect intrinsic: Annotation was correct on 0.00% (0 / 27943) of profiled executions.18 19; DISABLED-NOT: warning: <unknown>:0:0: 0.00%20; DISABLED-NOT: remark: <unknown>:0:0: Potential performance regression from use of the llvm.expect intrinsic: Annotation was correct on 0.00% (0 / 27943) of profiled executions.21 22; DISABLED-NOT: warning: <unknown>:0:0: 0.00%23; DISABLED-NOT: remark: <unknown>:0:0: Potential performance regression from use of the llvm.expect intrinsic: Annotation was correct on 0.00% (0 / 27943) of profiled executions.24 25; CORRECT-NOT: warning: {{.*}}26; CORRECT-NOT: remark: {{.*}}27 28; ModuleID = 'misexpect-switch.c'29source_filename = "misexpect-switch.c"30target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"31target triple = "x86_64-unknown-linux-gnu"32 33@inner_loop = dso_local constant i32 1000, align 434@outer_loop = dso_local constant i32 20, align 435@arry_size = dso_local constant i32 25, align 436@arry = dso_local global [25 x i32] zeroinitializer, align 1637 38; Function Attrs: nounwind uwtable39define dso_local void @init_arry() {40entry:41  %i = alloca i32, align 442  call void @llvm.lifetime.start.p0(ptr %i)43  store i32 0, ptr %i, align 4, !tbaa !444  br label %for.cond45 46for.cond:                                         ; preds = %for.inc, %entry47  %0 = load i32, ptr %i, align 4, !tbaa !448  %cmp = icmp slt i32 %0, 2549  br i1 %cmp, label %for.body, label %for.end50 51for.body:                                         ; preds = %for.cond52  %call = call i32 @rand()53  %rem = srem i32 %call, 1054  %1 = load i32, ptr %i, align 4, !tbaa !455  %idxprom = sext i32 %1 to i6456  %arrayidx = getelementptr inbounds [25 x i32], ptr @arry, i64 0, i64 %idxprom57  store i32 %rem, ptr %arrayidx, align 4, !tbaa !458  br label %for.inc59 60for.inc:                                          ; preds = %for.body61  %2 = load i32, ptr %i, align 4, !tbaa !462  %inc = add nsw i32 %2, 163  store i32 %inc, ptr %i, align 4, !tbaa !464  br label %for.cond65 66for.end:                                          ; preds = %for.cond67  call void @llvm.lifetime.end.p0(ptr %i)68  ret void69}70 71; Function Attrs: argmemonly nounwind willreturn72declare void @llvm.lifetime.start.p0(ptr nocapture)73 74; Function Attrs: nounwind readnone speculatable willreturn75declare void @llvm.dbg.declare(metadata, metadata, metadata)76 77; Function Attrs: nounwind78declare dso_local i32 @rand()79 80; Function Attrs: argmemonly nounwind willreturn81declare void @llvm.lifetime.end.p0(ptr nocapture)82 83; Function Attrs: nounwind uwtable84define dso_local i32 @main() {85entry:86  %retval = alloca i32, align 487  %val = alloca i32, align 488  %j = alloca i32, align 489  %condition = alloca i32, align 490  store i32 0, ptr %retval, align 491  call void @init_arry()92  call void @llvm.lifetime.start.p0(ptr %val)93  store i32 0, ptr %val, align 4, !tbaa !494  call void @llvm.lifetime.start.p0(ptr %j)95  store i32 0, ptr %j, align 4, !tbaa !496  br label %for.cond97 98for.cond:                                         ; preds = %for.inc, %entry99  %0 = load i32, ptr %j, align 4, !tbaa !4100  %cmp = icmp slt i32 %0, 20000101  br i1 %cmp, label %for.body, label %for.end102 103for.body:                                         ; preds = %for.cond104  call void @llvm.lifetime.start.p0(ptr %condition)105  %call = call i32 @rand()106  %rem = srem i32 %call, 5107  store i32 %rem, ptr %condition, align 4, !tbaa !4108  %1 = load i32, ptr %condition, align 4, !tbaa !4109  %conv = zext i32 %1 to i64110  %expval = call i64 @llvm.expect.i64(i64 %conv, i64 6)111  switch i64 %expval, label %sw.default [112    i64 0, label %sw.bb113    i64 1, label %sw.bb2114    i64 2, label %sw.bb2115    i64 3, label %sw.bb2116    i64 4, label %sw.bb3117  ]118 119sw.bb:                                            ; preds = %for.body120  %call1 = call i32 @sum(ptr @arry, i32 25)121  %2 = load i32, ptr %val, align 4, !tbaa !4122  %add = add nsw i32 %2, %call1123  store i32 %add, ptr %val, align 4, !tbaa !4124  br label %sw.epilog125 126sw.bb2:                                           ; preds = %for.body, %for.body, %for.body127  br label %sw.epilog128 129sw.bb3:                                           ; preds = %for.body130  %call4 = call i32 @random_sample(ptr @arry, i32 25)131  %3 = load i32, ptr %val, align 4, !tbaa !4132  %add5 = add nsw i32 %3, %call4133  store i32 %add5, ptr %val, align 4, !tbaa !4134  br label %sw.epilog135 136sw.default:                                       ; preds = %for.body137  unreachable138 139sw.epilog:                                        ; preds = %sw.bb3, %sw.bb2, %sw.bb140  call void @llvm.lifetime.end.p0(ptr %condition)141  br label %for.inc142 143for.inc:                                          ; preds = %sw.epilog144  %4 = load i32, ptr %j, align 4, !tbaa !4145  %inc = add nsw i32 %4, 1146  store i32 %inc, ptr %j, align 4, !tbaa !4147  br label %for.cond148 149for.end:                                          ; preds = %for.cond150  call void @llvm.lifetime.end.p0(ptr %j)151  call void @llvm.lifetime.end.p0(ptr %val)152  ret i32 0153}154 155; Function Attrs: nounwind readnone willreturn156declare i64 @llvm.expect.i64(i64, i64)157 158declare dso_local i32 @sum(ptr, i32)159 160declare dso_local i32 @random_sample(ptr, i32)161 162!llvm.module.flags = !{!0, !1, !2}163!llvm.ident = !{!3}164 165!0 = !{i32 2, !"Dwarf Version", i32 4}166!1 = !{i32 2, !"Debug Info Version", i32 3}167!2 = !{i32 1, !"wchar_size", i32 4}168!3 = !{!"clang version 10.0.0 (60b79b85b1763d3d25630261e5cd1adb7f0835bc)"}169!4 = !{!5, !5, i64 0}170!5 = !{!"int", !6, i64 0}171!6 = !{!"omnipotent char", !7, i64 0}172!7 = !{!"Simple C/C++ TBAA"}173