Go to the documentation of this file.
22 #define DEBUG_TYPE "localizer"
28 "Move/duplicate certain instructions close to their use",
43 TTI = &getAnalysis<TargetTransformInfoWrapperPass>().getTTI(MF.
getFunction());
58 return InsertMBB ==
Def.getParent();
67 for (
unsigned Idx = 1; Idx <
MI->getNumOperands(); Idx += 2) {
68 auto &MO =
MI->getOperand(Idx);
69 if (&MO != &
Op && MO.isReg() && MO.getReg() == SrcReg)
76 LocalizedSetVecT &LocalizedInstrs) {
87 if (!TL.shouldLocalize(
MI,
TTI))
90 assert(
MI.getDesc().getNumDefs() == 1 &&
91 "More than one definition not supported yet");
101 dbgs() <<
"Checking use: " << MIUse
103 if (isLocalUse(MOUse,
MI, InsertMBB)) {
107 LocalizedInstrs.insert(&
MI);
115 if (isNonUniquePhiValue(MOUse))
120 auto MBBAndReg = std::make_pair(InsertMBB,
Reg);
121 auto NewVRegIt = MBBWithLocalDef.
find(MBBAndReg);
122 if (NewVRegIt == MBBWithLocalDef.
end()) {
125 LocalizedInstrs.insert(LocalizedMI);
137 MBBWithLocalDef.
insert(std::make_pair(MBBAndReg, NewReg)).first;
143 MOUse.
setReg(NewVRegIt->second);
149 bool Localizer::localizeIntraBlock(LocalizedSetVecT &LocalizedInstrs) {
150 bool Changed =
false;
177 assert(II !=
MBB.
end() &&
"Didn't find the user in the MBB");
181 MI->removeFromParent();
195 if (DoNotRunPass(MF))
206 bool Changed = localizeInterBlock(MF, LocalizedInstrs);
207 Changed |= localizeIntraBlock(LocalizedInstrs);
Move duplicate certain instructions close to their use
bool hasProperty(Property P) const
unsigned getOperandNo(const_mop_iterator I) const
Returns the number of the operand iterator I points to.
This is an optimization pass for GlobalISel generic memory operations.
MachineInstrBuilder & UseMI
Reg
All possible values of the reg field in the ModR/M byte.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
iterator_range< use_instr_nodbg_iterator > use_nodbg_instructions(Register Reg) const
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
auto reverse(ContainerTy &&C, std::enable_if_t< has_rbegin< ContainerTy >::value > *=nullptr)
iterator_range< use_iterator > use_operands(Register Reg) const
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
void getSelectionDAGFallbackAnalysisUsage(AnalysisUsage &AU)
Modify analysis usage so it preserves passes required for the SelectionDAG fallback.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
const MachineBasicBlock & front() const
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
const MachineOperand & getOperand(unsigned i) const
Represent the analysis usage information of a pass.
const MachineFunctionProperties & getProperties() const
Get the function properties.
MachineOperand class - Representation of each machine instruction operand.
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
bool runOnMachineFunction(MachineFunction &MF) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
inst_range instructions(Function *F)
Representation of each machine instruction.
MachineInstr * CloneMachineInstr(const MachineInstr *Orig)
Create a new MachineInstr which is a copy of Orig, identical in all ways except the instruction has n...
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
iterator SkipPHIsAndLabels(iterator I)
Return the first instruction in MBB after I that is not a PHI or a label.
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
iterator find(const_arg_type_t< KeyT > Val)
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
print Print MemDeps of function
MachineBasicBlock * getMBB() const
const MachineBasicBlock * getParent() const
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Wrapper class representing virtual and physical registers.
Function & getFunction()
Return the LLVM function that this machine code represents.
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
INITIALIZE_PASS_BEGIN(Localizer, DEBUG_TYPE, "Move/duplicate certain instructions close to their use", false, false) INITIALIZE_PASS_END(Localizer
virtual const TargetLowering * getTargetLowering() const
bool hasOneUse(Register RegNo) const
hasOneUse - Return true if there is exactly one instruction using the specified register.
Register cloneVirtualRegister(Register VReg, StringRef Name="")
Create and return a new virtual register in the function with the same attributes as the given regist...
void setReg(Register Reg)
Change the register this operand corresponds to.
iv Induction Variable Users
A SetVector that performs no allocations if smaller than a certain size.
AnalysisUsage & addRequired()
Printable printReg(Register Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubIdx=0, const MachineRegisterInfo *MRI=nullptr)
Prints virtual and physical registers with or without a TRI instance.
This pass implements the localization mechanism described at the top of this file.