diff options
author | Max Kazantsev <max.kazantsev@azul.com> | 2018-10-16 07:50:14 +0000 |
---|---|---|
committer | Max Kazantsev <max.kazantsev@azul.com> | 2018-10-16 07:50:14 +0000 |
commit | 6a4f5e2addbddf32c54329d4e91aa830cd204e0f (patch) | |
tree | 6b380c08e9db817afe2f27f935a21e8f242c5365 /llvm/lib/Analysis/MustExecute.cpp | |
parent | c8466f937cc2dbc80412dcfcb1051bf74f399a80 (diff) | |
download | bcm5719-llvm-6a4f5e2addbddf32c54329d4e91aa830cd204e0f.tar.gz bcm5719-llvm-6a4f5e2addbddf32c54329d4e91aa830cd204e0f.zip |
[NFC] Move block throw check inside allLoopPathsLeadToBlock
llvm-svn: 344588
Diffstat (limited to 'llvm/lib/Analysis/MustExecute.cpp')
-rw-r--r-- | llvm/lib/Analysis/MustExecute.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/llvm/lib/Analysis/MustExecute.cpp b/llvm/lib/Analysis/MustExecute.cpp index 7c1ce86d15b..7f0912de26b 100644 --- a/llvm/lib/Analysis/MustExecute.cpp +++ b/llvm/lib/Analysis/MustExecute.cpp @@ -26,6 +26,11 @@ bool LoopSafetyInfo::headerMayThrow() const { return HeaderMayThrow; } +bool LoopSafetyInfo::blockMayThrow(const BasicBlock *BB) const { + (void)BB; + return anyBlockMayThrow(); +} + bool LoopSafetyInfo::anyBlockMayThrow() const { return MayThrow; } @@ -148,7 +153,10 @@ bool LoopSafetyInfo::allLoopPathsLeadToBlock(const Loop *CurLoop, // 3) Exit blocks which are not taken on 1st iteration. // Memoize blocks we've already checked. SmallPtrSet<const BasicBlock *, 4> CheckedSuccessors; - for (auto *Pred : Predecessors) + for (auto *Pred : Predecessors) { + // Predecessor block may throw, so it has a side exit. + if (blockMayThrow(Pred)) + return false; for (auto *Succ : successors(Pred)) if (CheckedSuccessors.insert(Succ).second && Succ != BB && !Predecessors.count(Succ)) @@ -169,6 +177,7 @@ bool LoopSafetyInfo::allLoopPathsLeadToBlock(const Loop *CurLoop, if (CurLoop->contains(Succ) || !CanProveNotTakenFirstIteration(Succ, DT, CurLoop)) return false; + } // All predecessors can only lead us to BB. return true; @@ -194,11 +203,6 @@ bool LoopSafetyInfo::isGuaranteedToExecute(const Instruction &Inst, return !headerMayThrow() || Inst.getParent()->getFirstNonPHIOrDbg() == &Inst; - // Somewhere in this loop there is an instruction which may throw and make us - // exit the loop. - if (anyBlockMayThrow()) - return false; - // If there is a path from header to exit or latch that doesn't lead to our // instruction's block, return false. if (!allLoopPathsLeadToBlock(CurLoop, Inst.getParent(), DT)) |