[LLVM][CodeGen] Add convenience accessors for MachineFunctionProperties (#140002)

Add per-property has<Prop>/set<Prop>/reset<Prop> functions to
MachineFunctionProperties.
This commit is contained in:
Rahul Joshi 2025-05-22 08:07:52 -07:00 committed by GitHub
parent eee958285b
commit 1fdf02ad5a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
69 changed files with 152 additions and 246 deletions

View File

@ -21,8 +21,7 @@ public:
MachineFunctionAnalysisManager &MFAM);
MachineFunctionProperties getRequiredProperties() const {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::NoPHIs);
return MachineFunctionProperties().setNoPHIs();
}
};

View File

@ -148,8 +148,7 @@ public:
bool runOnMachineFunction(MachineFunction &MF) override;
MachineFunctionProperties getRequiredProperties() const override {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::NoVRegs);
return MachineFunctionProperties().setNoVRegs();
}
private:

View File

@ -41,14 +41,13 @@ public:
MachineFunctionProperties getRequiredProperties() const override {
return MachineFunctionProperties()
.set(MachineFunctionProperties::Property::IsSSA)
.set(MachineFunctionProperties::Property::Legalized)
.set(MachineFunctionProperties::Property::RegBankSelected);
.setIsSSA()
.setLegalized()
.setRegBankSelected();
}
MachineFunctionProperties getSetProperties() const override {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::Selected);
return MachineFunctionProperties().setSelected();
}
InstructionSelect(CodeGenOptLevel OL = CodeGenOptLevel::Default,

View File

@ -56,19 +56,15 @@ public:
void getAnalysisUsage(AnalysisUsage &AU) const override;
MachineFunctionProperties getRequiredProperties() const override {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::IsSSA);
return MachineFunctionProperties().setIsSSA();
}
MachineFunctionProperties getSetProperties() const override {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::Legalized);
return MachineFunctionProperties().setLegalized();
}
MachineFunctionProperties getClearedProperties() const override {
return MachineFunctionProperties()
.set(MachineFunctionProperties::Property::NoPHIs)
.set(MachineFunctionProperties::Property::NoVRegs);
return MachineFunctionProperties().setNoPHIs().setNoVRegs();
}
bool runOnMachineFunction(MachineFunction &MF) override;

View File

@ -169,8 +169,7 @@ public:
StringRef getPassName() const override { return "LoadStoreOpt"; }
MachineFunctionProperties getRequiredProperties() const override {
return MachineFunctionProperties()
.set(MachineFunctionProperties::Property::IsSSA);
return MachineFunctionProperties().setIsSSA();
}
void getAnalysisUsage(AnalysisUsage &AU) const override;

View File

@ -85,8 +85,7 @@ public:
StringRef getPassName() const override { return "Localizer"; }
MachineFunctionProperties getRequiredProperties() const override {
return MachineFunctionProperties()
.set(MachineFunctionProperties::Property::IsSSA);
return MachineFunctionProperties().setIsSSA();
}
void getAnalysisUsage(AnalysisUsage &AU) const override;

View File

@ -624,19 +624,15 @@ public:
void getAnalysisUsage(AnalysisUsage &AU) const override;
MachineFunctionProperties getRequiredProperties() const override {
return MachineFunctionProperties()
.set(MachineFunctionProperties::Property::IsSSA)
.set(MachineFunctionProperties::Property::Legalized);
return MachineFunctionProperties().setIsSSA().setLegalized();
}
MachineFunctionProperties getSetProperties() const override {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::RegBankSelected);
return MachineFunctionProperties().setRegBankSelected();
}
MachineFunctionProperties getClearedProperties() const override {
return MachineFunctionProperties()
.set(MachineFunctionProperties::Property::NoPHIs);
return MachineFunctionProperties().setNoPHIs();
}
/// Check that our input is fully legal: we require the function to have the

View File

@ -157,8 +157,8 @@ void ThunkInserter<Derived, InsertedThunksTy>::createThunkFunction(
// generate one. At least GlobalISel asserts if this invariant isn't
// respected.
// Set MF properties. We never use vregs...
MF.getProperties().set(MachineFunctionProperties::Property::NoVRegs);
// Set MF properties. We never use vregs.
MF.getProperties().setNoVRegs();
}
template <typename Derived, typename InsertedThunksTy>

View File

@ -88,8 +88,7 @@ public:
void getAnalysisUsage(AnalysisUsage &) const override;
MachineFunctionProperties getSetProperties() const override {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::TracksDebugUserValues);
return MachineFunctionProperties().setTracksDebugUserValues();
}
};
@ -102,8 +101,7 @@ public:
using Result = LiveDebugVariables;
MachineFunctionProperties getSetProperties() const {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::TracksDebugUserValues);
return MachineFunctionProperties().setTracksDebugUserValues();
}
Result run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM);

View File

@ -19,8 +19,7 @@ public:
MachineFunctionAnalysisManager &MFAM);
MachineFunctionProperties getRequiredProperties() const {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::IsSSA);
return MachineFunctionProperties().setIsSSA();
}
};

View File

