Skip to content

Commit

Permalink
Revert "SelectionDAG: Avoid using MachineFunction::getMMI" (llvm#99777)
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalybuka authored and sgundapa committed Jul 23, 2024
1 parent e1e2164 commit fa3d184
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 27 deletions.
9 changes: 3 additions & 6 deletions llvm/include/llvm/CodeGen/SelectionDAG.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ class SelectionDAG {

ProfileSummaryInfo *PSI = nullptr;
BlockFrequencyInfo *BFI = nullptr;
MachineModuleInfo *MMI = nullptr;

/// List of non-single value types.
FoldingSet<SDVTListNode> VTListMap;
Expand Down Expand Up @@ -460,15 +459,14 @@ class SelectionDAG {
void init(MachineFunction &NewMF, OptimizationRemarkEmitter &NewORE,
Pass *PassPtr, const TargetLibraryInfo *LibraryInfo,
UniformityInfo *UA, ProfileSummaryInfo *PSIin,
BlockFrequencyInfo *BFIin, MachineModuleInfo &MMI,
FunctionVarLocs const *FnVarLocs);
BlockFrequencyInfo *BFIin, FunctionVarLocs const *FnVarLocs);

void init(MachineFunction &NewMF, OptimizationRemarkEmitter &NewORE,
MachineFunctionAnalysisManager &AM,
const TargetLibraryInfo *LibraryInfo, UniformityInfo *UA,
ProfileSummaryInfo *PSIin, BlockFrequencyInfo *BFIin,
MachineModuleInfo &MMI, FunctionVarLocs const *FnVarLocs) {
init(NewMF, NewORE, nullptr, LibraryInfo, UA, PSIin, BFIin, MMI, FnVarLocs);
FunctionVarLocs const *FnVarLocs) {
init(NewMF, NewORE, nullptr, LibraryInfo, UA, PSIin, BFIin, FnVarLocs);
MFAM = &AM;
}

Expand Down Expand Up @@ -502,7 +500,6 @@ class SelectionDAG {
OptimizationRemarkEmitter &getORE() const { return *ORE; }
ProfileSummaryInfo *getPSI() const { return PSI; }
BlockFrequencyInfo *getBFI() const { return BFI; }
MachineModuleInfo *getMMI() const { return MMI; }

FlagInserter *getFlagInserter() { return Inserter; }
void setFlagInserter(FlagInserter *FI) { Inserter = FI; }
Expand Down
1 change: 0 additions & 1 deletion llvm/include/llvm/CodeGen/SelectionDAGISel.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ class SelectionDAGISel {
std::unique_ptr<FunctionLoweringInfo> FuncInfo;
SwiftErrorValueTracking *SwiftError;
MachineFunction *MF;
MachineModuleInfo *MMI;
MachineRegisterInfo *RegInfo;
SelectionDAG *CurDAG;
std::unique_ptr<SelectionDAGBuilder> SDB;
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1333,7 +1333,7 @@ void SelectionDAG::init(MachineFunction &NewMF,
OptimizationRemarkEmitter &NewORE, Pass *PassPtr,
const TargetLibraryInfo *LibraryInfo,
UniformityInfo *NewUA, ProfileSummaryInfo *PSIin,
BlockFrequencyInfo *BFIin, MachineModuleInfo &MMIin,
BlockFrequencyInfo *BFIin,
FunctionVarLocs const *VarLocs) {
MF = &NewMF;
SDAGISelPass = PassPtr;
Expand All @@ -1345,7 +1345,6 @@ void SelectionDAG::init(MachineFunction &NewMF,
UA = NewUA;
PSI = PSIin;
BFI = BFIin;
MMI = &MMIin;
FnVarLocs = VarLocs;
}

Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6707,11 +6707,11 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I,
getValue(I.getArgOperand(0))));
return;
case Intrinsic::eh_sjlj_callsite: {
MachineModuleInfo &MMI = DAG.getMachineFunction().getMMI();
ConstantInt *CI = cast<ConstantInt>(I.getArgOperand(0));
assert(DAG.getMMI()->getCurrentCallSite() == 0 &&
"Overlapping call sites!");
assert(MMI.getCurrentCallSite() == 0 && "Overlapping call sites!");

DAG.getMMI()->setCurrentCallSite(CI->getZExtValue());
MMI.setCurrentCallSite(CI->getZExtValue());
return;
}
case Intrinsic::eh_sjlj_functioncontext: {
Expand Down
15 changes: 6 additions & 9 deletions llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ void SelectionDAGISel::initializeAnalysisResults(
FnVarLocs = &FAM.getResult<DebugAssignmentTrackingAnalysis>(Fn);

auto *UA = FAM.getCachedResult<UniformityInfoAnalysis>(Fn);
CurDAG->init(*MF, *ORE, MFAM, LibInfo, UA, PSI, BFI, *MMI, FnVarLocs);
CurDAG->init(*MF, *ORE, MFAM, LibInfo, UA, PSI, BFI, FnVarLocs);

// Now get the optional analyzes if we want to.
// This is based on the possibly changed OptLevel (after optnone is taken
Expand Down Expand Up @@ -562,11 +562,7 @@ void SelectionDAGISel::initializeAnalysisResults(MachineFunctionPass &MFP) {
UniformityInfo *UA = nullptr;
if (auto *UAPass = MFP.getAnalysisIfAvailable<UniformityInfoWrapperPass>())
UA = &UAPass->getUniformityInfo();

MachineModuleInfo &MMI =
MFP.getAnalysis<MachineModuleInfoWrapperPass>().getMMI();

CurDAG->init(*MF, *ORE, &MFP, LibInfo, UA, PSI, BFI, MMI, FnVarLocs);
CurDAG->init(*MF, *ORE, &MFP, LibInfo, UA, PSI, BFI, FnVarLocs);

// Now get the optional analyzes if we want to.
// This is based on the possibly changed OptLevel (after optnone is taken
Expand Down Expand Up @@ -800,7 +796,7 @@ bool SelectionDAGISel::runOnMachineFunction(MachineFunction &mf) {
}

// Determine if floating point is used for msvc
computeUsesMSVCFloatingPoint(TM.getTargetTriple(), Fn, *CurDAG->getMMI());
computeUsesMSVCFloatingPoint(TM.getTargetTriple(), Fn, MF->getMMI());

// Release function-specific state. SDB and CurDAG are already cleared
// at this point.
Expand Down Expand Up @@ -1447,6 +1443,7 @@ bool SelectionDAGISel::PrepareEHLandingPad() {

// Mark and Report IPToState for each Block under IsEHa
void SelectionDAGISel::reportIPToStateForBlocks(MachineFunction *MF) {
MachineModuleInfo &MMI = MF->getMMI();
llvm::WinEHFuncInfo *EHInfo = MF->getWinEHFuncInfo();
if (!EHInfo)
return;
Expand All @@ -1461,8 +1458,8 @@ void SelectionDAGISel::reportIPToStateForBlocks(MachineFunction *MF) {
continue;

// Insert EH Labels
MCSymbol *BeginLabel = MF->getContext().createTempSymbol();
MCSymbol *EndLabel = MF->getContext().createTempSymbol();
MCSymbol *BeginLabel = MMI.getContext().createTempSymbol();
MCSymbol *EndLabel = MMI.getContext().createTempSymbol();
EHInfo->addIPToStateRange(State, BeginLabel, EndLabel);
BuildMI(MBB, MBBb, SDB->getCurDebugLoc(),
TII->get(TargetOpcode::EH_LABEL))
Expand Down
3 changes: 1 addition & 2 deletions llvm/unittests/CodeGen/AArch64SelectionDAGTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ class AArch64SelectionDAGTest : public testing::Test {
if (!DAG)
report_fatal_error("DAG?");
OptimizationRemarkEmitter ORE(F);
DAG->init(*MF, ORE, nullptr, nullptr, nullptr, nullptr, nullptr, MMI,
nullptr);
DAG->init(*MF, ORE, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr);
}

TargetLoweringBase::LegalizeTypeAction getTypeAction(EVT VT) {
Expand Down
3 changes: 1 addition & 2 deletions llvm/unittests/CodeGen/SelectionDAGAddressAnalysisTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ class SelectionDAGAddressAnalysisTest : public testing::Test {
if (!DAG)
report_fatal_error("DAG?");
OptimizationRemarkEmitter ORE(F);
DAG->init(*MF, ORE, nullptr, nullptr, nullptr, nullptr, nullptr, MMI,
nullptr);
DAG->init(*MF, ORE, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr);
}

TargetLoweringBase::LegalizeTypeAction getTypeAction(EVT VT) {
Expand Down
3 changes: 1 addition & 2 deletions llvm/unittests/CodeGen/SelectionDAGPatternMatchTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ class SelectionDAGPatternMatchTest : public testing::Test {
if (!DAG)
report_fatal_error("DAG?");
OptimizationRemarkEmitter ORE(F);
DAG->init(*MF, ORE, nullptr, nullptr, nullptr, nullptr, nullptr, MMI,
nullptr);
DAG->init(*MF, ORE, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr);
}

TargetLoweringBase::LegalizeTypeAction getTypeAction(EVT VT) {
Expand Down

0 comments on commit fa3d184

Please sign in to comment.