diff options
author | Hal Finkel <hfinkel@anl.gov> | 2013-04-08 16:24:03 +0000 |
---|---|---|
committer | Hal Finkel <hfinkel@anl.gov> | 2013-04-08 16:24:03 +0000 |
commit | b5aa7e54d9e16a7c7282d78387a057ae74daa877 (patch) | |
tree | 4f16dddd1d4735ecc80f11cbcf53fc4ec1a79e3b /llvm/lib/Target/PowerPC/PPCTargetMachine.cpp | |
parent | c03f2ee0ae5efa1a6aa4ac06cc4575a8fd0bd356 (diff) | |
download | bcm5719-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.cpp | 2 |
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; |