@ -25,8 +25,7 @@ public:
MachineFunctionAnalysisManager &MFAM);
MachineFunctionProperties getRequiredProperties() const {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::NoVRegs);
return MachineFunctionProperties().setNoVRegs();
}
};

View File

@ -214,6 +214,25 @@ public:
return *this;
}
// Per property has/set/reset accessors.
#define PPACCESSORS(X) \
bool has##X() const { return hasProperty(Property::X); } \
MachineFunctionProperties &set##X(void) { return set(Property::X); } \
MachineFunctionProperties &reset##X(void) { return reset(Property::X); }
PPACCESSORS(IsSSA)
PPACCESSORS(NoPHIs)
PPACCESSORS(TracksLiveness)
PPACCESSORS(NoVRegs)
PPACCESSORS(FailedISel)
PPACCESSORS(Legalized)
PPACCESSORS(RegBankSelected)
PPACCESSORS(Selected)
PPACCESSORS(TiedOpsRewritten)
PPACCESSORS(FailsVerification)
PPACCESSORS(FailedRegAlloc)
PPACCESSORS(TracksDebugUserValues)
/// Reset all the properties.
MachineFunctionProperties &reset() {
Properties.reset();

View File

@ -19,8 +19,7 @@ public:
MachineFunctionAnalysisManager &MachineFunctionAM);
MachineFunctionProperties getRequiredProperties() const {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::NoVRegs);
return MachineFunctionProperties().setNoVRegs();
}
};

View File

@ -198,21 +198,15 @@ public:
// The TwoAddressInstructionPass and PHIElimination passes take the machine
// function out of SSA form when they introduce multiple defs per virtual
// register.
bool isSSA() const {
return MF->getProperties().hasProperty(
MachineFunctionProperties::Property::IsSSA);
}
bool isSSA() const { return MF->getProperties().hasIsSSA(); }
// leaveSSA - Indicates that the machine function is no longer in SSA form.
void leaveSSA() {
MF->getProperties().reset(MachineFunctionProperties::Property::IsSSA);
}
void leaveSSA() { MF->getProperties().resetIsSSA(); }
/// tracksLiveness - Returns true when tracking register liveness accurately.
/// (see MachineFUnctionProperties::Property description for details)
bool tracksLiveness() const {
return MF->getProperties().hasProperty(
MachineFunctionProperties::Property::TracksLiveness);
return MF->getProperties().hasTracksLiveness();
}
/// invalidateLiveness - Indicates that register liveness is no longer being
@ -220,10 +214,7 @@ public:
///
/// This should be called by late passes that invalidate the liveness
/// information.
void invalidateLiveness() {
MF->getProperties().reset(
MachineFunctionProperties::Property::TracksLiveness);
}
void invalidateLiveness() { MF->getProperties().resetTracksLiveness(); }
/// Returns true if liveness for register class @p RC should be tracked at
/// the subregister level.

View File

@ -19,8 +19,7 @@ public:
MachineFunctionAnalysisManager &MFAM);
MachineFunctionProperties getRequiredProperties() const {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::NoVRegs);
return MachineFunctionProperties().setNoVRegs();
}
static bool isRequired() { return true; }
};

View File

@ -22,8 +22,7 @@ public:
MachineFunctionAnalysisManager &MFAM);
MachineFunctionProperties getRequiredProperties() const {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::NoVRegs);
return MachineFunctionProperties().setNoVRegs();
}
};

View File

@ -172,9 +172,7 @@ public:
bool runOnMachineFunction(MachineFunction &MF) override;
MachineFunctionProperties getRequiredProperties() const override {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::NoVRegs).set(
MachineFunctionProperties::Property::TracksLiveness);
return MachineFunctionProperties().setNoVRegs().setTracksLiveness();
}
/// Re-run the analysis.

View File

@ -28,22 +28,19 @@ public:
RegAllocFastPass(Options Opts = Options()) : Opts(std::move(Opts)) {}
MachineFunctionProperties getRequiredProperties() const {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::NoPHIs);
return MachineFunctionProperties().setNoPHIs();
}
MachineFunctionProperties getSetProperties() const {
if (Opts.ClearVRegs) {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::NoVRegs);
return MachineFunctionProperties().setNoVRegs();
}
return MachineFunctionProperties();
}
MachineFunctionProperties getClearedProperties() const {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::IsSSA);
return MachineFunctionProperties().setIsSSA();
}
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &);

View File

@ -28,13 +28,11 @@ public:
PreservedAnalyses run(MachineFunction &F, MachineFunctionAnalysisManager &AM);
MachineFunctionProperties getRequiredProperties() const {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::NoPHIs);
return MachineFunctionProperties().setNoPHIs();
}
MachineFunctionProperties getClearedProperties() const {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::IsSSA);
return MachineFunctionProperties().setIsSSA();
}
void

View File

@ -18,8 +18,7 @@ public:
MachineFunctionAnalysisManager &MFAM);
MachineFunctionProperties getClearedProperties() const {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::IsSSA);
return MachineFunctionProperties().setIsSSA();
}
};

View File

@ -20,8 +20,7 @@ public:
MachineFunctionAnalysisManager &MFAM);
MachineFunctionProperties getRequiredProperties() const {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::NoVRegs);
return MachineFunctionProperties().setNoVRegs();
}
};

