aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/Local.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Transforms/Utils/Local.cpp')
-rw-r--r--lib/Transforms/Utils/Local.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/Transforms/Utils/Local.cpp b/lib/Transforms/Utils/Local.cpp
index c22485342e..aa6efe80b3 100644
--- a/lib/Transforms/Utils/Local.cpp
+++ b/lib/Transforms/Utils/Local.cpp
@@ -148,6 +148,23 @@ bool llvm::ConstantFoldTerminator(BasicBlock *BB) {
return false;
}
+//===----------------------------------------------------------------------===//
+// CFG Simplification
+//
+
+/// isTerminatorFirstRelevantInsn - Return true if Term is very first
+/// instruction ignoring Phi nodes and dbg intrinsics.
+bool llvm::isTerminatorFirstRelevantInsn(BasicBlock *BB, Instruction *Term) {
+ BasicBlock::iterator BBI = Term;
+ while (BBI != BB->begin()) {
+ --BBI;
+ if (!isa<DbgInfoIntrinsic>(BBI))
+ break;
+ }
+ if (isa<PHINode>(BBI) || &*BBI == Term)
+ return true;
+ return false;
+}
//===----------------------------------------------------------------------===//
// Local dead code elimination...