aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/llvm/Analysis/LoopInfo.h3
-rw-r--r--lib/Analysis/LoopInfo.cpp16
-rw-r--r--lib/Transforms/Utils/LCSSA.cpp2
3 files changed, 21 insertions, 0 deletions
diff --git a/include/llvm/Analysis/LoopInfo.h b/include/llvm/Analysis/LoopInfo.h
index 06b007c..17363df 100644
--- a/include/llvm/Analysis/LoopInfo.h
+++ b/include/llvm/Analysis/LoopInfo.h
@@ -146,6 +146,9 @@ public:
/// this returns null.
///
Value *getTripCount() const;
+
+ /// isLCSSAForm - Return true if the Loop is in LCSSA form
+ bool isLCSSAForm() const;
//===--------------------------------------------------------------------===//
// APIs for updating loop information after changing the CFG
diff --git a/lib/Analysis/LoopInfo.cpp b/lib/Analysis/LoopInfo.cpp
index c7ce58e..eed2cd6 100644
--- a/lib/Analysis/LoopInfo.cpp
+++ b/lib/Analysis/LoopInfo.cpp
@@ -479,6 +479,22 @@ Value *Loop::getTripCount() const {
return 0;
}
+/// isLCSSAForm - Return true if the Loop is in LCSSA form
+bool Loop::isLCSSAForm() const {
+ for (Loop::block_iterator BB = block_begin(), E = block_end();
+ BB != E; ++BB) {
+ for (BasicBlock::iterator I = (*BB)->begin(), E = (*BB)->end(); I != E; ++I)
+ for (Value::use_iterator UI = I->use_begin(), E = I->use_end(); UI != E;
+ ++UI) {
+ BasicBlock *UserBB = cast<Instruction>(*UI)->getParent();
+ if (!isa<PHINode>(*UI) && !contains(UserBB)) {
+ return false;
+ }
+ }
+ }
+
+ return true;
+}
//===-------------------------------------------------------------------===//
// APIs for updating loop information after changing the CFG
diff --git a/lib/Transforms/Utils/LCSSA.cpp b/lib/Transforms/Utils/LCSSA.cpp
index e1af50e..ed02c97 100644
--- a/lib/Transforms/Utils/LCSSA.cpp
+++ b/lib/Transforms/Utils/LCSSA.cpp
@@ -132,6 +132,8 @@ bool LCSSA::visitSubloop(Loop* L) {
processInstruction(*I, exitBlocks);
}
+ assert(L->isLCSSAForm());
+
return true;
}