View File

@ -19,8 +19,7 @@ public:
MachineFunctionAnalysisManager &MFAM);
MachineFunctionProperties getRequiredProperties() const {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::NoVRegs);
return MachineFunctionProperties().setNoVRegs();
}
};

View File

@ -29,8 +29,7 @@ class EarlyTailDuplicatePass
: public TailDuplicatePassBase<EarlyTailDuplicatePass, true> {
public:
MachineFunctionProperties getClearedProperties() const {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::NoPHIs);
return MachineFunctionProperties().setNoPHIs();
}
};

View File

@ -19,8 +19,7 @@ public:
PreservedAnalyses run(MachineFunction &MF,
MachineFunctionAnalysisManager &MFAM);
MachineFunctionProperties getSetProperties() const {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::TiedOpsRewritten);
return MachineFunctionProperties().setTiedOpsRewritten();
}
};

View File

@ -106,8 +106,7 @@ public:
}
MachineFunctionProperties getRequiredProperties() const override {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::NoPHIs);
return MachineFunctionProperties().setNoPHIs();
}
};

View File

@ -64,8 +64,7 @@ public:
bool runOnMachineFunction(MachineFunction &MF) override;
MachineFunctionProperties getRequiredProperties() const override {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::NoVRegs);
return MachineFunctionProperties().setNoVRegs();
}
private:

View File

@ -29,8 +29,7 @@ public:
bool runOnMachineFunction(MachineFunction &F) override;
MachineFunctionProperties getRequiredProperties() const override {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::NoVRegs);
return MachineFunctionProperties().setNoVRegs();
}
};
}

View File

