diff options
author | Max Kazantsev <mkazantsev@azul.com> | 2021-10-08 17:54:27 +0700 |
---|---|---|
committer | Max Kazantsev <mkazantsev@azul.com> | 2021-10-08 17:54:27 +0700 |
commit | d68b59f3ebb253ee7119a25a71c51cf19b73e030 (patch) | |
tree | a81947150a558e7812a67e8c02ba14356137e5cc /llvm/lib/Transforms/Utils/BasicBlockUtils.cpp | |
parent | 30caca39f401ae17927439c0a0bd6d1b1916dd6a (diff) | |
download | llvm-d68b59f3ebb253ee7119a25a71c51cf19b73e030.zip llvm-d68b59f3ebb253ee7119a25a71c51cf19b73e030.tar.gz llvm-d68b59f3ebb253ee7119a25a71c51cf19b73e030.tar.bz2 |
Recommit "[LoopPeel] Peel loops with deoptimizing exits"
Removed obsolete DT verification that should not be there because the
strategy of DT updates has changed.
Differential Revision: https://reviews.llvm.org/D110922
Diffstat (limited to 'llvm/lib/Transforms/Utils/BasicBlockUtils.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/BasicBlockUtils.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp index 1a07697..de6c2af 100644 --- a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp +++ b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp @@ -39,6 +39,7 @@ #include "llvm/IR/Value.h" #include "llvm/IR/ValueHandle.h" #include "llvm/Support/Casting.h" +#include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Transforms/Utils/Local.h" @@ -52,6 +53,11 @@ using namespace llvm; #define DEBUG_TYPE "basicblock-utils" +static cl::opt<unsigned> MaxDeoptimizingCheckDepth( + "max-deopt-check-depth", cl::init(8), cl::Hidden, + cl::desc("Set the maximum path length when checking whether a basic block " + "is deoptimizing")); + void llvm::DetatchDeadBlocks( ArrayRef<BasicBlock *> BBs, SmallVectorImpl<DominatorTree::UpdateType> *Updates, @@ -485,6 +491,20 @@ void llvm::ReplaceInstWithInst(BasicBlock::InstListType &BIL, BI = New; } +bool llvm::IsBlockFollowedByDeoptOrUnreachable(const BasicBlock *BB) { + // Remember visited blocks to avoid infinite loop + SmallPtrSet<const BasicBlock *, 8> VisitedBlocks; + unsigned Depth = 0; + while (BB && Depth++ < MaxDeoptimizingCheckDepth && + VisitedBlocks.insert(BB).second) { + if (BB->getTerminatingDeoptimizeCall() || + isa<UnreachableInst>(BB->getTerminator())) + return true; + BB = BB->getSingleSuccessor(); + } + return false; +} + void llvm::ReplaceInstWithInst(Instruction *From, Instruction *To) { BasicBlock::iterator BI(From); ReplaceInstWithInst(From->getParent()->getInstList(), BI, To); |