Skip to content

Commit f11be66

Browse files
authored
Revert "Spiller: Detach legacy pass and supply analyses instead (#119181)"
This reverts commit a531800.
1 parent 01a7d4e commit f11be66

File tree

5 files changed

+31
-46
lines changed

5 files changed

+31
-46
lines changed

llvm/include/llvm/CodeGen/Spiller.h

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ class MachineFunction;
1919
class MachineFunctionPass;
2020
class VirtRegMap;
2121
class VirtRegAuxInfo;
22-
class LiveIntervals;
23-
class LiveStacks;
24-
class MachineDominatorTree;
25-
class MachineBlockFrequencyInfo;
2622

2723
/// Spiller interface.
2824
///
@@ -45,20 +41,12 @@ class Spiller {
4541
virtual ArrayRef<Register> getReplacedRegs() = 0;
4642

4743
virtual void postOptimization() {}
48-
49-
struct RequiredAnalyses {
50-
LiveIntervals &LIS;
51-
LiveStacks &LSS;
52-
MachineDominatorTree &MDT;
53-
const MachineBlockFrequencyInfo &MBFI;
54-
};
5544
};
5645

5746
/// Create and return a spiller that will insert spill code directly instead
5847
/// of deferring though VirtRegMap.
59-
Spiller *createInlineSpiller(const Spiller::RequiredAnalyses &Analyses,
60-
MachineFunction &MF, VirtRegMap &VRM,
61-
VirtRegAuxInfo &VRAI);
48+
Spiller *createInlineSpiller(MachineFunctionPass &Pass, MachineFunction &MF,
49+
VirtRegMap &VRM, VirtRegAuxInfo &VRAI);
6250

6351
} // end namespace llvm
6452

llvm/lib/CodeGen/InlineSpiller.cpp

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ RestrictStatepointRemat("restrict-statepoint-remat",
7575
cl::desc("Restrict remat for statepoint operands"));
7676

