diff options
Diffstat (limited to 'llvm/lib/Analysis/MustExecute.cpp')
-rw-r--r-- | llvm/lib/Analysis/MustExecute.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/MustExecute.cpp b/llvm/lib/Analysis/MustExecute.cpp index ece4a1695cf..1e922fd44c4 100644 --- a/llvm/lib/Analysis/MustExecute.cpp +++ b/llvm/lib/Analysis/MustExecute.cpp @@ -109,8 +109,11 @@ bool llvm::isGuaranteedToExecute(const Instruction &Inst, // is a common case, and can save some work, check it now. if (Inst.getParent() == CurLoop->getHeader()) // If there's a throw in the header block, we can't guarantee we'll reach - // Inst. - return !SafetyInfo->HeaderMayThrow; + // Inst unless we can prove that Inst comes before the potential implicit + // exit. At the moment, we use a (cheap) hack for the common case where + // the instruction of interest is the first one in the block. + return !SafetyInfo->HeaderMayThrow || + Inst.getParent()->getFirstNonPHI() == &Inst; // Somewhere in this loop there is an instruction which may throw and make us // exit the loop. |