[PATCH] D78517: [PowerPC][Future] Remove "unskipableSimplifyCode()" in PPCMIPeephole.cpp
Victor Huang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 27 12:58:34 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG64d44ae7c2de: [PowerPC][Future] Remove "unskipableSimplifyCode()" in PPCMIPeephole.cpp (authored by NeHuang).
Changed prior to commit:
https://reviews.llvm.org/D78517?vs=260405&id=260426#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D78517/new/
https://reviews.llvm.org/D78517
Files:
llvm/lib/Target/PowerPC/PPCMIPeephole.cpp
Index: llvm/lib/Target/PowerPC/PPCMIPeephole.cpp
===================================================================
--- llvm/lib/Target/PowerPC/PPCMIPeephole.cpp
+++ llvm/lib/Target/PowerPC/PPCMIPeephole.cpp
@@ -57,8 +57,6 @@
"Number of pairs of rotate left, clear left/right collapsed");
STATISTIC(NumEXTSWAndSLDICombined,
"Number of pairs of EXTSW and SLDI combined as EXTSWSLI");
-STATISTIC(NumX2FoundForPCRel, "Number of times the X2 TOC pointer has been "
- "found when PC relative NOTOC is being used.");
static cl::opt<bool>
FixedPointRegToImm("ppc-reg-to-imm-fixed-point", cl::Hidden, cl::init(true),
@@ -101,11 +99,6 @@
// Initialize class variables.
void initialize(MachineFunction &MFParm);
- // Perform peepholes that cannot be skipped.
- // Some peephole simplifications are required for correctness and will not
- // be skipped even if skipFunction(MF.getFunction()) returns true.
- void unskipableSimplifyCode(void);
-
// Perform peepholes.
bool simplifyCode(void);
@@ -132,11 +125,11 @@
// Main entry point for this pass.
bool runOnMachineFunction(MachineFunction &MF) override {
initialize(MF);
- // FIXME: This introduces another complete traversal of the instructions
- // in the function in the common case (function is not skipped). Although
- // this is less than ideal for compile time, this code will go away once
- // our PC-Rel implementation is complete.
- unskipableSimplifyCode();
+ // At this point, TOC pointer should not be used in a function that uses
+ // PC-Relative addressing.
+ assert((MF.getRegInfo().use_empty(PPC::X2) ||
+ !MF.getSubtarget<PPCSubtarget>().isUsingPCRelativeCalls()) &&
+ "TOC pointer used in a function using PC-Relative addressing!");
if (skipFunction(MF.getFunction()))
return false;
return simplifyCode();
@@ -272,41 +265,6 @@
TOCSaves[MI] = Keep;
}
-void PPCMIPeephole::unskipableSimplifyCode(void) {
- // If this function has no uses of R2 there is nothing to do here.
- if(MF->getRegInfo().use_empty(PPC::X2))
- return;
-
- // This is only for PCRelative calls.
- if (!MF->getSubtarget<PPCSubtarget>().isUsingPCRelativeCalls()) {
- return;
- }
-
- // This function has R2 so we need to mark an implicit def for it.
- PPCFunctionInfo *FuncInfo = MF->getInfo<PPCFunctionInfo>();
- FuncInfo->setUsesTOCBasePtr();
- for (MachineBasicBlock &MBB : *MF) {
- for (MachineInstr &MI : MBB) {
- if (MI.getOpcode() == PPC::BL8_NOTOC) {
- // At this point the BL8_NOTOC instruction is not really safe because it
- // assumes that the caller does not need the TOC. It will be safe
- // later once the full PC relative implementation is complete but it is
- // not now.
- // Here we are looking for X2. Since this is Pre-RA the only uses of X2
- // would indicate the use of the TOC. We want to detect all uses of the
- // TOC. Once the work is done we should not see any uses of the TOC.
- // TODO: Once the implementation is complete this should be turned into
- // an assert
- Register Reg = MF->getSubtarget<PPCSubtarget>().getTOCPointerRegister();
- MachineOperand MO = MachineOperand::CreateReg(Reg, false, true);
- MI.addOperand(*MF, MO);
- MI.setDesc(TII->get(PPC::BL8_NOP));
- ++NumX2FoundForPCRel;
- }
- }
- }
-}
-
// Perform peephole optimizations.
bool PPCMIPeephole::simplifyCode(void) {
bool Simplified = false;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78517.260426.patch
Type: text/x-patch
Size: 3565 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200427/3687a485/attachment.bin>
More information about the llvm-commits
mailing list