summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
diff options
context:
space:
mode:
authorHal Finkel <hfinkel@anl.gov>2013-04-08 16:24:03 +0000
committerHal Finkel <hfinkel@anl.gov>2013-04-08 16:24:03 +0000
commitb5aa7e54d9e16a7c7282d78387a057ae74daa877 (patch)
tree4f16dddd1d4735ecc80f11cbcf53fc4ec1a79e3b /llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
parentc03f2ee0ae5efa1a6aa4ac06cc4575a8fd0bd356 (diff)
downloadbcm5719-llvm-b5aa7e54d9e16a7c7282d78387a057ae74daa877.tar.gz
bcm5719-llvm-b5aa7e54d9e16a7c7282d78387a057ae74daa877.zip
Generate PPC early conditional returns
PowerPC has a conditional branch to the link register (return) instruction: BCLR. This should be used any time when we'd otherwise have a conditional branch to a return. This adds a small pass, PPCEarlyReturn, which runs just prior to the branch selection pass (and, importantly, after block placement) to generate these conditional returns when possible. It will also eliminate unconditional branches to returns (these happen rarely; most of the time these have already been tail duplicated by the time PPCEarlyReturn is invoked). This is a nice optimization for small functions that do not maintain a stack frame. llvm-svn: 179026
Diffstat (limited to 'llvm/lib/Target/PowerPC/PPCTargetMachine.cpp')
-rw-r--r--llvm/lib/Target/PowerPC/PPCTargetMachine.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp b/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
index 59c82f6cc99..caf5c983066 100644
--- a/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
+++ b/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
@@ -124,6 +124,8 @@ bool PPCPassConfig::addInstSelector() {
}
bool PPCPassConfig::addPreEmitPass() {
+ if (getOptLevel() != CodeGenOpt::None)
+ addPass(createPPCEarlyReturnPass());
// Must run branch selection immediately preceding the asm printer.
addPass(createPPCBranchSelectionPass());
return false;
OpenPOWER on IntegriCloud