1; RUN: llvm-profdata merge %S/Inputs/irreducible.proftext -o %t.profdata 2; RUN: opt < %s -pgo-instr-use -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE 3; RUN: opt < %s -passes=pgo-instr-use -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE 4; RUN: llvm-profdata merge %S/Inputs/irreducible_entry.proftext -o %t2.profdata 5; RUN: opt < %s -pgo-instr-use -pgo-instrument-entry=true -pgo-test-profile-file=%t2.profdata -S | FileCheck %s --check-prefix=USE 6; RUN: opt < %s -passes=pgo-instr-use -pgo-instrument-entry=true -pgo-test-profile-file=%t2.profdata -S | FileCheck %s --check-prefix=USE 7 8; GEN: $__llvm_profile_raw_version = comdat any 9 10; Function Attrs: noinline norecurse nounwind readnone uwtable 11define i32 @_Z11irreducibleii(i32 %iter_outer, i32 %iter_inner) local_unnamed_addr #0 { 12entry: 13 %cmp24 = icmp sgt i32 %iter_outer, 0 14 br i1 %cmp24, label %for.body, label %entry.for.cond.cleanup_crit_edge 15 16entry.for.cond.cleanup_crit_edge: ; preds = %entry 17 br label %for.cond.cleanup 18 19for.cond.cleanup: ; preds = %entry.for.cond.cleanup_crit_edge, %for.end 20 %sum.0.lcssa = phi i32 [ 0, %entry.for.cond.cleanup_crit_edge ], [ %sum.1, %for.end ] 21 ret i32 %sum.0.lcssa 22 23for.body: ; preds = %entry, %for.end 24 %k.026 = phi i32 [ %inc12, %for.end ], [ 0, %entry ] 25 %sum.025 = phi i32 [ %sum.1, %for.end ], [ 0, %entry ] 26 %rem23 = and i32 %k.026, 1 27 %cmp1 = icmp eq i32 %rem23, 0 28 br i1 %cmp1, label %entry8, label %for.cond2 29 30for.cond2: ; preds = %for.body, %if.end9 31 %sum.1 = phi i32 [ %add10, %if.end9 ], [ %sum.025, %for.body ] 32 %i.0 = phi i32 [ %inc, %if.end9 ], [ 0, %for.body ] 33 %cmp3 = icmp slt i32 %i.0, %iter_inner 34 br i1 %cmp3, label %for.body4, label %for.end 35; USE: br i1 %cmp3, label %for.body4, label %for.end, !prof !{{[0-9]+}}, 36; USE-SAME: !irr_loop ![[FOR_COND2_IRR_LOOP:[0-9]+]] 37 38for.body4: ; preds = %for.cond2 39 %rem5 = srem i32 %k.026, 3 40 %cmp6 = icmp eq i32 %rem5, 0 41 br i1 %cmp6, label %entry8, label %if.end9 42 43entry8: ; preds = %for.body4, %for.body 44 %sum.2 = phi i32 [ %sum.025, %for.body ], [ %sum.1, %for.body4 ] 45 %i.1 = phi i32 [ 0, %for.body ], [ %i.0, %for.body4 ] 46 %add = add nsw i32 %sum.2, 4 47 br label %if.end9 48; USE: br label %if.end9, 49; USE-SAME: !irr_loop ![[ENTRY8_IRR_LOOP:[0-9]+]] 50 51if.end9: ; preds = %entry8, %for.body4 52 %sum.3 = phi i32 [ %add, %entry8 ], [ %sum.1, %for.body4 ] 53 %i.2 = phi i32 [ %i.1, %entry8 ], [ %i.0, %for.body4 ] 54 %add10 = add nsw i32 %sum.3, 1 55 %inc = add nsw i32 %i.2, 1 56 br label %for.cond2 57; USE: br label %for.cond2, 58; USE-SAME: !irr_loop ![[IF_END9_IRR_LOOP:[0-9]+]] 59 60for.end: ; preds = %for.cond2 61 %inc12 = add nuw nsw i32 %k.026, 1 62 %exitcond = icmp eq i32 %inc12, %iter_outer 63 br i1 %exitcond, label %for.cond.cleanup, label %for.body 64} 65 66 67 68@targets = local_unnamed_addr global [256 x i8*] zeroinitializer, align 16 69@tracing = local_unnamed_addr global i32 0, align 4 70 71; Function Attrs: noinline norecurse nounwind uwtable 72define i32 @_Z11irreduciblePh(i8* nocapture readonly %p) { 73entry: 74 %0 = load i32, i32* @tracing, align 4 75 %1 = trunc i32 %0 to i8 76 %tobool = icmp eq i32 %0, 0 77 br label %for.cond1 78 79for.cond1: ; preds = %sw.default, %entry 80 br label %dispatch_op 81 82dispatch_op: ; preds = %sw.bb6, %for.cond1 83 switch i8 %1, label %sw.default [ 84 i8 0, label %sw.bb 85 i8 1, label %dispatch_op.sw.bb6_crit_edge 86 i8 2, label %sw.bb15 87 ] 88 89dispatch_op.sw.bb6_crit_edge: ; preds = %dispatch_op 90 br label %sw.bb6 91 92sw.bb: ; preds = %indirectgoto, %dispatch_op 93 br label %exit 94 95TARGET_1: ; preds = %indirectgoto 96 br label %sw.bb6 97; USE: br label %sw.bb6, !irr_loop {{.*}} 98 99sw.bb6: ; preds = %TARGET_1, %dispatch_op.sw.bb6_crit_edge 100 br i1 %tobool, label %dispatch_op, label %if.then 101; USE: br i1 %tobool, label %dispatch_op, label %if.then, !prof !{{[0-9]+}}, 102; USE-SAME: !irr_loop ![[SW_BB6_IRR_LOOP:[0-9]+]] 103 104if.then: ; preds = %sw.bb6 105 br label %indirectgoto 106 107TARGET_2: ; preds = %indirectgoto 108 br label %sw.bb15 109; USE: br label %sw.bb15, !irr_loop {{.*}} 110 111sw.bb15: ; preds = %TARGET_2, %dispatch_op 112 br i1 %tobool, label %if.then18, label %exit 113; USE: br i1 %tobool, label %if.then18, label %exit, !prof !{{[0-9]+}}, 114; USE-SAME: !irr_loop ![[SW_BB15_IRR_LOOP:[0-9]+]] 115 116if.then18: ; preds = %sw.bb15 117 br label %indirectgoto 118 119unknown_op: ; preds = %indirectgoto 120 br label %sw.default 121 122sw.default: ; preds = %unknown_op, %dispatch_op 123 br label %for.cond1 124 125exit: ; preds = %sw.bb15, %sw.bb 126 ret i32 0 127 128indirectgoto: ; preds = %if.then18, %if.then 129 %idxprom21 = zext i32 %0 to i64 130 %arrayidx22 = getelementptr inbounds [256 x i8*], [256 x i8*]* @targets, i64 0, i64 %idxprom21 131 %target = load i8*, i8** %arrayidx22, align 8 132 indirectbr i8* %target, [label %unknown_op, label %sw.bb, label %TARGET_1, label %TARGET_2] 133; USE: indirectbr i8* %target, [label %unknown_op, label %sw.bb, label %TARGET_1, label %TARGET_2], !prof !{{[0-9]+}}, 134; USE-SAME: !irr_loop ![[INDIRECTGOTO_IRR_LOOP:[0-9]+]] 135} 136 137; USE: ![[FOR_COND2_IRR_LOOP]] = !{!"loop_header_weight", i64 1050} 138; USE: ![[ENTRY8_IRR_LOOP]] = !{!"loop_header_weight", i64 373} 139; USE: ![[IF_END9_IRR_LOOP]] = !{!"loop_header_weight", i64 1000} 140; USE: ![[SW_BB6_IRR_LOOP]] = !{!"loop_header_weight", i64 501} 141; USE: ![[SW_BB15_IRR_LOOP]] = !{!"loop_header_weight", i64 100} 142; USE: ![[INDIRECTGOTO_IRR_LOOP]] = !{!"loop_header_weight", i64 400} 143