diff options
author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2010-02-05 23:21:31 +0000 |
---|---|---|
committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2010-02-05 23:21:31 +0000 |
commit | d450e5b88662557f2965331f06277d60266a9eec (patch) | |
tree | 7568c3660c39341a354fa202e975f7b1ca37e625 /lib/Transforms/Scalar/LoopUnrollPass.cpp | |
parent | aa034fa2299e41b73f60d3993f5460260e239fab (diff) |
Don't unroll loops containing function calls.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95454 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/LoopUnrollPass.cpp')
-rw-r--r-- | lib/Transforms/Scalar/LoopUnrollPass.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/Transforms/Scalar/LoopUnrollPass.cpp b/lib/Transforms/Scalar/LoopUnrollPass.cpp index ee8cb4f9a7..a355ec3a7e 100644 --- a/lib/Transforms/Scalar/LoopUnrollPass.cpp +++ b/lib/Transforms/Scalar/LoopUnrollPass.cpp @@ -76,11 +76,12 @@ static RegisterPass<LoopUnroll> X("loop-unroll", "Unroll loops"); Pass *llvm::createLoopUnrollPass() { return new LoopUnroll(); } /// ApproximateLoopSize - Approximate the size of the loop. -static unsigned ApproximateLoopSize(const Loop *L) { +static unsigned ApproximateLoopSize(const Loop *L, unsigned &NumCalls) { CodeMetrics Metrics; for (Loop::block_iterator I = L->block_begin(), E = L->block_end(); I != E; ++I) Metrics.analyzeBasicBlock(*I); + NumCalls = Metrics.NumCalls; return Metrics.NumInsts; } @@ -110,8 +111,13 @@ bool LoopUnroll::runOnLoop(Loop *L, LPPassManager &LPM) { // Enforce the threshold. if (UnrollThreshold != NoThreshold) { - unsigned LoopSize = ApproximateLoopSize(L); + unsigned NumCalls; + unsigned LoopSize = ApproximateLoopSize(L, NumCalls); DEBUG(dbgs() << " Loop Size = " << LoopSize << "\n"); + if (NumCalls != 0) { + DEBUG(dbgs() << " Not unrolling loop with function calls.\n"); + return false; + } uint64_t Size = (uint64_t)LoopSize*Count; if (TripCount != 1 && Size > UnrollThreshold) { DEBUG(dbgs() << " Too large to fully unroll with count: " << Count |