7777
namespace {
78+
7879
class HoistSpillHelper : private LiveRangeEdit::Delegate {
7980
MachineFunction &MF;
8081
LiveIntervals &LIS;
@@ -127,11 +128,15 @@ class HoistSpillHelper : private LiveRangeEdit::Delegate {
127128
DenseMap<MachineBasicBlock *, unsigned> &SpillsToIns);
128129

129130
public:
130-
HoistSpillHelper(const Spiller::RequiredAnalyses &Analyses,
131-
MachineFunction &mf, VirtRegMap &vrm)
132-
: MF(mf), LIS(Analyses.LIS), LSS(Analyses.LSS), MDT(Analyses.MDT),
131+
HoistSpillHelper(MachineFunctionPass &pass, MachineFunction &mf,
132+
VirtRegMap &vrm)
133+
: MF(mf), LIS(pass.getAnalysis<LiveIntervalsWrapperPass>().getLIS()),
134+
LSS(pass.getAnalysis<LiveStacksWrapperLegacy>().getLS()),
135+
MDT(pass.getAnalysis<MachineDominatorTreeWrapperPass>().getDomTree()),
133136
VRM(vrm), MRI(mf.getRegInfo()), TII(*mf.getSubtarget().getInstrInfo()),
134-
TRI(*mf.getSubtarget().getRegisterInfo()), MBFI(Analyses.MBFI),
137+
TRI(*mf.getSubtarget().getRegisterInfo()),
138+
MBFI(
139+
pass.getAnalysis<MachineBlockFrequencyInfoWrapperPass>().getMBFI()),
135140
IPA(LIS, mf.getNumBlockIDs()) {}
136141

137142
void addToMergeableSpills(MachineInstr &Spill, int StackSlot,
@@ -185,12 +190,16 @@ class InlineSpiller : public Spiller {
185190
~InlineSpiller() override = default;
186191

187192
public:
188-
InlineSpiller(const Spiller::RequiredAnalyses &Analyses, MachineFunction &MF,
189-
VirtRegMap &VRM, VirtRegAuxInfo &VRAI)
190-
: MF(MF), LIS(Analyses.LIS), LSS(Analyses.LSS), MDT(Analyses.MDT),
193+
InlineSpiller(MachineFunctionPass &Pass, MachineFunction &MF, VirtRegMap &VRM,
194+
VirtRegAuxInfo &VRAI)
195+
: MF(MF), LIS(Pass.getAnalysis<LiveIntervalsWrapperPass>().getLIS()),
196+
LSS(Pass.getAnalysis<LiveStacksWrapperLegacy>().getLS()),
197+
MDT(Pass.getAnalysis<MachineDominatorTreeWrapperPass>().getDomTree()),
191198
VRM(VRM), MRI(MF.getRegInfo()), TII(*MF.getSubtarget().getInstrInfo()),
192-
TRI(*MF.getSubtarget().getRegisterInfo()), MBFI(Analyses.MBFI),
193-
HSpiller(Analyses, MF, VRM), VRAI(VRAI) {}
199+
TRI(*MF.getSubtarget().getRegisterInfo()),
200+
MBFI(
201+
Pass.getAnalysis<MachineBlockFrequencyInfoWrapperPass>().getMBFI()),
202+
HSpiller(Pass, MF, VRM), VRAI(VRAI) {}
194203

195204
void spill(LiveRangeEdit &) override;
196205
ArrayRef<Register> getSpilledRegs() override { return RegsToSpill; }
@@ -228,11 +237,10 @@ Spiller::~Spiller() = default;
228237

229238
void Spiller::anchor() {}
230239

231-
Spiller *
232-
llvm::createInlineSpiller(const InlineSpiller::RequiredAnalyses &Analyses,
233-
MachineFunction &MF, VirtRegMap &VRM,
234-
VirtRegAuxInfo &VRAI) {
235-
return new InlineSpiller(Analyses, MF, VRM, VRAI);
240+
Spiller *llvm::createInlineSpiller(MachineFunctionPass &Pass,
241+
MachineFunction &MF, VirtRegMap &VRM,
242+
VirtRegAuxInfo &VRAI) {
243+
return new InlineSpiller(Pass, MF, VRM, VRAI);
236244
}
237245

238246
//===----------------------------------------------------------------------===//

llvm/lib/CodeGen/RegAllocBasic.cpp

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "llvm/CodeGen/LiveRegMatrix.h"
2323
#include "llvm/CodeGen/LiveStacks.h"
2424
#include "llvm/CodeGen/MachineBlockFrequencyInfo.h"
25-
#include "llvm/CodeGen/MachineDominators.h"
2625
#include "llvm/CodeGen/MachineFunctionPass.h"
2726
#include "llvm/CodeGen/MachineLoopInfo.h"
2827
#include "llvm/CodeGen/Passes.h"
@@ -188,7 +187,6 @@ void RABasic::getAnalysisUsage(AnalysisUsage &AU) const {
188187
AU.addRequired<ProfileSummaryInfoWrapperPass>();
189188
AU.addRequired<MachineBlockFrequencyInfoWrapperPass>();
190189
AU.addPreserved<MachineBlockFrequencyInfoWrapperPass>();
191-
AU.addRequired<MachineDominatorTreeWrapperPass>();
192190
AU.addRequiredID(MachineDominatorsID);
193191
AU.addPreservedID(MachineDominatorsID);
194192
AU.addRequired<MachineLoopInfoWrapperPass>();
@@ -312,20 +310,16 @@ bool RABasic::runOnMachineFunction(MachineFunction &mf) {
312310
<< "********** Function: " << mf.getName() << '\n');
313311

314312
MF = &mf;
315-
auto &MBFI = getAnalysis<MachineBlockFrequencyInfoWrapperPass>().getMBFI();
316-
auto &LiveStks = getAnalysis<LiveStacksWrapperLegacy>().getLS();
317-
auto &MDT = getAnalysis<MachineDominatorTreeWrapperPass>().getDomTree();
318-
319313
RegAllocBase::init(getAnalysis<VirtRegMapWrapperLegacy>().getVRM(),
320314
getAnalysis<LiveIntervalsWrapperPass>().getLIS(),
321315
getAnalysis<LiveRegMatrixWrapperLegacy>().getLRM());
322-
VirtRegAuxInfo VRAI(*MF, *LIS, *VRM,
323-
getAnalysis<MachineLoopInfoWrapperPass>().getLI(), MBFI,
324-
&getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI());
316+
VirtRegAuxInfo VRAI(
317+
*MF, *LIS, *VRM, getAnalysis<MachineLoopInfoWrapperPass>().getLI(),
318+
getAnalysis<MachineBlockFrequencyInfoWrapperPass>().getMBFI(),
319+
&getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI());
325320
VRAI.calculateSpillWeightsAndHints();
326321

327-
SpillerInstance.reset(
328-
createInlineSpiller({*LIS, LiveStks, MDT, MBFI}, *MF, *VRM, VRAI));
322+
SpillerInstance.reset(createInlineSpiller(*this, *MF, *VRM, VRAI));
329323

330324
allocatePhysRegs();
331325
postOptimization();

llvm/lib/CodeGen/RegAllocGreedy.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2750,7 +2750,6 @@ bool RAGreedy::runOnMachineFunction(MachineFunction &mf) {
27502750
Bundles = &getAnalysis<EdgeBundlesWrapperLegacy>().getEdgeBundles();
27512751
SpillPlacer = &getAnalysis<SpillPlacementWrapperLegacy>().getResult();
27522752
DebugVars = &getAnalysis<LiveDebugVariablesWrapperLegacy>().getLDV();
2753-
auto &LSS = getAnalysis<LiveStacksWrapperLegacy>().getLS();
27542753

27552754
initializeCSRCost();
27562755

@@ -2771,8 +2770,7 @@ bool RAGreedy::runOnMachineFunction(MachineFunction &mf) {
27712770
getAnalysis<RegAllocPriorityAdvisorAnalysis>().getAdvisor(*MF, *this);
27722771

27732772
VRAI = std::make_unique<VirtRegAuxInfo>(*MF, *LIS, *VRM, *Loops, *MBFI);
2774-
SpillerInstance.reset(
2775-
createInlineSpiller({*LIS, LSS, *DomTree, *MBFI}, *MF, *VRM, *VRAI));
2773+
SpillerInstance.reset(createInlineSpiller(*this, *MF, *VRM, *VRAI));
27762774

27772775
VRAI->calculateSpillWeightsAndHints();
27782776

llvm/lib/CodeGen/RegAllocPBQP.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -794,9 +794,6 @@ bool RegAllocPBQP::runOnMachineFunction(MachineFunction &MF) {
794794
MachineBlockFrequencyInfo &MBFI =
795795
getAnalysis<MachineBlockFrequencyInfoWrapperPass>().getMBFI();
796796

797-
auto &LiveStks = getAnalysis<LiveStacksWrapperLegacy>().getLS();
798-
auto &MDT = getAnalysis<MachineDominatorTreeWrapperPass>().getDomTree();
799-
800797
VirtRegMap &VRM = getAnalysis<VirtRegMapWrapperLegacy>().getVRM();
801798

802799
PBQPVirtRegAuxInfo VRAI(
@@ -810,7 +807,7 @@ bool RegAllocPBQP::runOnMachineFunction(MachineFunction &MF) {
810807
VirtRegAuxInfo DefaultVRAI(
811808
MF, LIS, VRM, getAnalysis<MachineLoopInfoWrapperPass>().getLI(), MBFI);
812809
std::unique_ptr<Spiller> VRegSpiller(
813-
createInlineSpiller({LIS, LiveStks, MDT, MBFI}, MF, VRM, DefaultVRAI));
810+
createInlineSpiller(*this, MF, VRM, DefaultVRAI));
814811

815812
MF.getRegInfo().freezeReservedRegs();
816813

0 commit comments

Comments
 (0)