Author: Roman Lebedev Date: 2021-01-08T02:15:26+03:00 New Revision: 05adc73db053fd79e64901e359e6ee783d772a80
URL: https://github.com/llvm/llvm-project/commit/05adc73db053fd79e64901e359e6ee783d772a80 DIFF: https://github.com/llvm/llvm-project/commit/05adc73db053fd79e64901e359e6ee783d772a80.diff LOG: [SimplifyCFG] changeToUnreachable(): switch to non-permissive DomTree updates ... which requires not deleting edges that were just deleted already, by not processing the same predecessor more than once. Added: Modified: llvm/lib/Transforms/Utils/Local.cpp Removed: ################################################################################ diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp index 220a4d43b491..5b9d5d343d7f 100644 --- a/llvm/lib/Transforms/Utils/Local.cpp +++ b/llvm/lib/Transforms/Utils/Local.cpp @@ -2025,19 +2025,18 @@ unsigned llvm::changeToUnreachable(Instruction *I, bool UseLLVMTrap, bool PreserveLCSSA, DomTreeUpdater *DTU, MemorySSAUpdater *MSSAU) { BasicBlock *BB = I->getParent(); - std::vector <DominatorTree::UpdateType> Updates; if (MSSAU) MSSAU->changeToUnreachable(I); + SmallSetVector<BasicBlock *, 8> UniqueSuccessors; + // Loop over all of the successors, removing BB's entry from any PHI // nodes. - if (DTU) - Updates.reserve(BB->getTerminator()->getNumSuccessors()); for (BasicBlock *Successor : successors(BB)) { Successor->removePredecessor(BB, PreserveLCSSA); if (DTU) - Updates.push_back({DominatorTree::Delete, BB, Successor}); + UniqueSuccessors.insert(Successor); } // Insert a call to llvm.trap right before this. This turns the undefined // behavior into a hard fail instead of falling through into random code. @@ -2059,8 +2058,13 @@ unsigned llvm::changeToUnreachable(Instruction *I, bool UseLLVMTrap, BB->getInstList().erase(BBI++); ++NumInstrsRemoved; } - if (DTU) - DTU->applyUpdatesPermissive(Updates); + if (DTU) { + SmallVector<DominatorTree::UpdateType, 8> Updates; + Updates.reserve(UniqueSuccessors.size()); + for (BasicBlock *UniqueSuccessor : UniqueSuccessors) + Updates.push_back({DominatorTree::Delete, BB, UniqueSuccessor}); + DTU->applyUpdates(Updates); + } return NumInstrsRemoved; } _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits