forked from OSchip/llvm-project
[AggressiveInstCombine] Fix `TruncInstCombine` (fix f84d732f
)
Erase phi-nodes from `InstInfoMap` before erasing themselves
This commit is contained in:
parent
0dd8401371
commit
904a00d17a
|
@ -504,6 +504,7 @@ void TruncInstCombine::ReduceExpressionGraph(Type *SclTy) {
|
|||
for (auto &Node : OldNewPHINodes) {
|
||||
PHINode *OldPN = Node.first;
|
||||
OldPN->replaceAllUsesWith(PoisonValue::get(OldPN->getType()));
|
||||
InstInfoMap.erase(OldPN);
|
||||
OldPN->eraseFromParent();
|
||||
}
|
||||
// Now we have expression graph turned into dag.
|
||||
|
@ -511,9 +512,6 @@ void TruncInstCombine::ReduceExpressionGraph(Type *SclTy) {
|
|||
// visit any of its operands, this way, when we get to the operand, we already
|
||||
// removed the instructions (from the expression dag) that uses it.
|
||||
for (auto &I : llvm::reverse(InstInfoMap)) {
|
||||
// Skip phi-nodes since they were erased before
|
||||
if (isa<PHINode>(I.first))
|
||||
continue;
|
||||
// We still need to check that the instruction has no users before we erase
|
||||
// it, because {SExt, ZExt}Inst Instruction might have other users that was
|
||||
// not reduced, in such case, we need to keep that instruction.
|
||||
|
|
Loading…
Reference in New Issue