forked from OSchip/llvm-project
[SimplifyCFG] FoldValueComparisonIntoPredecessors(): deal with each predecessor only once
If the predecessor is a switch, and BB is not the default destination, multiple cases could have the same destination. and it doesn't make sense to re-process the predecessor, because we won't make any changes, once is enough. I'm not sure this can be really tested, other than via the assertion being added here, which fires without the fix.
This commit is contained in:
parent
fc96cb2dad
commit
d15d81ce15
|
@ -1099,7 +1099,7 @@ bool SimplifyCFGOpt::FoldValueComparisonIntoPredecessors(Instruction *TI,
|
|||
++NumFoldValueComparisonIntoPredecessors;
|
||||
});
|
||||
|
||||
SmallVector<BasicBlock *, 16> Preds(predecessors(BB));
|
||||
SmallSetVector<BasicBlock *, 16> Preds(pred_begin(BB), pred_end(BB));
|
||||
while (!Preds.empty()) {
|
||||
BasicBlock *Pred = Preds.pop_back_val();
|
||||
|
||||
|
@ -1260,6 +1260,7 @@ bool SimplifyCFGOpt::FoldValueComparisonIntoPredecessors(Instruction *TI,
|
|||
// Okay, at this point, we know which new successor Pred will get. Make
|
||||
// sure we update the number of entries in the PHI nodes for these
|
||||
// successors.
|
||||
assert(!NewSuccessors.empty() && "Should be adding some new successors.");
|
||||
for (const std::pair<BasicBlock *, int /*Num*/> &NewSuccessor :
|
||||
NewSuccessors) {
|
||||
for (auto I : seq(0, NewSuccessor.second)) {
|
||||
|
|
Loading…
Reference in New Issue