From fbffd126b8cea0e6d249dce41850ce8ce0cf03bc Mon Sep 17 00:00:00 2001 From: Philip Reames Date: Thu, 8 Mar 2018 21:25:30 +0000 Subject: [NFC] Factor out a helper function for checking if a block has a potential early implicit exit. llvm-svn: 327065 --- llvm/lib/Analysis/ValueTracking.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'llvm/lib/Analysis') diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index c132586d874..2ec9cc11493 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -3968,6 +3968,15 @@ bool llvm::isGuaranteedToTransferExecutionToSuccessor(const Instruction *I) { return true; } +bool llvm::isGuaranteedToTransferExecutionToSuccessor(const BasicBlock *BB) { + // TODO: This is slightly consdervative for invoke instruction since exiting + // via an exception *is* normal control for them. + for (auto I = BB->begin(), E = BB->end(); I != E; ++I) + if (!isGuaranteedToTransferExecutionToSuccessor(&*I)) + return false; + return true; +} + bool llvm::isGuaranteedToExecuteForEveryIteration(const Instruction *I, const Loop *L) { // The loop header is guaranteed to be executed for every iteration. -- cgit v1.2.3