[PATCH] D79785: [ARM] Register pressure with -mthumb forces register reload before each call
Prathamesh via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 8 04:52:11 PDT 2020
prathamesh updated this revision to Diff 269167.
prathamesh added a comment.
Hi John,
Thanks for the review and I am sorry for late response, I was on a leave.
I have the updated the patch with suggested changes, do they look in right direction ?
Testing with make check-llvm shows no unexpected failures.
Thanks,
Prathamesh
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D79785/new/
https://reviews.llvm.org/D79785
Files:
llvm/lib/Target/ARM/Thumb1InstrInfo.cpp
llvm/lib/Target/ARM/Thumb1InstrInfo.h
Index: llvm/lib/Target/ARM/Thumb1InstrInfo.h
===================================================================
--- llvm/lib/Target/ARM/Thumb1InstrInfo.h
+++ llvm/lib/Target/ARM/Thumb1InstrInfo.h
@@ -53,6 +53,13 @@
const TargetRegisterInfo *TRI) const override;
bool canCopyGluedNodeDuringSchedule(SDNode *N) const override;
+
+protected:
+ virtual MachineInstr *foldMemoryOperandImpl(
+ MachineFunction &MF, MachineInstr &MI, ArrayRef<unsigned> Ops,
+ MachineBasicBlock::iterator InsertPt, MachineInstr &LoadMI,
+ LiveIntervals *LIS = nullptr) const override;
+
private:
void expandLoadStackGuard(MachineBasicBlock::iterator MI) const override;
};
Index: llvm/lib/Target/ARM/Thumb1InstrInfo.cpp
===================================================================
--- llvm/lib/Target/ARM/Thumb1InstrInfo.cpp
+++ llvm/lib/Target/ARM/Thumb1InstrInfo.cpp
@@ -152,3 +152,35 @@
return false;
}
+
+MachineInstr *Thumb1InstrInfo::foldMemoryOperandImpl(
+ MachineFunction &MF, MachineInstr &MI, ArrayRef<unsigned> Ops,
+ MachineBasicBlock::iterator InsertPt, MachineInstr &LoadMI,
+ LiveIntervals *LIS) const {
+ // Replace:
+ // ldr Rd, func address
+ // blx Rd
+ // with:
+ // bl func
+
+ if (MI.getOpcode() == ARM::tBLXr && LoadMI.getOpcode() == ARM::tLDRpci &&
+ MI.getParent() == LoadMI.getParent()) {
+ unsigned CPI = LoadMI.getOperand(1).getIndex();
+ const MachineConstantPool *MCP = MF.getConstantPool();
+ const MachineConstantPoolEntry &CPE = MCP->getConstants()[CPI];
+ assert(!CPE.isMachineConstantPoolEntry() && "Invalid constpool entry");
+ const Constant *Callee = cast<Constant>(CPE.Val.ConstVal);
+ const char *FuncName = MF.createExternalSymbolName(Callee->getName());
+ MachineInstrBuilder MIB = BuildMI(*MI.getParent(), InsertPt, MI.getDebugLoc(), get(ARM::tBL))
+ .add(predOps(ARMCC::AL))
+ .addExternalSymbol(FuncName);
+ for (auto &MO: MI.implicit_operands())
+ if (MO.isReg())
+ MIB.addReg(MO.getReg(), RegState::Implicit | RegState::Kill);
+ else if (MO.isRegMask())
+ MIB.add(MO);
+ return MIB.getInstr();
+ }
+
+ return nullptr;
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79785.269167.patch
Type: text/x-patch
Size: 2267 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200608/7d9b6f9e/attachment.bin>
More information about the llvm-commits
mailing list