[PATCH] D14778: [PPC64] Enable shrink wrapping for PPC64 LE.
Kit Barton via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 18 08:37:05 PST 2015
kbarton created this revision.
kbarton added reviewers: hfinkel, nemanjai, seurer, qcolombet.
kbarton added a subscriber: llvm-commits.
Re-enable shrink wrapping for PPC64 Little Endian.
One minor modification to PPCFrameLowering::findScratchRegister was necessary to handle fall-thru blocks (blocks with no terminator) correctly.
Tested with all LLVM test, clang tests, and the self-hosting build, with no problems found.
http://reviews.llvm.org/D14778
Files:
lib/Target/PowerPC/PPCFrameLowering.cpp
test/CodeGen/PowerPC/ppc-shrink-wrapping.ll
Index: test/CodeGen/PowerPC/ppc-shrink-wrapping.ll
===================================================================
--- test/CodeGen/PowerPC/ppc-shrink-wrapping.ll
+++ test/CodeGen/PowerPC/ppc-shrink-wrapping.ll
@@ -1,6 +1,5 @@
; RUN: llc -mtriple=powerpc64le-unknown-linux-gnu -mcpu=pwr8 %s -o - | FileCheck %s --check-prefix=CHECK --check-prefix=ENABLE
; RUN: llc -mtriple=powerpc64le-unknown-linux-gnu %s -o - -enable-shrink-wrap=false | FileCheck %s --check-prefix=CHECK --check-prefix=DISABLE
-; XFAIL: *
;
; Note: Lots of tests use inline asm instead of regular calls.
; This allows to have a better control on what the allocation will do.
Index: lib/Target/PowerPC/PPCFrameLowering.cpp
===================================================================
--- lib/Target/PowerPC/PPCFrameLowering.cpp
+++ lib/Target/PowerPC/PPCFrameLowering.cpp
@@ -573,10 +573,18 @@
RS.initRegState();
RS.enterBasicBlock(MBB);
- // The scratch register will be used at the end of the block, so must consider
- // all registers used within the block
- if (UseAtEnd && MBB->begin() != MBB->getFirstTerminator())
- RS.forward(MBB->getFirstTerminator());
+ if (UseAtEnd && !MBB->empty()) {
+ // The scratch register will be used at the end of the block, so must consider
+ // all registers used within the block
+
+ MachineBasicBlock::iterator MBBI = MBB->getFirstTerminator();
+ // If no terminator, back iterator up to previous instruction
+ if (MBBI == MBB->end())
+ MBBI = std::prev(MBBI);
+
+ if (MBBI != MBB->begin())
+ RS.forward(MBBI);
+ }
if (!RS.isRegUsed(R0))
return true;
@@ -1768,6 +1776,6 @@
}
bool PPCFrameLowering::enableShrinkWrapping(const MachineFunction &MF) const {
- // FIXME: Enable this for non-Darwin PPC64 once it is confirmed working.
- return false;
+ return (MF.getSubtarget<PPCSubtarget>().isSVR4ABI() &&
+ MF.getSubtarget<PPCSubtarget>().isPPC64());
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14778.40517.patch
Type: text/x-patch
Size: 1950 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151118/fce71780/attachment.bin>
More information about the llvm-commits
mailing list