Index: include/llvm/CodeGen/MachineBasicBlock.h =================================================================== --- include/llvm/CodeGen/MachineBasicBlock.h +++ include/llvm/CodeGen/MachineBasicBlock.h @@ -106,6 +106,10 @@ // MachineBasicBlocks are allocated and owned by MachineFunction. friend class MachineFunction; + // Default weight value. Used when adding a successor without indicating any + // weight. + static const uint32_t DEFAULT_WEIGHT = 16; + public: /// Return the LLVM basic block that this instance corresponded to originally. /// Note that this may be NULL if this instance does not correspond directly @@ -379,7 +383,7 @@ /// calculate branch probability. /// /// Note that duplicate Machine CFG edges are not allowed. - void addSuccessor(MachineBasicBlock *succ, uint32_t weight = 0); + void addSuccessor(MachineBasicBlock *succ, uint32_t weight = DEFAULT_WEIGHT); /// Set successor weight of a given iterator. void setSuccWeight(succ_iterator I, uint32_t weight); Index: lib/Analysis/BranchProbabilityInfo.cpp =================================================================== --- lib/Analysis/BranchProbabilityInfo.cpp +++ lib/Analysis/BranchProbabilityInfo.cpp @@ -22,6 +22,7 @@ #include "llvm/IR/Metadata.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" +#include using namespace llvm; @@ -206,6 +207,25 @@ } assert(Weights.size() == TI->getNumSuccessors() && "Checked above"); + // Weight cannot be zero. Here we find out all zero weights read from MD, and + // replace them by 1. If any other weight is not zero, we need to normalize + // other weights so that the sum of all weights are maximized but less than + // UINT32_MAX. + auto ZeroWeightNum = std::count(Weights.begin(), Weights.end(), 0u); + if (ZeroWeightNum > 0) { + // If all weights are zeros, replace them by 1. + if (ZeroWeightNum == Weights.size()) + std::fill(Weights.begin(), Weights.end(), 1u); + else { + uint64_t ScalingFactor = (UINT32_MAX - ZeroWeightNum) / WeightSum; + if (ScalingFactor > 1) + for (auto &W : Weights) + W *= ScalingFactor; + std::replace(Weights.begin(), Weights.end(), 0u, 1u); + } + WeightSum += ZeroWeightNum; + } + // If the sum of weights does not fit in 32 bits, scale every weight down // accordingly. uint64_t ScalingFactor = @@ -213,7 +233,8 @@ WeightSum = 0; for (unsigned i = 0, e = TI->getNumSuccessors(); i != e; ++i) { - uint32_t W = Weights[i] / ScalingFactor; + // Make sure the weight is greater than 0. + uint32_t W = std::max(Weights[i] / ScalingFactor, 1); WeightSum += W; setEdgeWeight(BB, i, W); } Index: lib/CodeGen/MIRParser/MIRParser.cpp =================================================================== --- lib/CodeGen/MIRParser/MIRParser.cpp +++ lib/CodeGen/MIRParser/MIRParser.cpp @@ -373,7 +373,10 @@ if (parseMBBReference(SuccMBB, MBBSource, MF, PFS)) return true; // TODO: Report an error when adding the same successor more than once. - MBB.addSuccessor(SuccMBB, HasWeights ? Weights[SuccessorIndex++].Value : 0); + if (HasWeights) + MBB.addSuccessor(SuccMBB, Weights[SuccessorIndex++].Value); + else + MBB.addSuccessor(SuccMBB); } // Parse the liveins. for (const auto &LiveInSource : YamlMBB.LiveIns) { Index: lib/CodeGen/MachineBasicBlock.cpp =================================================================== --- lib/CodeGen/MachineBasicBlock.cpp +++ lib/CodeGen/MachineBasicBlock.cpp @@ -313,9 +313,8 @@ if (Indexes) OS << '\t'; OS << " Successors according to CFG:"; for (const_succ_iterator SI = succ_begin(), E = succ_end(); SI != E; ++SI) { - OS << " BB#" << (*SI)->getNumber(); - if (!Weights.empty()) - OS << '(' << *getWeightIterator(SI) << ')'; + OS << " BB#" << (*SI)->getNumber() << '(' << *getWeightIterator(SI) + << ')'; } OS << '\n'; } @@ -475,29 +474,19 @@ } void MachineBasicBlock::addSuccessor(MachineBasicBlock *succ, uint32_t weight) { - - // If we see non-zero value for the first time it means we actually use Weight - // list, so we fill all Weights with 0's. - if (weight != 0 && Weights.empty()) - Weights.resize(Successors.size()); - - if (weight != 0 || !Weights.empty()) - Weights.push_back(weight); - - Successors.push_back(succ); - succ->addPredecessor(this); - } + assert(weight > 0 && "Edge weight must be greater than 0!"); + Weights.push_back(weight); + Successors.push_back(succ); + succ->addPredecessor(this); +} void MachineBasicBlock::removeSuccessor(MachineBasicBlock *succ) { succ->removePredecessor(this); succ_iterator I = std::find(Successors.begin(), Successors.end(), succ); assert(I != Successors.end() && "Not a current successor!"); - // If Weight list is empty it means we don't use it (disabled optimization). - if (!Weights.empty()) { - weight_iterator WI = getWeightIterator(I); - Weights.erase(WI); - } + weight_iterator WI = getWeightIterator(I); + Weights.erase(WI); Successors.erase(I); } @@ -506,11 +495,8 @@ MachineBasicBlock::removeSuccessor(succ_iterator I) { assert(I != Successors.end() && "Not a current successor!"); - // If Weight list is empty it means we don't use it (disabled optimization). - if (!Weights.empty()) { - weight_iterator WI = getWeightIterator(I); - Weights.erase(WI); - } + weight_iterator WI = getWeightIterator(I); + Weights.erase(WI); (*I)->removePredecessor(this); return Successors.erase(I); @@ -546,13 +532,9 @@ return; } - // New is already a successor. - // Update its weight instead of adding a duplicate edge. - if (!Weights.empty()) { - weight_iterator OldWI = getWeightIterator(OldI); - *getWeightIterator(NewI) += *OldWI; - Weights.erase(OldWI); - } + weight_iterator OldWI = getWeightIterator(OldI); + *getWeightIterator(NewI) += *OldWI; + Weights.erase(OldWI); Successors.erase(OldI); } @@ -572,12 +554,7 @@ while (!fromMBB->succ_empty()) { MachineBasicBlock *Succ = *fromMBB->succ_begin(); - uint32_t Weight = 0; - - // If Weight list is empty it means we don't use it (disabled optimization). - if (!fromMBB->Weights.empty()) - Weight = *fromMBB->Weights.begin(); - + uint32_t Weight = *fromMBB->Weights.begin(); addSuccessor(Succ, Weight); fromMBB->removeSuccessor(Succ); } @@ -590,9 +567,7 @@ while (!fromMBB->succ_empty()) { MachineBasicBlock *Succ = *fromMBB->succ_begin(); - uint32_t Weight = 0; - if (!fromMBB->Weights.empty()) - Weight = *fromMBB->Weights.begin(); + uint32_t Weight = *fromMBB->Weights.begin(); addSuccessor(Succ, Weight); fromMBB->removeSuccessor(Succ); @@ -1086,16 +1061,12 @@ /// getSuccWeight - Return weight of the edge from this block to MBB. /// uint32_t MachineBasicBlock::getSuccWeight(const_succ_iterator Succ) const { - if (Weights.empty()) - return 0; - return *getWeightIterator(Succ); } /// Set successor weight of a given iterator. void MachineBasicBlock::setSuccWeight(succ_iterator I, uint32_t weight) { - if (Weights.empty()) - return; + assert(weight > 0 && "Edge weight must be greater than 0!"); *getWeightIterator(I) = weight; } Index: lib/CodeGen/SelectionDAG/FastISel.cpp =================================================================== --- lib/CodeGen/SelectionDAG/FastISel.cpp +++ lib/CodeGen/SelectionDAG/FastISel.cpp @@ -1398,11 +1398,12 @@ TII.InsertBranch(*FuncInfo.MBB, MSucc, nullptr, SmallVector(), DbgLoc); } - uint32_t BranchWeight = 0; - if (FuncInfo.BPI) - BranchWeight = FuncInfo.BPI->getEdgeWeight(FuncInfo.MBB->getBasicBlock(), - MSucc->getBasicBlock()); - FuncInfo.MBB->addSuccessor(MSucc, BranchWeight); + if (FuncInfo.BPI) { + uint32_t BranchWeight = FuncInfo.BPI->getEdgeWeight( + FuncInfo.MBB->getBasicBlock(), MSucc->getBasicBlock()); + FuncInfo.MBB->addSuccessor(MSucc, BranchWeight); + } else + FuncInfo.MBB->addSuccessor(MSucc); } /// Emit an FNeg operation. Index: lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp =================================================================== --- lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -1363,7 +1363,10 @@ uint32_t Weight /* = 0 */) { if (!Weight) Weight = getEdgeWeight(Src, Dst); - Src->addSuccessor(Dst, Weight); + if (Weight) + Src->addSuccessor(Dst, Weight); + else + Src->addSuccessor(Dst); } Index: lib/Target/AArch64/AArch64FastISel.cpp =================================================================== --- lib/Target/AArch64/AArch64FastISel.cpp +++ lib/Target/AArch64/AArch64FastISel.cpp @@ -2236,11 +2236,12 @@ MIB.addMBB(TBB); // Obtain the branch weight and add the TrueBB to the successor list. - uint32_t BranchWeight = 0; - if (FuncInfo.BPI) - BranchWeight = FuncInfo.BPI->getEdgeWeight(BI->getParent(), - TBB->getBasicBlock()); - FuncInfo.MBB->addSuccessor(TBB, BranchWeight); + if (FuncInfo.BPI) { + uint32_t BranchWeight = + FuncInfo.BPI->getEdgeWeight(BI->getParent(), TBB->getBasicBlock()); + FuncInfo.MBB->addSuccessor(TBB, BranchWeight); + } else + FuncInfo.MBB->addSuccessor(TBB); fastEmitBranch(FBB, DbgLoc); return true; @@ -2318,11 +2319,12 @@ .addMBB(TBB); // Obtain the branch weight and add the TrueBB to the successor list. - uint32_t BranchWeight = 0; - if (FuncInfo.BPI) - BranchWeight = FuncInfo.BPI->getEdgeWeight(BI->getParent(), - TBB->getBasicBlock()); - FuncInfo.MBB->addSuccessor(TBB, BranchWeight); + if (FuncInfo.BPI) { + uint32_t BranchWeight = + FuncInfo.BPI->getEdgeWeight(BI->getParent(), TBB->getBasicBlock()); + FuncInfo.MBB->addSuccessor(TBB, BranchWeight); + } else + FuncInfo.MBB->addSuccessor(TBB); fastEmitBranch(FBB, DbgLoc); return true; @@ -2356,11 +2358,12 @@ .addMBB(TBB); // Obtain the branch weight and add the TrueBB to the successor list. - uint32_t BranchWeight = 0; - if (FuncInfo.BPI) - BranchWeight = FuncInfo.BPI->getEdgeWeight(BI->getParent(), - TBB->getBasicBlock()); - FuncInfo.MBB->addSuccessor(TBB, BranchWeight); + if (FuncInfo.BPI) { + uint32_t BranchWeight = + FuncInfo.BPI->getEdgeWeight(BI->getParent(), TBB->getBasicBlock()); + FuncInfo.MBB->addSuccessor(TBB, BranchWeight); + } else + FuncInfo.MBB->addSuccessor(TBB); fastEmitBranch(FBB, DbgLoc); return true; @@ -2372,11 +2375,12 @@ .addMBB(Target); // Obtain the branch weight and add the target to the successor list. - uint32_t BranchWeight = 0; - if (FuncInfo.BPI) - BranchWeight = FuncInfo.BPI->getEdgeWeight(BI->getParent(), - Target->getBasicBlock()); - FuncInfo.MBB->addSuccessor(Target, BranchWeight); + if (FuncInfo.BPI) { + uint32_t BranchWeight = + FuncInfo.BPI->getEdgeWeight(BI->getParent(), Target->getBasicBlock()); + FuncInfo.MBB->addSuccessor(Target, BranchWeight); + } else + FuncInfo.MBB->addSuccessor(Target); return true; } else if (foldXALUIntrinsic(CC, I, BI->getCondition())) { // Fake request the condition, otherwise the intrinsic might be completely @@ -2391,11 +2395,12 @@ .addMBB(TBB); // Obtain the branch weight and add the TrueBB to the successor list. - uint32_t BranchWeight = 0; - if (FuncInfo.BPI) - BranchWeight = FuncInfo.BPI->getEdgeWeight(BI->getParent(), - TBB->getBasicBlock()); - FuncInfo.MBB->addSuccessor(TBB, BranchWeight); + if (FuncInfo.BPI) { + uint32_t BranchWeight = + FuncInfo.BPI->getEdgeWeight(BI->getParent(), TBB->getBasicBlock()); + FuncInfo.MBB->addSuccessor(TBB, BranchWeight); + } else + FuncInfo.MBB->addSuccessor(TBB); fastEmitBranch(FBB, DbgLoc); return true; @@ -2425,11 +2430,12 @@ .addMBB(TBB); // Obtain the branch weight and add the TrueBB to the successor list. - uint32_t BranchWeight = 0; - if (FuncInfo.BPI) - BranchWeight = FuncInfo.BPI->getEdgeWeight(BI->getParent(), - TBB->getBasicBlock()); - FuncInfo.MBB->addSuccessor(TBB, BranchWeight); + if (FuncInfo.BPI) { + uint32_t BranchWeight = + FuncInfo.BPI->getEdgeWeight(BI->getParent(), TBB->getBasicBlock()); + FuncInfo.MBB->addSuccessor(TBB, BranchWeight); + } else + FuncInfo.MBB->addSuccessor(TBB); fastEmitBranch(FBB, DbgLoc); return true; Index: lib/Target/PowerPC/PPCISelLowering.cpp =================================================================== --- lib/Target/PowerPC/PPCISelLowering.cpp +++ lib/Target/PowerPC/PPCISelLowering.cpp @@ -8383,8 +8383,8 @@ .addMBB(mainMBB); MIB = BuildMI(*thisMBB, MI, DL, TII->get(PPC::B)).addMBB(sinkMBB); - thisMBB->addSuccessor(mainMBB, /* weight */ 0); - thisMBB->addSuccessor(sinkMBB, /* weight */ 1); + thisMBB->addSuccessor(mainMBB, /* weight */ 1); + thisMBB->addSuccessor(sinkMBB, /* weight */ UINT32_MAX - 1); // mainMBB: // mainDstReg = 0 Index: lib/Target/X86/X86FastISel.cpp =================================================================== --- lib/Target/X86/X86FastISel.cpp +++ lib/Target/X86/X86FastISel.cpp @@ -1432,11 +1432,12 @@ } // Obtain the branch weight and add the TrueBB to the successor list. - uint32_t BranchWeight = 0; - if (FuncInfo.BPI) - BranchWeight = FuncInfo.BPI->getEdgeWeight(BI->getParent(), - TrueMBB->getBasicBlock()); - FuncInfo.MBB->addSuccessor(TrueMBB, BranchWeight); + if (FuncInfo.BPI) { + uint32_t BranchWeight = FuncInfo.BPI->getEdgeWeight( + BI->getParent(), TrueMBB->getBasicBlock()); + FuncInfo.MBB->addSuccessor(TrueMBB, BranchWeight); + } else + FuncInfo.MBB->addSuccessor(TrueMBB); // Emits an unconditional branch to the FalseBB, obtains the branch // weight, and adds it to the successor list. @@ -1473,11 +1474,12 @@ BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.get(JmpOpc)) .addMBB(TrueMBB); fastEmitBranch(FalseMBB, DbgLoc); - uint32_t BranchWeight = 0; - if (FuncInfo.BPI) - BranchWeight = FuncInfo.BPI->getEdgeWeight(BI->getParent(), - TrueMBB->getBasicBlock()); - FuncInfo.MBB->addSuccessor(TrueMBB, BranchWeight); + if (FuncInfo.BPI) { + uint32_t BranchWeight = FuncInfo.BPI->getEdgeWeight( + BI->getParent(), TrueMBB->getBasicBlock()); + FuncInfo.MBB->addSuccessor(TrueMBB, BranchWeight); + } else + FuncInfo.MBB->addSuccessor(TrueMBB); return true; } } @@ -1493,11 +1495,12 @@ BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.get(BranchOpc)) .addMBB(TrueMBB); fastEmitBranch(FalseMBB, DbgLoc); - uint32_t BranchWeight = 0; - if (FuncInfo.BPI) - BranchWeight = FuncInfo.BPI->getEdgeWeight(BI->getParent(), - TrueMBB->getBasicBlock()); - FuncInfo.MBB->addSuccessor(TrueMBB, BranchWeight); + if (FuncInfo.BPI) { + uint32_t BranchWeight = FuncInfo.BPI->getEdgeWeight( + BI->getParent(), TrueMBB->getBasicBlock()); + FuncInfo.MBB->addSuccessor(TrueMBB, BranchWeight); + } else + FuncInfo.MBB->addSuccessor(TrueMBB); return true; } @@ -1512,11 +1515,12 @@ BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.get(X86::JNE_1)) .addMBB(TrueMBB); fastEmitBranch(FalseMBB, DbgLoc); - uint32_t BranchWeight = 0; - if (FuncInfo.BPI) - BranchWeight = FuncInfo.BPI->getEdgeWeight(BI->getParent(), - TrueMBB->getBasicBlock()); - FuncInfo.MBB->addSuccessor(TrueMBB, BranchWeight); + if (FuncInfo.BPI) { + uint32_t BranchWeight = + FuncInfo.BPI->getEdgeWeight(BI->getParent(), TrueMBB->getBasicBlock()); + FuncInfo.MBB->addSuccessor(TrueMBB, BranchWeight); + } else + FuncInfo.MBB->addSuccessor(TrueMBB); return true; } Index: test/Analysis/BlockFrequencyInfo/bad_input.ll =================================================================== --- test/Analysis/BlockFrequencyInfo/bad_input.ll +++ test/Analysis/BlockFrequencyInfo/bad_input.ll @@ -9,8 +9,8 @@ entry: br label %for.body -; Check that we get 1,4 instead of 0,3. -; CHECK-NEXT: for.body: float = 4.0, +; Check that we get 1, ~UINT32_MAX instead of 0, 3. +; CHECK-NEXT: for.body: float = 4294967291.0, for.body: %i = phi i32 [ 0, %entry ], [ %inc, %for.body ] call void @g(i32 %i) Index: test/CodeGen/PowerPC/sjlj.ll =================================================================== --- test/CodeGen/PowerPC/sjlj.ll +++ test/CodeGen/PowerPC/sjlj.ll @@ -74,24 +74,24 @@ ; CHECK-DAG: std [[REGA]], [[OFF:[0-9]+]](31) # 8-byte Folded Spill ; CHECK-DAG: std 1, 16([[REGA]]) ; CHECK-DAG: std 2, 24([[REGA]]) -; CHECK: bcl 20, 31, .LBB1_1 +; CHECK: bcl 20, 31, .LBB1_5 ; CHECK: li 3, 1 -; CHECK: #EH_SjLj_Setup .LBB1_1 -; CHECK: b .LBB1_2 +; CHECK: #EH_SjLj_Setup .LBB1_5 +; CHECK: b .LBB1_1 ; CHECK: .LBB1_1: -; CHECK: mflr [[REGL:[0-9]+]] -; CHECK: ld [[REG2:[0-9]+]], [[OFF]](31) # 8-byte Folded Reload -; CHECK: std [[REGL]], 8([[REG2]]) -; CHECK: li 3, 0 - -; CHECK: .LBB1_2: ; CHECK: lfd ; CHECK: lvx ; CHECK: ld ; CHECK: blr +; CHECK: .LBB1_5: +; CHECK: mflr [[REGL:[0-9]+]] +; CHECK: ld [[REG2:[0-9]+]], [[OFF]](31) # 8-byte Folded Reload +; CHECK: std [[REGL]], 8([[REG2]]) +; CHECK: li 3, 0 + ; CHECK-NOAV: @main ; CHECK-NOAV-NOT: stvx ; CHECK-NOAV: bcl Index: test/Transforms/SampleProfile/branch.ll =================================================================== --- test/Transforms/SampleProfile/branch.ll +++ test/Transforms/SampleProfile/branch.ll @@ -36,8 +36,8 @@ tail call void @llvm.dbg.value(metadata i8** %argv, i64 0, metadata !14, metadata !DIExpression()), !dbg !27 %cmp = icmp slt i32 %argc, 2, !dbg !28 br i1 %cmp, label %return, label %if.end, !dbg !28 -; CHECK: edge entry -> return probability is 0 / 1 = 0% -; CHECK: edge entry -> if.end probability is 1 / 1 = 100% +; CHECK: edge entry -> return probability is 1 / 4294967295 = 2.32831e-08% +; CHECK: edge entry -> if.end probability is 4294967294 / 4294967295 = 100% [HOT edge] if.end: ; preds = %entry %arrayidx = getelementptr inbounds i8*, i8** %argv, i64 1, !dbg !30 @@ -46,8 +46,8 @@ tail call void @llvm.dbg.value(metadata i32 %call, i64 0, metadata !17, metadata !DIExpression()), !dbg !30 %cmp1 = icmp sgt i32 %call, 100, !dbg !35 br i1 %cmp1, label %for.body, label %if.end6, !dbg !35 -; CHECK: edge if.end -> for.body probability is 0 / 1 = 0% -; CHECK: edge if.end -> if.end6 probability is 1 / 1 = 100% +; CHECK: edge if.end -> for.body probability is 1 / 4294967295 = 2.32831e-08% +; CHECK: edge if.end -> if.end6 probability is 4294967294 / 4294967295 = 100% [HOT edge] for.body: ; preds = %if.end, %for.body %u.016 = phi i32 [ %inc, %for.body ], [ 0, %if.end ] @@ -65,8 +65,8 @@ tail call void @llvm.dbg.value(metadata i32 %inc, i64 0, metadata !21, metadata !DIExpression()), !dbg !38 %exitcond = icmp eq i32 %inc, %call, !dbg !38 br i1 %exitcond, label %if.end6, label %for.body, !dbg !38 -; CHECK: edge for.body -> if.end6 probability is 0 / 10226 = 0% -; CHECK: edge for.body -> for.body probability is 10226 / 10226 = 100% [HOT edge] +; CHECK: edge for.body -> if.end6 probability is 1 / 4294960905 = 2.32831e-08% +; CHECK: edge for.body -> for.body probability is 4294960904 / 4294960905 = 100% [HOT edge] if.end6: ; preds = %for.body, %if.end %result.0 = phi double [ 0.000000e+00, %if.end ], [ %sub, %for.body ] Index: test/Transforms/SampleProfile/calls.ll =================================================================== --- test/Transforms/SampleProfile/calls.ll +++ test/Transforms/SampleProfile/calls.ll @@ -52,8 +52,8 @@ store i32 %inc, i32* %i, align 4, !dbg !14 %cmp = icmp slt i32 %0, 400000000, !dbg !14 br i1 %cmp, label %while.body, label %while.end, !dbg !14 -; CHECK: edge while.cond -> while.body probability is 5391 / 5391 = 100% [HOT edge] -; CHECK: edge while.cond -> while.end probability is 0 / 5391 = 0% +; CHECK: edge while.cond -> while.body probability is 4294966572 / 4294966573 = 100% [HOT edge] +; CHECK: edge while.cond -> while.end probability is 1 / 4294966573 = 2.32831e-08% while.body: ; preds = %while.cond %1 = load i32, i32* %i, align 4, !dbg !16 @@ -63,8 +63,8 @@ ; both branches out of while.body had the same weight. In reality, ; the edge while.body->if.then is taken most of the time. ; -; CHECK: edge while.body -> if.then probability is 5752 / 5752 = 100% [HOT edge] -; CHECK: edge while.body -> if.else probability is 0 / 5752 = 0% +; CHECK: edge while.body -> if.then probability is 4294966632 / 4294966633 = 100% [HOT edge] +; CHECK: edge while.body -> if.else probability is 1 / 4294966633 = 2.32831e-08% if.then: ; preds = %while.body Index: test/Transforms/SampleProfile/propagate.ll =================================================================== --- test/Transforms/SampleProfile/propagate.ll +++ test/Transforms/SampleProfile/propagate.ll @@ -73,8 +73,8 @@ %5 = load i64, i64* %N.addr, align 8, !dbg !15 %cmp1 = icmp slt i64 %4, %5, !dbg !15 br i1 %cmp1, label %for.body, label %for.end18, !dbg !15 -; CHECK: edge for.cond -> for.body probability is 10 / 10 = 100% [HOT edge] -; CHECK: edge for.cond -> for.end18 probability is 0 / 10 = 0% +; CHECK: edge for.cond -> for.body probability is 4294967290 / 4294967291 = 100% [HOT edge] +; CHECK: edge for.cond -> for.end18 probability is 1 / 4294967291 = 2.32831e-08% for.body: ; preds = %for.cond %6 = load i64, i64* %i, align 8, !dbg !18 @@ -119,8 +119,8 @@ %14 = load i64, i64* %i, align 8, !dbg !28 %cmp10 = icmp slt i64 %conv9, %14, !dbg !28 br i1 %cmp10, label %for.body11, label %for.end, !dbg !28 -; CHECK: edge for.cond8 -> for.body11 probability is 16191 / 16191 = 100% [HOT edge] -; CHECK: edge for.cond8 -> for.end probability is 0 / 16191 = 0% +; CHECK: edge if.then6 -> if.end15 probability is 16 / 16 = 100% [HOT edge] +; CHECK: edge for.cond8 -> for.end probability is 1 / 4294954189 = 2.32831e-08% for.body11: ; preds = %for.cond8 %15 = load i32, i32* %j, align 4, !dbg !31