From: Anton Afanasyev Date: Fri, 25 Feb 2022 05:04:11 +0000 (+0300) Subject: [AggressiveInstCombine] Fix `TruncInstCombine` (fix f84d732f) X-Git-Tag: upstream/15.0.7~15323 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=904a00d17ae60718f54d587db8b394f590efbdc3;p=platform%2Fupstream%2Fllvm.git [AggressiveInstCombine] Fix `TruncInstCombine` (fix f84d732f) Erase phi-nodes from `InstInfoMap` before erasing themselves --- diff --git a/llvm/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp b/llvm/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp index 71f3d76..a446696 100644 --- a/llvm/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp +++ b/llvm/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp @@ -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(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.