diff options
| author | James Molloy <james.molloy@arm.com> | 2012-12-20 16:04:27 +0000 |
|---|---|---|
| committer | James Molloy <james.molloy@arm.com> | 2012-12-20 16:04:27 +0000 |
| commit | 4f6fb953a7597cf617005582e26e2c71ed7cbaa5 (patch) | |
| tree | 1d3c47d0896c06d408edea3ec9d5dd4ce37b44d4 /llvm/lib/Transforms/Scalar/LoopUnswitch.cpp | |
| parent | 3b42bdd58ae3c5ea61afe2f13adbb216ef79dd65 (diff) | |
| download | bcm5719-llvm-4f6fb953a7597cf617005582e26e2c71ed7cbaa5.tar.gz bcm5719-llvm-4f6fb953a7597cf617005582e26e2c71ed7cbaa5.zip | |
Add a new attribute, 'noduplicate'. If a function contains a noduplicate call, the call cannot be duplicated - Jump threading, loop unrolling, loop unswitching, and loop rotation are inhibited if they would duplicate the call.
Similarly inlining of the function is inhibited, if that would duplicate the call (in particular inlining is still allowed when there is only one callsite and the function has internal linkage).
llvm-svn: 170704
Diffstat (limited to 'llvm/lib/Transforms/Scalar/LoopUnswitch.cpp')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/LoopUnswitch.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp b/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp index 17ffda60fdf..e2e42e5054f 100644 --- a/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp +++ b/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp @@ -248,6 +248,13 @@ bool LUAnalysisCache::countLoop(const Loop* L) { Props.SizeEstimation = std::min(Metrics.NumInsts, Metrics.NumBlocks * 5); Props.CanBeUnswitchedCount = MaxSize / (Props.SizeEstimation); MaxSize -= Props.SizeEstimation * Props.CanBeUnswitchedCount; + + if (Metrics.notDuplicatable) { + DEBUG(dbgs() << "NOT unswitching loop %" + << L->getHeader()->getName() << ", contents cannot be " + << "duplicated!\n"); + return false; + } } if (!Props.CanBeUnswitchedCount) { |

