141 lines · plain
1; RUN: llvm-profdata merge %S/Inputs/irreducible.proftext -o %t.profdata2; RUN: opt < %s -passes=pgo-instr-use -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE3; RUN: llvm-profdata merge %S/Inputs/irreducible_entry.proftext -o %t2.profdata4; RUN: opt < %s -passes=pgo-instr-use -pgo-instrument-entry=true -pgo-test-profile-file=%t2.profdata -S | FileCheck %s --check-prefix=USE5 6; GEN: $__llvm_profile_raw_version = comdat any7 8; Function Attrs: noinline norecurse nounwind readnone uwtable9define i32 @_Z11irreducibleii(i32 %iter_outer, i32 %iter_inner) local_unnamed_addr #0 {10entry:11 %cmp24 = icmp sgt i32 %iter_outer, 012 br i1 %cmp24, label %for.body, label %entry.for.cond.cleanup_crit_edge13 14entry.for.cond.cleanup_crit_edge: ; preds = %entry15 br label %for.cond.cleanup16 17for.cond.cleanup: ; preds = %entry.for.cond.cleanup_crit_edge, %for.end18 %sum.0.lcssa = phi i32 [ 0, %entry.for.cond.cleanup_crit_edge ], [ %sum.1, %for.end ]19 ret i32 %sum.0.lcssa20 21for.body: ; preds = %entry, %for.end22 %k.026 = phi i32 [ %inc12, %for.end ], [ 0, %entry ]23 %sum.025 = phi i32 [ %sum.1, %for.end ], [ 0, %entry ]24 %rem23 = and i32 %k.026, 125 %cmp1 = icmp eq i32 %rem23, 026 br i1 %cmp1, label %entry8, label %for.cond227 28for.cond2: ; preds = %for.body, %if.end929 %sum.1 = phi i32 [ %add10, %if.end9 ], [ %sum.025, %for.body ]30 %i.0 = phi i32 [ %inc, %if.end9 ], [ 0, %for.body ]31 %cmp3 = icmp slt i32 %i.0, %iter_inner32 br i1 %cmp3, label %for.body4, label %for.end33; USE: br i1 %cmp3, label %for.body4, label %for.end, !prof !{{[0-9]+}},34; USE-SAME: !irr_loop ![[FOR_COND2_IRR_LOOP:[0-9]+]]35 36for.body4: ; preds = %for.cond237 %rem5 = srem i32 %k.026, 338 %cmp6 = icmp eq i32 %rem5, 039 br i1 %cmp6, label %entry8, label %if.end940 41entry8: ; preds = %for.body4, %for.body42 %sum.2 = phi i32 [ %sum.025, %for.body ], [ %sum.1, %for.body4 ]43 %i.1 = phi i32 [ 0, %for.body ], [ %i.0, %for.body4 ]44 %add = add nsw i32 %sum.2, 445 br label %if.end946; USE: br label %if.end9,47; USE-SAME: !irr_loop ![[ENTRY8_IRR_LOOP:[0-9]+]]48 49if.end9: ; preds = %entry8, %for.body450 %sum.3 = phi i32 [ %add, %entry8 ], [ %sum.1, %for.body4 ]51 %i.2 = phi i32 [ %i.1, %entry8 ], [ %i.0, %for.body4 ]52 %add10 = add nsw i32 %sum.3, 153 %inc = add nsw i32 %i.2, 154 br label %for.cond255; USE: br label %for.cond2,56; USE-SAME: !irr_loop ![[IF_END9_IRR_LOOP:[0-9]+]]57 58for.end: ; preds = %for.cond259 %inc12 = add nuw nsw i32 %k.026, 160 %exitcond = icmp eq i32 %inc12, %iter_outer61 br i1 %exitcond, label %for.cond.cleanup, label %for.body62}63 64 65 66@targets = local_unnamed_addr global [256 x ptr] zeroinitializer, align 1667@tracing = local_unnamed_addr global i32 0, align 468 69; Function Attrs: noinline norecurse nounwind uwtable70define i32 @_Z11irreduciblePh(ptr nocapture readonly %p) {71entry:72 %0 = load i32, ptr @tracing, align 473 %1 = trunc i32 %0 to i874 %tobool = icmp eq i32 %0, 075 br label %for.cond176 77for.cond1: ; preds = %sw.default, %entry78 br label %dispatch_op79 80dispatch_op: ; preds = %sw.bb6, %for.cond181 switch i8 %1, label %sw.default [82 i8 0, label %sw.bb83 i8 1, label %dispatch_op.sw.bb6_crit_edge84 i8 2, label %sw.bb1585 ]86 87dispatch_op.sw.bb6_crit_edge: ; preds = %dispatch_op88 br label %sw.bb689 90sw.bb: ; preds = %indirectgoto, %dispatch_op91 br label %exit92 93TARGET_1: ; preds = %indirectgoto94 br label %sw.bb695; USE: br label %sw.bb6, !irr_loop {{.*}}96 97sw.bb6: ; preds = %TARGET_1, %dispatch_op.sw.bb6_crit_edge98 br i1 %tobool, label %dispatch_op, label %if.then99; USE: br i1 %tobool, label %dispatch_op, label %if.then, !prof !{{[0-9]+}},100; USE-SAME: !irr_loop ![[SW_BB6_IRR_LOOP:[0-9]+]]101 102if.then: ; preds = %sw.bb6103 br label %indirectgoto104 105TARGET_2: ; preds = %indirectgoto106 br label %sw.bb15107; USE: br label %sw.bb15, !irr_loop {{.*}}108 109sw.bb15: ; preds = %TARGET_2, %dispatch_op110 br i1 %tobool, label %if.then18, label %exit111; USE: br i1 %tobool, label %if.then18, label %exit, !prof !{{[0-9]+}},112; USE-SAME: !irr_loop ![[SW_BB15_IRR_LOOP:[0-9]+]]113 114if.then18: ; preds = %sw.bb15115 br label %indirectgoto116 117unknown_op: ; preds = %indirectgoto118 br label %sw.default119 120sw.default: ; preds = %unknown_op, %dispatch_op121 br label %for.cond1122 123exit: ; preds = %sw.bb15, %sw.bb124 ret i32 0125 126indirectgoto: ; preds = %if.then18, %if.then127 %idxprom21 = zext i32 %0 to i64128 %arrayidx22 = getelementptr inbounds [256 x ptr], ptr @targets, i64 0, i64 %idxprom21129 %target = load ptr, ptr %arrayidx22, align 8130 indirectbr ptr %target, [label %unknown_op, label %sw.bb, label %TARGET_1, label %TARGET_2]131; USE: indirectbr ptr %target, [label %unknown_op, label %sw.bb, label %TARGET_1, label %TARGET_2], !prof !{{[0-9]+}},132; USE-SAME: !irr_loop ![[INDIRECTGOTO_IRR_LOOP:[0-9]+]]133}134 135; USE: ![[FOR_COND2_IRR_LOOP]] = !{!"loop_header_weight", i64 1050}136; USE: ![[ENTRY8_IRR_LOOP]] = !{!"loop_header_weight", i64 373}137; USE: ![[IF_END9_IRR_LOOP]] = !{!"loop_header_weight", i64 1000}138; USE: ![[SW_BB6_IRR_LOOP]] = !{!"loop_header_weight", i64 501}139; USE: ![[SW_BB15_IRR_LOOP]] = !{!"loop_header_weight", i64 100}140; USE: ![[INDIRECTGOTO_IRR_LOOP]] = !{!"loop_header_weight", i64 399}141