@ -255,8 +255,7 @@ bool Combiner::tryDCE(MachineInstr &MI, MachineRegisterInfo &MRI) {
bool Combiner::combineMachineInstrs() {
// If the ISel pipeline failed, do not bother running this pass.
// FIXME: Should this be here or in individual combiner passes.
if (MF.getProperties().hasProperty(
MachineFunctionProperties::Property::FailedISel))
if (MF.getProperties().hasFailedISel())
return false;
// We can't call this in the constructor because the derived class is

View File

@ -115,7 +115,7 @@ static void reportTranslationError(MachineFunction &MF,
const TargetPassConfig &TPC,
OptimizationRemarkEmitter &ORE,
OptimizationRemarkMissed &R) {
MF.getProperties().set(MachineFunctionProperties::Property::FailedISel);
MF.getProperties().setFailedISel();
// Print the function name explicitly if we don't have a debug location (which
// makes the diagnostic less useful) or if we're going to emit a raw error.

View File

@ -133,8 +133,7 @@ void InstructionSelect::getAnalysisUsage(AnalysisUsage &AU) const {
bool InstructionSelect::runOnMachineFunction(MachineFunction &MF) {
// If the ISel pipeline failed, do not bother running that pass.
if (MF.getProperties().hasProperty(
MachineFunctionProperties::Property::FailedISel))
if (MF.getProperties().hasFailedISel())
return false;
ISel = MF.getSubtarget().getInstructionSelector();
@ -307,7 +306,7 @@ bool InstructionSelect::selectMachineFunction(MachineFunction &MF) {
if (!DebugCounter::shouldExecute(GlobalISelCounter)) {
dbgs() << "Falling back for function " << MF.getName() << "\n";
MF.getProperties().set(MachineFunctionProperties::Property::FailedISel);
MF.getProperties().setFailedISel();
return false;
}

View File

@ -308,8 +308,7 @@ Legalizer::legalizeMachineFunction(MachineFunction &MF, const LegalizerInfo &LI,
bool Legalizer::runOnMachineFunction(MachineFunction &MF) {
// If the ISel pipeline failed, do not bother running that pass.
if (MF.getProperties().hasProperty(
MachineFunctionProperties::Property::FailedISel))
if (MF.getProperties().hasFailedISel())
return false;
LLVM_DEBUG(dbgs() << "Legalize Machine IR for: " << MF.getName() << '\n');
init(MF);

View File

@ -67,8 +67,7 @@ void LoadStoreOpt::init(MachineFunction &MF) {
TLI = MF.getSubtarget().getTargetLowering();
LI = MF.getSubtarget().getLegalizerInfo();
Builder.setMF(MF);
IsPreLegalizer = !MF.getProperties().hasProperty(
MachineFunctionProperties::Property::Legalized);
IsPreLegalizer = !MF.getProperties().hasLegalized();
InstsToErase.clear();
}
@ -973,8 +972,7 @@ void LoadStoreOpt::initializeStoreMergeTargetInfo(unsigned AddrSpace) {
bool LoadStoreOpt::runOnMachineFunction(MachineFunction &MF) {
// If the ISel pipeline failed, do not bother running that pass.
if (MF.getProperties().hasProperty(
MachineFunctionProperties::Property::FailedISel))
if (MF.getProperties().hasFailedISel())
return false;
LLVM_DEBUG(dbgs() << "Begin memory optimizations for: " << MF.getName()

View File

@ -203,8 +203,7 @@ bool Localizer::localizeIntraBlock(LocalizedSetVecT &LocalizedInstrs) {
bool Localizer::runOnMachineFunction(MachineFunction &MF) {
// If the ISel pipeline failed, do not bother running that pass.
if (MF.getProperties().hasProperty(
MachineFunctionProperties::Property::FailedISel))
if (MF.getProperties().hasFailedISel())
return false;
// Don't run the pass if the target asked so.

View File

@ -733,8 +733,7 @@ bool RegBankSelect::checkFunctionIsLegal(MachineFunction &MF) const {
bool RegBankSelect::runOnMachineFunction(MachineFunction &MF) {
// If the ISel pipeline failed, do not bother running that pass.
if (MF.getProperties().hasProperty(
MachineFunctionProperties::Property::FailedISel))
if (MF.getProperties().hasFailedISel())
return false;
LLVM_DEBUG(dbgs() << "Assign register banks for: " << MF.getName() << '\n');

View File

@ -259,7 +259,7 @@ void llvm::reportGISelWarning(MachineFunction &MF, const TargetPassConfig &TPC,
void llvm::reportGISelFailure(MachineFunction &MF, const TargetPassConfig &TPC,
MachineOptimizationRemarkEmitter &MORE,
MachineOptimizationRemarkMissed &R) {
MF.getProperties().set(MachineFunctionProperties::Property::FailedISel);
MF.getProperties().setFailedISel();
reportGISelDiagnostic(DS_Error, MF, TPC, MORE, R);
}

View File

@ -217,8 +217,7 @@ namespace {
bool runOnMachineFunction(MachineFunction &MF) override;
MachineFunctionProperties getRequiredProperties() const override {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::NoVRegs);
return MachineFunctionProperties().setNoVRegs();
}
private:

View File

@ -226,8 +226,7 @@ public:
}
MachineFunctionProperties getRequiredProperties() const override {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::NoVRegs);
return MachineFunctionProperties().setNoVRegs();
}
};

View File

@ -434,7 +434,7 @@ bool MIRParserImpl::computeFunctionProperties(
MF.setHasInlineAsm(HasInlineAsm);
if (HasTiedOps && AllTiedOpsRewritten)
Properties.set(MachineFunctionProperties::Property::TiedOpsRewritten);
Properties.setTiedOpsRewritten();
if (ComputedPropertyHelper(YamlMF.IsSSA, isSSA(MF),
MachineFunctionProperties::Property::IsSSA)) {
@ -556,21 +556,19 @@ MIRParserImpl::initializeMachineFunction(const yaml::MachineFunction &YamlMF,
MF.setHasEHFunclets(YamlMF.HasEHFunclets);
MF.setIsOutlined(YamlMF.IsOutlined);
MachineFunctionProperties &Props = MF.getProperties();
if (YamlMF.Legalized)
MF.getProperties().set(MachineFunctionProperties::Property::Legalized);
Props.setLegalized();
if (YamlMF.RegBankSelected)
MF.getProperties().set(
MachineFunctionProperties::Property::RegBankSelected);
Props.setRegBankSelected();
if (YamlMF.Selected)
MF.getProperties().set(MachineFunctionProperties::Property::Selected);
Props.setSelected();
if (YamlMF.FailedISel)
MF.getProperties().set(MachineFunctionProperties::Property::FailedISel);
Props.setFailedISel();
if (YamlMF.FailsVerification)
MF.getProperties().set(
MachineFunctionProperties::Property::FailsVerification);
Props.setFailsVerification();
if (YamlMF.TracksDebugUserValues)
MF.getProperties().set(
MachineFunctionProperties::Property::TracksDebugUserValues);
Props.setTracksDebugUserValues();
PerFunctionMIParsingState PFS(MF, SM, IRSlots, *Target);
if (parseRegisterInfo(PFS, YamlMF))

View File

@ -188,25 +188,16 @@ static void printMF(raw_ostream &OS, const MachineModuleInfo &MMI,
YamlMF.IsOutlined = MF.isOutlined();
YamlMF.UseDebugInstrRef = MF.useDebugInstrRef();
YamlMF.Legalized = MF.getProperties().hasProperty(
MachineFunctionProperties::Property::Legalized);
YamlMF.RegBankSelected = MF.getProperties().hasProperty(
MachineFunctionProperties::Property::RegBankSelected);
YamlMF.Selected = MF.getProperties().hasProperty(
MachineFunctionProperties::Property::Selected);
YamlMF.FailedISel = MF.getProperties().hasProperty(
MachineFunctionProperties::Property::FailedISel);
YamlMF.FailsVerification = MF.getProperties().hasProperty(
MachineFunctionProperties::Property::FailsVerification);
YamlMF.TracksDebugUserValues = MF.getProperties().hasProperty(
MachineFunctionProperties::Property::TracksDebugUserValues);
YamlMF.NoPHIs = MF.getProperties().hasProperty(
MachineFunctionProperties::Property::NoPHIs);
YamlMF.IsSSA = MF.getProperties().hasProperty(
MachineFunctionProperties::Property::IsSSA);
YamlMF.NoVRegs = MF.getProperties().hasProperty(
MachineFunctionProperties::Property::NoVRegs);
const MachineFunctionProperties &Props = MF.getProperties();
YamlMF.Legalized = Props.hasLegalized();
YamlMF.RegBankSelected = Props.hasRegBankSelected();
YamlMF.Selected = Props.hasSelected();
YamlMF.FailedISel = Props.hasFailedISel();
YamlMF.FailsVerification = Props.hasFailsVerification();
YamlMF.TracksDebugUserValues = Props.hasTracksDebugUserValues();
YamlMF.NoPHIs = Props.hasNoPHIs();
YamlMF.IsSSA = Props.hasIsSSA();
YamlMF.NoVRegs = Props.hasNoVRegs();
convertMRI(YamlMF, MF, MF.getRegInfo(), MF.getSubtarget().getRegisterInfo());
MachineModuleSlotTracker &MST = State.MST;

View File

@ -1776,17 +1776,15 @@ void MachineBasicBlock::clearLiveIns(
}
MachineBasicBlock::livein_iterator MachineBasicBlock::livein_begin() const {
assert(getParent()->getProperties().hasProperty(
MachineFunctionProperties::Property::TracksLiveness) &&
"Liveness information is accurate");
assert(getParent()->getProperties().hasTracksLiveness() &&
"Liveness information is accurate");
return LiveIns.begin();
}
MachineBasicBlock::liveout_iterator MachineBasicBlock::liveout_begin() const {
const MachineFunction &MF = *getParent();
assert(MF.getProperties().hasProperty(
MachineFunctionProperties::Property::TracksLiveness) &&
"Liveness information is accurate");
assert(MF.getProperties().hasTracksLiveness() &&
"Liveness information is accurate");
const TargetLowering &TLI = *MF.getSubtarget().getTargetLowering();
MCRegister ExceptionPointer, ExceptionSelector;

View File

@ -153,8 +153,7 @@ public:
}
MachineFunctionProperties getRequiredProperties() const override {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::IsSSA);
return MachineFunctionProperties().setIsSSA();
}
};
} // end anonymous namespace

View File

@ -514,8 +514,7 @@ public:
bool runOnMachineFunction(MachineFunction &MF) override;
MachineFunctionProperties getRequiredProperties() const override {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::NoVRegs);
return MachineFunctionProperties().setNoVRegs();
}
};

View File

@ -187,8 +187,8 @@ void MachineFunction::handleChangeDesc(MachineInstr &MI,
void MachineFunction::init() {
// Assume the function starts in SSA form with correct liveness.
Properties.set(MachineFunctionProperties::Property::IsSSA);
Properties.set(MachineFunctionProperties::Property::TracksLiveness);
Properties.setIsSSA();
Properties.setTracksLiveness();
RegInfo = new (Allocator) MachineRegisterInfo(this);
MFInfo = nullptr;

View File

@ -81,8 +81,7 @@ public:
bool runOnMachineFunction(MachineFunction &MF) override;
MachineFunctionProperties getRequiredProperties() const override {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::NoVRegs);
return MachineFunctionProperties().setNoVRegs();
}
};

View File

@ -962,10 +962,10 @@ MachineFunction *MachineOutliner::createOutlinedFunction(
computeAndPublishHashSequence(MF, OF.Candidates.size());
// Set normal properties for a late MachineFunction.
MF.getProperties().reset(MachineFunctionProperties::Property::IsSSA);
MF.getProperties().set(MachineFunctionProperties::Property::NoPHIs);
MF.getProperties().set(MachineFunctionProperties::Property::NoVRegs);
MF.getProperties().set(MachineFunctionProperties::Property::TracksLiveness);
MF.getProperties().resetIsSSA();
MF.getProperties().setNoPHIs();
MF.getProperties().setNoVRegs();
MF.getProperties().setTracksLiveness();
MF.getRegInfo().freezeReservedRegs();
// Compute live-in set for outlined fn
@ -1111,8 +1111,7 @@ bool MachineOutliner::outline(
// anything we outline doesn't break liveness assumptions. The outlined
// functions themselves currently don't track liveness, but we should
// make sure that the ranges we yank things out of aren't wrong.
if (MBB.getParent()->getProperties().hasProperty(
MachineFunctionProperties::Property::TracksLiveness)) {
if (MBB.getParent()->getProperties().hasTracksLiveness()) {
// The following code is to add implicit def operands to the call
// instruction. It also updates call site information for moved
// code.

View File

@ -2082,8 +2082,7 @@ public:
}
MachineFunctionProperties getRequiredProperties() const override {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::NoVRegs);
return MachineFunctionProperties().setNoVRegs();
}
private:

View File

@ -383,8 +383,7 @@ struct MachineVerifierLegacyPass : public MachineFunctionPass {
// Skip functions that have known verification problems.
// FIXME: Remove this mechanism when all problematic passes have been
// fixed.
if (MF.getProperties().hasProperty(
MachineFunctionProperties::Property::FailsVerification))
if (MF.getProperties().hasFailsVerification())
return false;
MachineVerifier(this, Banner.c_str(), &errs()).verify(MF);
@ -400,8 +399,7 @@ MachineVerifierPass::run(MachineFunction &MF,
// Skip functions that have known verification problems.
// FIXME: Remove this mechanism when all problematic passes have been
// fixed.
if (MF.getProperties().hasProperty(
MachineFunctionProperties::Property::FailsVerification))
if (MF.getProperties().hasFailsVerification())
return PreservedAnalyses::all();
MachineVerifier(MFAM, Banner.c_str(), &errs()).verify(MF);
return PreservedAnalyses::all();
@ -462,9 +460,7 @@ void MachineVerifier::verifyProperties(const MachineFunction &MF) {
// If a pass has introduced virtual registers without clearing the
// NoVRegs property (or set it without allocating the vregs)
// then report an error.
if (MF.getProperties().hasProperty(
MachineFunctionProperties::Property::NoVRegs) &&
MRI->getNumVirtRegs())
if (MF.getProperties().hasNoVRegs() && MRI->getNumVirtRegs())
report("Function has NoVRegs property but there are VReg operands", &MF);
}
@ -476,8 +472,8 @@ bool MachineVerifier::verify(const MachineFunction &MF) {
RBI = MF.getSubtarget().getRegBankInfo();
MRI = &MF.getRegInfo();
const bool isFunctionFailedISel = MF.getProperties().hasProperty(
MachineFunctionProperties::Property::FailedISel);
const MachineFunctionProperties &Props = MF.getProperties();
const bool isFunctionFailedISel = Props.hasFailedISel();
// If we're mid-GlobalISel and we already triggered the fallback path then
// it's expected that the MIR is somewhat broken but that's ok since we'll
@ -485,12 +481,9 @@ bool MachineVerifier::verify(const MachineFunction &MF) {
if (isFunctionFailedISel)
return true;
isFunctionRegBankSelected = MF.getProperties().hasProperty(
MachineFunctionProperties::Property::RegBankSelected);
isFunctionSelected = MF.getProperties().hasProperty(
MachineFunctionProperties::Property::Selected);
isFunctionTracksDebugUserValues = MF.getProperties().hasProperty(
MachineFunctionProperties::Property::TracksDebugUserValues);
isFunctionRegBankSelected = Props.hasRegBankSelected();
isFunctionSelected = Props.hasSelected();
isFunctionTracksDebugUserValues = Props.hasTracksDebugUserValues();
if (PASS) {
auto *LISWrapper = PASS->getAnalysisIfAvailable<LiveIntervalsWrapperPass>();
@ -731,8 +724,7 @@ MachineVerifier::visitMachineBasicBlockBefore(const MachineBasicBlock *MBB) {
FirstTerminator = nullptr;
FirstNonPHI = nullptr;
if (!MF->getProperties().hasProperty(
MachineFunctionProperties::Property::NoPHIs) && MRI->tracksLiveness()) {
if (!MF->getProperties().hasNoPHIs() && MRI->tracksLiveness()) {
// If this block has allocatable physical registers live-in, check that
// it is an entry block or landing pad.
for (const auto &LI : MBB->liveins()) {
@ -2285,8 +2277,7 @@ void MachineVerifier::visitMachineInstrBefore(const MachineInstr *MI) {
report("NoConvergent flag expected only on convergent instructions.", MI);
if (MI->isPHI()) {
if (MF->getProperties().hasProperty(
MachineFunctionProperties::Property::NoPHIs))
if (MF->getProperties().hasNoPHIs())
report("Found PHI instruction with NoPHIs property set", MI);
if (FirstNonPHI)
@ -2303,9 +2294,7 @@ void MachineVerifier::visitMachineInstrBefore(const MachineInstr *MI) {
if (!MI->getOperand(0).isReg() || !MI->getOperand(0).isDef())
report("Unspillable Terminator does not define a reg", MI);
Register Def = MI->getOperand(0).getReg();
if (Def.isVirtual() &&
!MF->getProperties().hasProperty(
MachineFunctionProperties::Property::NoPHIs) &&
if (Def.isVirtual() && !MF->getProperties().hasNoPHIs() &&
std::distance(MRI->use_nodbg_begin(Def), MRI->use_nodbg_end()) > 1)
report("Unspillable Terminator expected to have at most one use!", MI);
}
@ -2626,9 +2615,8 @@ MachineVerifier::visitMachineOperand(const MachineOperand *MO, unsigned MONum) {
// TiedOpsRewritten property to verify two-address constraints, this
// property will be set in twoaddressinstruction pass.
unsigned DefIdx;
if (MF->getProperties().hasProperty(
MachineFunctionProperties::Property::TiedOpsRewritten) &&
MO->isUse() && MI->isRegTiedToDefOperand(MONum, &DefIdx) &&
if (MF->getProperties().hasTiedOpsRewritten() && MO->isUse() &&
MI->isRegTiedToDefOperand(MONum, &DefIdx) &&
Reg != MI->getOperand(DefIdx).getReg())
report("Two-address instruction operands must be identical", MO, MONum);
@ -3729,9 +3717,7 @@ void MachineVerifier::verifyLiveRangeSegment(const LiveRange &LR,
// early-clobber slot if it is being redefined by an early-clobber def.
// TODO: Before tied operands are rewritten, a live segment can only end at
// an early-clobber slot if the last use is tied to an early-clobber def.
if (MF->getProperties().hasProperty(
MachineFunctionProperties::Property::TiedOpsRewritten) &&
S.end.isEarlyClobber()) {
if (MF->getProperties().hasTiedOpsRewritten() && S.end.isEarlyClobber()) {
if (I + 1 == LR.end() || (I + 1)->start != S.end) {
report("Live segment ending at early clobber slot must be "
"redefined by an EC def in the same instruction",

View File

@ -152,8 +152,7 @@ public:
}
MachineFunctionProperties getSetProperties() const override {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::NoPHIs);
return MachineFunctionProperties().setNoPHIs();
}
void getAnalysisUsage(AnalysisUsage &AU) const override;
@ -285,7 +284,7 @@ bool PHIEliminationImpl::run(MachineFunction &MF) {
ImpDefs.clear();
VRegPHIUseCount.clear();
MF.getProperties().set(MachineFunctionProperties::Property::NoPHIs);
MF.getProperties().setNoPHIs();
return Changed;
}

View File

@ -38,8 +38,7 @@ struct PatchableFunctionLegacy : public MachineFunctionPass {
}
MachineFunctionProperties getRequiredProperties() const override {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::NoVRegs);
return MachineFunctionProperties().setNoVRegs();
}
};

View File

@ -577,8 +577,7 @@ public:
}
MachineFunctionProperties getRequiredProperties() const override {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::IsSSA);
return MachineFunctionProperties().setIsSSA();
}
};

View File

@ -106,8 +106,7 @@ public:
}
MachineFunctionProperties getRequiredProperties() const override {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::NoVRegs);
return MachineFunctionProperties().setNoVRegs();
}
bool runOnMachineFunction(MachineFunction &Fn) override;

View File

@ -48,8 +48,7 @@ public:
bool runOnMachineFunction(MachineFunction &MF) override;
MachineFunctionProperties getRequiredProperties() const override {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::IsSSA);
return MachineFunctionProperties().setIsSSA();
}
};
} // end anonymous namespace

View File

@ -659,8 +659,7 @@ void PEIImpl::spillCalleeSavedRegs(MachineFunction &MF) {
// pipeline is set up without giving the passes a chance to look at the
// TargetMachine.
// FIXME: Find a way to express this in getRequiredProperties.
assert(MF.getProperties().hasProperty(
MachineFunctionProperties::Property::NoVRegs));
assert(MF.getProperties().hasNoVRegs());
const Function &F = MF.getFunction();
const TargetFrameLowering *TFI = MF.getSubtarget().getFrameLowering();

View File

@ -216,10 +216,9 @@ MCPhysReg RegAllocBase::getErrorAssignment(const TargetRegisterClass &RC,
// Avoid printing the error for every single instance of the register. It
// would be better if this were per register class.
bool EmitError = !MF.getProperties().hasProperty(
MachineFunctionProperties::Property::FailedRegAlloc);
bool EmitError = !MF.getProperties().hasFailedRegAlloc();
if (EmitError)
MF.getProperties().set(MachineFunctionProperties::Property::FailedRegAlloc);
MF.getProperties().setFailedRegAlloc();
const Function &Fn = MF.getFunction();
LLVMContext &Context = Fn.getContext();

View File

@ -105,13 +105,11 @@ public:
bool runOnMachineFunction(MachineFunction &mf) override;
MachineFunctionProperties getRequiredProperties() const override {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::NoPHIs);
return MachineFunctionProperties().setNoPHIs();
}
MachineFunctionProperties getClearedProperties() const override {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::IsSSA);
return MachineFunctionProperties().setIsSSA();
}
// Helper for spilling all live virtual registers currently unified under preg

View File

@ -417,22 +417,19 @@ public:
}
MachineFunctionProperties getRequiredProperties() const override {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::NoPHIs);
return MachineFunctionProperties().setNoPHIs();
}
MachineFunctionProperties getSetProperties() const override {
if (Impl.ClearVirtRegs) {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::NoVRegs);
return MachineFunctionProperties().setNoVRegs();
}
return MachineFunctionProperties();
}
MachineFunctionProperties getClearedProperties() const override {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::IsSSA);
return MachineFunctionProperties().setIsSSA();
}
};
@ -1196,10 +1193,9 @@ MCPhysReg RegAllocFastImpl::getErrorAssignment(const LiveReg &LR,
MachineFunction &MF = *MI.getMF();
// Avoid repeating the error every time a register is used.
bool EmitError = !MF.getProperties().hasProperty(
MachineFunctionProperties::Property::FailedRegAlloc);
bool EmitError = !MF.getProperties().hasFailedRegAlloc();
if (EmitError)
MF.getProperties().set(MachineFunctionProperties::Property::FailedRegAlloc);
MF.getProperties().setFailedRegAlloc();
// If the allocation order was empty, all registers in the class were
// probably reserved. Fall back to taking the first register in the class,

View File

@ -158,13 +158,11 @@ public:
bool runOnMachineFunction(MachineFunction &mf) override;
MachineFunctionProperties getRequiredProperties() const override {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::NoPHIs);
return MachineFunctionProperties().setNoPHIs();
}
MachineFunctionProperties getClearedProperties() const override {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::IsSSA);
return MachineFunctionProperties().setIsSSA();
}
};

View File

@ -135,13 +135,11 @@ public:
bool runOnMachineFunction(MachineFunction &MF) override;
MachineFunctionProperties getRequiredProperties() const override {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::NoPHIs);
return MachineFunctionProperties().setNoPHIs();
}
MachineFunctionProperties getClearedProperties() const override {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::IsSSA);
return MachineFunctionProperties().setIsSSA();
}
private:

View File

@ -398,8 +398,7 @@ public:
void getAnalysisUsage(AnalysisUsage &AU) const override;
MachineFunctionProperties getClearedProperties() const override {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::IsSSA);
return MachineFunctionProperties().setIsSSA();
}
/// This is the pass entry point.

View File

@ -467,7 +467,7 @@ void llvm::scavengeFrameVirtualRegs(MachineFunction &MF, RegScavenger &RS) {
MachineRegisterInfo &MRI = MF.getRegInfo();
// Shortcut.
if (MRI.getNumVirtRegs() == 0) {
MF.getProperties().set(MachineFunctionProperties::Property::NoVRegs);
MF.getProperties().setNoVRegs();
return;
}
@ -489,7 +489,7 @@ void llvm::scavengeFrameVirtualRegs(MachineFunction &MF, RegScavenger &RS) {
}
MRI.clearVirtRegs();
MF.getProperties().set(MachineFunctionProperties::Property::NoVRegs);
MF.getProperties().setNoVRegs();
}
namespace {

View File

@ -58,8 +58,7 @@ public:
}
MachineFunctionProperties getRequiredProperties() const override {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::NoVRegs);
return MachineFunctionProperties().setNoVRegs();
}
StringRef getPassName() const override {

View File

@ -60,8 +60,7 @@ namespace {
auto ClearVRegTypesOnReturn =
make_scope_exit([&MF]() { MF.getRegInfo().clearVirtRegTypes(); });
if (MF.getProperties().hasProperty(
MachineFunctionProperties::Property::FailedISel)) {
if (MF.getProperties().hasFailedISel()) {
if (AbortOnFailedISel)
report_fatal_error("Instruction selection failed");
LLVM_DEBUG(dbgs() << "Resetting: " << MF.getName() << '\n');

View File

@ -345,8 +345,7 @@ SelectionDAGISelLegacy::SelectionDAGISelLegacy(
bool SelectionDAGISelLegacy::runOnMachineFunction(MachineFunction &MF) {
// If we already selected that function, we do not need to run SDISel.
if (MF.getProperties().hasProperty(
MachineFunctionProperties::Property::Selected))
if (MF.getProperties().hasSelected())
return false;
// Do some sanity-checking on the command-line options.
@ -421,8 +420,7 @@ PreservedAnalyses
SelectionDAGISelPass::run(MachineFunction &MF,
MachineFunctionAnalysisManager &MFAM) {
// If we already selected that function, we do not need to run SDISel.
if (MF.getProperties().hasProperty(
MachineFunctionProperties::Property::Selected))
if (MF.getProperties().hasSelected())
return PreservedAnalyses::all();
// Do some sanity-checking on the command-line options.

View File

@ -275,8 +275,7 @@ public:
}
MachineFunctionProperties getRequiredProperties() const override {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::NoVRegs);
return MachineFunctionProperties().setNoVRegs();
}
StringRef getPassName() const override { return "Shrink Wrapping analysis"; }

View File

@ -62,8 +62,7 @@ public:
void getAnalysisUsage(AnalysisUsage &AU) const override;
MachineFunctionProperties getRequiredProperties() const override {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::NoVRegs);
return MachineFunctionProperties().setNoVRegs();
}
/// Calculate the liveness information for the given machine function.

View File

@ -66,8 +66,7 @@ public:
}
MachineFunctionProperties getClearedProperties() const override {
return MachineFunctionProperties()
.set(MachineFunctionProperties::Property::NoPHIs);
return MachineFunctionProperties().setNoPHIs();
}
};

View File

@ -1846,8 +1846,7 @@ TargetInstrInfo::describeLoadedValue(const MachineInstr &MI,
// To simplify the sub-register handling, verify that we only need to
// consider physical registers.
assert(MF->getProperties().hasProperty(
MachineFunctionProperties::Property::NoVRegs));
assert(MF->getProperties().hasNoVRegs());
if (auto DestSrc = isCopyInstr(MI)) {
Register DestReg = DestSrc->Destination->getReg();

View File

@ -1837,8 +1837,7 @@ bool TwoAddressInstructionImpl::run() {
MRI->leaveSSA();
// This pass will rewrite the tied-def to meet the RegConstraint.
MF->getProperties()
.set(MachineFunctionProperties::Property::TiedOpsRewritten);
MF->getProperties().setTiedOpsRewritten();
TiedOperandMap TiedOperands;
for (MachineBasicBlock &MBBI : *MF) {

View File

@ -244,8 +244,7 @@ public:
MachineFunctionProperties getSetProperties() const override {
if (ClearVirtRegs) {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::NoVRegs);
return MachineFunctionProperties().setNoVRegs();
}
return MachineFunctionProperties();