From 9859759f10ad0701e7342bc95edc1e8dbf892a26 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Wed, 27 Mar 2019 16:37:31 +0000 Subject: [PATCH] PEI: Delay checking requiresFrameIndexReplacementScavenging Currently this is called before the frame size is set on the function. For AMDGPU, the scavenger is used for large frames where part of the offset needs to be materialized in a register, so estimating the frame size is useful for knowing whether the scavenger is useful. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357087 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/PrologEpilogInserter.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/CodeGen/PrologEpilogInserter.cpp b/lib/CodeGen/PrologEpilogInserter.cpp index f2b1802fff2..920a915552a 100644 --- a/lib/CodeGen/PrologEpilogInserter.cpp +++ b/lib/CodeGen/PrologEpilogInserter.cpp @@ -218,8 +218,6 @@ bool PEI::runOnMachineFunction(MachineFunction &MF) { RS = TRI->requiresRegisterScavenging(MF) ? new RegScavenger() : nullptr; FrameIndexVirtualScavenging = TRI->requiresFrameIndexScavenging(MF); - FrameIndexEliminationScavenging = (RS && !FrameIndexVirtualScavenging) || - TRI->requiresFrameIndexReplacementScavenging(MF); ORE = &getAnalysis().getORE(); // Calculate the MaxCallFrameSize and AdjustsStack variables for the @@ -1074,8 +1072,16 @@ void PEI::insertPrologEpilogCode(MachineFunction &MF) { /// replaceFrameIndices - Replace all MO_FrameIndex operands with physical /// register references and actual offsets. void PEI::replaceFrameIndices(MachineFunction &MF) { - const TargetFrameLowering &TFI = *MF.getSubtarget().getFrameLowering(); - if (!TFI.needsFrameIndexResolution(MF)) return; + const auto &ST = MF.getSubtarget(); + const TargetFrameLowering &TFI = *ST.getFrameLowering(); + if (!TFI.needsFrameIndexResolution(MF)) + return; + + const TargetRegisterInfo *TRI = ST.getRegisterInfo(); + + // Allow the target to determine this after knowing the frame size. + FrameIndexEliminationScavenging = (RS && !FrameIndexVirtualScavenging) || + TRI->requiresFrameIndexReplacementScavenging(MF); // Store SPAdj at exit of a basic block. SmallVector SPState; -- 2.11.0