summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils/LoopUnroll.cpp
diff options
context:
space:
mode:
authorAndrew Trick <atrick@apple.com>2012-04-10 05:14:42 +0000
committerAndrew Trick <atrick@apple.com>2012-04-10 05:14:42 +0000
commit4442bfe55931923ae829c22e99de658b2b210436 (patch)
tree521882feee51439c1dffc4a333280dbb8fe73d8c /llvm/lib/Transforms/Utils/LoopUnroll.cpp
parent4104ed9c76d0a275c62e2bafd1fda704b782bfaf (diff)
downloadbcm5719-llvm-4442bfe55931923ae829c22e99de658b2b210436.tar.gz
bcm5719-llvm-4442bfe55931923ae829c22e99de658b2b210436.zip
Fix 12513: Loop unrolling breaks with indirect branches.
Take this opportunity to generalize the indirectbr bailout logic for loop transformations. CFG transformations will never get indirectbr right, and there's no point trying. llvm-svn: 154386
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopUnroll.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/LoopUnroll.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopUnroll.cpp b/llvm/lib/Transforms/Utils/LoopUnroll.cpp
index 512b6895011..e15497a77ae 100644
--- a/llvm/lib/Transforms/Utils/LoopUnroll.cpp
+++ b/llvm/lib/Transforms/Utils/LoopUnroll.cpp
@@ -149,6 +149,12 @@ bool llvm::UnrollLoop(Loop *L, unsigned Count, unsigned TripCount,
return false;
}
+ // Loops with indirectbr cannot be cloned.
+ if (!L->isSafeToClone()) {
+ DEBUG(dbgs() << " Can't unroll; Loop body cannot be cloned.\n");
+ return false;
+ }
+
BasicBlock *Header = L->getHeader();
BranchInst *BI = dyn_cast<BranchInst>(LatchBlock->getTerminator());
OpenPOWER on IntegriCloud