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/LoopRotation.cpp | |
| parent | 3b42bdd58ae3c5ea61afe2f13adbb216ef79dd65 (diff) | |
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/LoopRotation.cpp')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/LoopRotation.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopRotation.cpp b/llvm/lib/Transforms/Scalar/LoopRotation.cpp index 249baf51645f..83e049b94c24 100644 --- a/llvm/lib/Transforms/Scalar/LoopRotation.cpp +++ b/llvm/lib/Transforms/Scalar/LoopRotation.cpp @@ -274,10 +274,16 @@ bool LoopRotate::rotateLoop(Loop *L) { if (OrigLatch == 0 || L->isLoopExiting(OrigLatch)) return false; - // Check size of original header and reject loop if it is very big. + // Check size of original header and reject loop if it is very big or we can't + // duplicate blocks inside it. { CodeMetrics Metrics; Metrics.analyzeBasicBlock(OrigHeader); + if (Metrics.notDuplicatable) { + DEBUG(dbgs() << "LoopRotation: NOT rotating - contains non duplicatable" + << " instructions: "; L->dump()); + return false; + } if (Metrics.NumInsts > MAX_HEADER_SIZE) return false; } |
