diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2023-07-26 19:03:47 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2023-07-26 19:04:23 +0000 |
| commit | 7fa27ce4a07f19b07799a767fc29416f3b625afb (patch) | |
| tree | 27825c83636c4de341eb09a74f49f5d38a15d165 /llvm/lib/CodeGen/MachineLICM.cpp | |
| parent | e3b557809604d036af6e00c60f012c2025b59a5e (diff) | |
Diffstat (limited to 'llvm/lib/CodeGen/MachineLICM.cpp')
| -rw-r--r-- | llvm/lib/CodeGen/MachineLICM.cpp | 55 |
1 files changed, 27 insertions, 28 deletions
diff --git a/llvm/lib/CodeGen/MachineLICM.cpp b/llvm/lib/CodeGen/MachineLICM.cpp index 1c09c01df3aa..4e80e9b58c06 100644 --- a/llvm/lib/CodeGen/MachineLICM.cpp +++ b/llvm/lib/CodeGen/MachineLICM.cpp @@ -112,26 +112,26 @@ STATISTIC(NumNotHoistedDueToHotness, namespace { class MachineLICMBase : public MachineFunctionPass { - const TargetInstrInfo *TII; - const TargetLoweringBase *TLI; - const TargetRegisterInfo *TRI; - const MachineFrameInfo *MFI; - MachineRegisterInfo *MRI; + const TargetInstrInfo *TII = nullptr; + const TargetLoweringBase *TLI = nullptr; + const TargetRegisterInfo *TRI = nullptr; + const MachineFrameInfo *MFI = nullptr; + MachineRegisterInfo *MRI = nullptr; TargetSchedModel SchedModel; - bool PreRegAlloc; - bool HasProfileData; + bool PreRegAlloc = false; + bool HasProfileData = false; // Various analyses that we use... - AliasAnalysis *AA; // Alias analysis info. - MachineBlockFrequencyInfo *MBFI; // Machine block frequncy info - MachineLoopInfo *MLI; // Current MachineLoopInfo - MachineDominatorTree *DT; // Machine dominator tree for the cur loop + AliasAnalysis *AA = nullptr; // Alias analysis info. + MachineBlockFrequencyInfo *MBFI = nullptr; // Machine block frequncy info + MachineLoopInfo *MLI = nullptr; // Current MachineLoopInfo + MachineDominatorTree *DT = nullptr; // Machine dominator tree for the cur loop // State that is updated as we process loops - bool Changed; // True if a loop is changed. - bool FirstInLoop; // True if it's the first LICM in the loop. - MachineLoop *CurLoop; // The current loop we are working on. - MachineBasicBlock *CurPreheader; // The preheader for CurLoop. + bool Changed = false; // True if a loop is changed. + bool FirstInLoop = false; // True if it's the first LICM in the loop. + MachineLoop *CurLoop = nullptr; // The current loop we are working on. + MachineBasicBlock *CurPreheader = nullptr; // The preheader for CurLoop. // Exit blocks for CurLoop. SmallVector<MachineBasicBlock *, 8> ExitBlocks; @@ -163,7 +163,7 @@ namespace { // If a MBB does not dominate loop exiting blocks then it may not safe // to hoist loads from this block. // Tri-state: 0 - false, 1 - true, 2 - unknown - unsigned SpeculationState; + unsigned SpeculationState = SpeculateUnknown; public: MachineLICMBase(char &PassID, bool PreRegAlloc) @@ -575,8 +575,8 @@ void MachineLICMBase::HoistRegionPostRA() { if (!PhysRegClobbers.test(Def) && !TermRegs.test(Def)) { bool Safe = true; MachineInstr *MI = Candidate.MI; - for (const MachineOperand &MO : MI->operands()) { - if (!MO.isReg() || MO.isDef() || !MO.getReg()) + for (const MachineOperand &MO : MI->all_uses()) { + if (!MO.getReg()) continue; Register Reg = MO.getReg(); if (PhysRegDefs.test(Reg) || @@ -600,8 +600,9 @@ void MachineLICMBase::AddToLiveIns(MCRegister Reg) { if (!BB->isLiveIn(Reg)) BB->addLiveIn(Reg); for (MachineInstr &MI : *BB) { - for (MachineOperand &MO : MI.operands()) { - if (!MO.isReg() || !MO.getReg() || MO.isDef()) continue; + for (MachineOperand &MO : MI.all_uses()) { + if (!MO.getReg()) + continue; if (MO.getReg() == Reg || TRI->isSuperRegister(Reg, MO.getReg())) MO.setIsKill(false); } @@ -669,8 +670,8 @@ bool MachineLICMBase::isTriviallyReMaterializable( if (!TII->isTriviallyReMaterializable(MI)) return false; - for (const MachineOperand &MO : MI.operands()) { - if (MO.isReg() && MO.isUse() && MO.getReg().isVirtual()) + for (const MachineOperand &MO : MI.all_uses()) { + if (MO.getReg().isVirtual()) return false; } @@ -866,7 +867,7 @@ MachineLICMBase::calcRegisterCost(const MachineInstr *MI, bool ConsiderSeen, continue; const int *PS = TRI->getRegClassPressureSets(RC); for (; *PS != -1; ++PS) { - if (Cost.find(*PS) == Cost.end()) + if (!Cost.contains(*PS)) Cost[*PS] = RCCost; else Cost[*PS] += RCCost; @@ -1014,9 +1015,7 @@ bool MachineLICMBase::HasLoopPHIUse(const MachineInstr *MI) const { SmallVector<const MachineInstr*, 8> Work(1, MI); do { MI = Work.pop_back_val(); - for (const MachineOperand &MO : MI->operands()) { - if (!MO.isReg() || !MO.isDef()) - continue; + for (const MachineOperand &MO : MI->all_defs()) { Register Reg = MO.getReg(); if (!Reg.isVirtual()) continue; @@ -1455,8 +1454,8 @@ bool MachineLICMBase::Hoist(MachineInstr *MI, MachineBasicBlock *Preheader) { // Clear the kill flags of any register this instruction defines, // since they may need to be live throughout the entire loop // rather than just live for part of it. - for (MachineOperand &MO : MI->operands()) - if (MO.isReg() && MO.isDef() && !MO.isDead()) + for (MachineOperand &MO : MI->all_defs()) + if (!MO.isDead()) MRI->clearKillFlags(MO.getReg()); // Add to the CSE map. |
