Skip to content

Commit 42775a4

Browse files
authored
[ControlHeightReduction] Add assert to avoid underflow (#116339)
`NumCHRedBranches - 1` is used later, we should add an assertion to make sure it will not underflow.
1 parent 3291372 commit 42775a4

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1862,6 +1862,7 @@ void CHR::fixupBranchesAndSelects(CHRScope *Scope,
18621862
++NumCHRedBranches;
18631863
}
18641864
}
1865+
assert(NumCHRedBranches > 0);
18651866
Stats.NumBranchesDelta += NumCHRedBranches - 1;
18661867
Stats.WeightedNumBranchesDelta += (NumCHRedBranches - 1) * ProfileCount;
18671868
ORE.emit([&]() {

0 commit comments

Comments
 (0)