mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-19 02:52:53 +02:00
RISCV: Don't store function in RISCVMachineFunctionInfo
Targets should not depend on the MachineFunction state during the MachineFunctionInfo construction.
This commit is contained in:
parent
8215de3621
commit
6494b099e2
@ -31,7 +31,7 @@ static int getLibCallID(const MachineFunction &MF,
|
||||
const std::vector<CalleeSavedInfo> &CSI) {
|
||||
const auto *RVFI = MF.getInfo<RISCVMachineFunctionInfo>();
|
||||
|
||||
if (CSI.empty() || !RVFI->useSaveRestoreLibCalls())
|
||||
if (CSI.empty() || !RVFI->useSaveRestoreLibCalls(MF))
|
||||
return -1;
|
||||
|
||||
Register MaxReg = RISCV::NoRegister;
|
||||
@ -731,9 +731,10 @@ bool RISCVFrameLowering::restoreCalleeSavedRegisters(
|
||||
|
||||
bool RISCVFrameLowering::canUseAsPrologue(const MachineBasicBlock &MBB) const {
|
||||
MachineBasicBlock *TmpMBB = const_cast<MachineBasicBlock *>(&MBB);
|
||||
const auto *RVFI = MBB.getParent()->getInfo<RISCVMachineFunctionInfo>();
|
||||
const MachineFunction *MF = MBB.getParent();
|
||||
const auto *RVFI = MF->getInfo<RISCVMachineFunctionInfo>();
|
||||
|
||||
if (!RVFI->useSaveRestoreLibCalls())
|
||||
if (!RVFI->useSaveRestoreLibCalls(*MF))
|
||||
return true;
|
||||
|
||||
// Inserting a call to a __riscv_save libcall requires the use of the register
|
||||
@ -746,10 +747,11 @@ bool RISCVFrameLowering::canUseAsPrologue(const MachineBasicBlock &MBB) const {
|
||||
}
|
||||
|
||||
bool RISCVFrameLowering::canUseAsEpilogue(const MachineBasicBlock &MBB) const {
|
||||
const MachineFunction *MF = MBB.getParent();
|
||||
MachineBasicBlock *TmpMBB = const_cast<MachineBasicBlock *>(&MBB);
|
||||
const auto *RVFI = MBB.getParent()->getInfo<RISCVMachineFunctionInfo>();
|
||||
const auto *RVFI = MF->getInfo<RISCVMachineFunctionInfo>();
|
||||
|
||||
if (!RVFI->useSaveRestoreLibCalls())
|
||||
if (!RVFI->useSaveRestoreLibCalls(*MF))
|
||||
return true;
|
||||
|
||||
// Using the __riscv_restore libcalls to restore CSRs requires a tail call.
|
||||
|
@ -1234,7 +1234,7 @@ static MachineBasicBlock *emitSplitF64Pseudo(MachineInstr &MI,
|
||||
Register HiReg = MI.getOperand(1).getReg();
|
||||
Register SrcReg = MI.getOperand(2).getReg();
|
||||
const TargetRegisterClass *SrcRC = &RISCV::FPR64RegClass;
|
||||
int FI = MF.getInfo<RISCVMachineFunctionInfo>()->getMoveF64FrameIndex();
|
||||
int FI = MF.getInfo<RISCVMachineFunctionInfo>()->getMoveF64FrameIndex(MF);
|
||||
|
||||
TII.storeRegToStackSlot(*BB, MI, SrcReg, MI.getOperand(2).isKill(), FI, SrcRC,
|
||||
RI);
|
||||
@ -1266,7 +1266,7 @@ static MachineBasicBlock *emitBuildPairF64Pseudo(MachineInstr &MI,
|
||||
Register LoReg = MI.getOperand(1).getReg();
|
||||
Register HiReg = MI.getOperand(2).getReg();
|
||||
const TargetRegisterClass *DstRC = &RISCV::FPR64RegClass;
|
||||
int FI = MF.getInfo<RISCVMachineFunctionInfo>()->getMoveF64FrameIndex();
|
||||
int FI = MF.getInfo<RISCVMachineFunctionInfo>()->getMoveF64FrameIndex(MF);
|
||||
|
||||
MachineMemOperand *MMO =
|
||||
MF.getMachineMemOperand(MachinePointerInfo::getFixedStack(MF, FI),
|
||||
|
@ -23,7 +23,6 @@ namespace llvm {
|
||||
/// and contains private RISCV-specific information for each MachineFunction.
|
||||
class RISCVMachineFunctionInfo : public MachineFunctionInfo {
|
||||
private:
|
||||
MachineFunction &MF;
|
||||
/// FrameIndex for start of varargs area
|
||||
int VarArgsFrameIndex = 0;
|
||||
/// Size of the save area used for varargs
|
||||
@ -35,7 +34,7 @@ private:
|
||||
unsigned LibCallStackSize = 0;
|
||||
|
||||
public:
|
||||
RISCVMachineFunctionInfo(MachineFunction &MF) : MF(MF) {}
|
||||
RISCVMachineFunctionInfo(const MachineFunction &MF) {}
|
||||
|
||||
int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
|
||||
void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; }
|
||||
@ -43,7 +42,7 @@ public:
|
||||
unsigned getVarArgsSaveSize() const { return VarArgsSaveSize; }
|
||||
void setVarArgsSaveSize(int Size) { VarArgsSaveSize = Size; }
|
||||
|
||||
int getMoveF64FrameIndex() {
|
||||
int getMoveF64FrameIndex(MachineFunction &MF) {
|
||||
if (MoveF64FrameIndex == -1)
|
||||
MoveF64FrameIndex = MF.getFrameInfo().CreateStackObject(8, 8, false);
|
||||
return MoveF64FrameIndex;
|
||||
@ -52,7 +51,7 @@ public:
|
||||
unsigned getLibCallStackSize() const { return LibCallStackSize; }
|
||||
void setLibCallStackSize(unsigned Size) { LibCallStackSize = Size; }
|
||||
|
||||
bool useSaveRestoreLibCalls() const {
|
||||
bool useSaveRestoreLibCalls(const MachineFunction &MF) const {
|
||||
// We cannot use fixed locations for the callee saved spill slots if the
|
||||
// function uses a varargs save area.
|
||||
return MF.getSubtarget<RISCVSubtarget>().enableSaveRestore() &&
|
||||
|
@ -128,7 +128,7 @@ bool RISCVRegisterInfo::hasReservedSpillSlot(const MachineFunction &MF,
|
||||
Register Reg,
|
||||
int &FrameIdx) const {
|
||||
const auto *RVFI = MF.getInfo<RISCVMachineFunctionInfo>();
|
||||
if (!RVFI->useSaveRestoreLibCalls())
|
||||
if (!RVFI->useSaveRestoreLibCalls(MF))
|
||||
return false;
|
||||
|
||||
auto FII = FixedCSRFIMap.find(Reg);
|
||||
|
Loading…
Reference in New Issue
Block a user