14 #define DEBUG_TYPE "codegen-cp"
31 STATISTIC(NumDeletes,
"Number of dead copies deleted");
51 void SourceNoLongerAvailable(
unsigned Reg,
62 "Machine Copy Propagation Pass",
false,
false)
65 MachineCopyPropagation::SourceNoLongerAvailable(
unsigned Reg,
69 SourceMap::iterator SI = SrcMap.find(*AI);
70 if (SI != SrcMap.end()) {
71 const DestList& Defs = SI->second;
72 for (DestList::const_iterator
I = Defs.begin(), E = Defs.end();
74 unsigned MappedDef = *
I;
76 if (AvailCopyMap.erase(MappedDef)) {
78 AvailCopyMap.erase(*SR);
95 while (I != E && I != E2) {
96 if (I->hasUnmodeledSideEffects() || I->isCall() ||
145 bool Changed =
false;
157 " register allocation!");
160 if (CI != AvailCopyMap.
end()) {
162 if (!
MRI->isReserved(Def) &&
182 I->clearRegisterKills(Def, TRI);
193 CI = CopyMap.
find(*AI);
194 if (CI != CopyMap.
end())
195 MaybeDeadCopies.
remove(CI->second);
199 MaybeDeadCopies.
insert(MI);
208 SourceNoLongerAvailable(Def, SrcMap, AvailCopyMap);
214 AvailCopyMap.
erase(*AI);
219 AvailCopyMap[*SR] =
MI;
224 if (std::find(SrcMap[Src].
begin(), SrcMap[Src].
end(), Def) ==
226 SrcMap[Src].push_back(Def);
234 int RegMaskOpNum = -1;
247 " register allocation!");
258 if (CI != CopyMap.
end())
259 MaybeDeadCopies.
remove(CI->second);
267 if (RegMaskOpNum >= 0) {
271 DI = MaybeDeadCopies.
begin(),
DE = MaybeDeadCopies.
end();
273 unsigned Reg = (*DI)->getOperand(0).getReg();
282 MaybeDeadCopies.
clear();
283 AvailCopyMap.
clear();
289 for (
unsigned i = 0, e = Defs.
size(); i != e; ++i) {
290 unsigned Reg = Defs[i];
295 AvailCopyMap.
erase(*AI);
300 SourceNoLongerAvailable(Reg, SrcMap, AvailCopyMap);
309 DI = MaybeDeadCopies.
begin(),
DE = MaybeDeadCopies.
end();
311 if (!
MRI->isReserved((*DI)->getOperand(0).getReg())) {
322 bool MachineCopyPropagation::runOnMachineFunction(
MachineFunction &MF) {
323 bool Changed =
false;
330 Changed |= CopyPropagateBlock(*
I);
void push_back(const T &Elt)
const_iterator end(StringRef path)
Get end iterator over path.
static PassRegistry * getPassRegistry()
bool isValid() const
isValid - returns true if this iterator is not yet at the end.
static bool NoInterveningSideEffect(const MachineInstr *CopyMI, const MachineInstr *MI)
static bool isNopCopy(MachineInstr *CopyMI, unsigned Def, unsigned Src, const TargetRegisterInfo *TRI)
static bool isVirtualRegister(unsigned Reg)
const_iterator begin(StringRef path)
Get begin iterator over path.
bool isSubRegister(unsigned RegA, unsigned RegB) const
Returns true if RegB is a sub-register of RegA.
iterator end()
Get an iterator to the end of the SetVector.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(const char *reason, bool gen_crash_diag=true)
unsigned getSubRegIndex(unsigned RegNo, unsigned SubRegNo) const
For a given register pair, return the sub-register index if the second register is a sub-register of ...
const HexagonInstrInfo * TII
bool isReg() const
isReg - Tests if this is a MO_Register operand.
ID
LLVM Calling Convention Representation.
bool remove(const value_type &X)
Remove an item from the set vector.
unsigned getNumOperands() const
bool insert(const value_type &X)
Insert a new element into the SetVector.
iterator begin()
Get an iterator to the beginning of the SetVector.
const MachineBasicBlock * getParent() const
bundle_iterator< MachineInstr, instr_iterator > iterator
const MachineOperand & getOperand(unsigned i) const
char & MachineCopyPropagationID
void initializeMachineCopyPropagationPass(PassRegistry &)
INITIALIZE_PASS(MachineCopyPropagation,"machine-cp","Machine Copy Propagation Pass", false, false) void MachineCopyPropagation
bool isRegMask() const
isRegMask - Tests if this is a MO_RegisterMask operand.
virtual const TargetInstrInfo * getInstrInfo() const
A SetVector that performs no allocations if smaller than a certain size.
void setDesc(const MCInstrDesc &tid)
bool erase(const KeyT &Val)
static bool clobbersPhysReg(const uint32_t *RegMask, unsigned PhysReg)
void clear()
Completely clear the SetVector.
bundle_iterator< const MachineInstr, const_instr_iterator > const_iterator
STATISTIC(NumDeletes,"Number of dead copies deleted")
MachineRegisterInfo & getRegInfo()
const TargetMachine & getTarget() const
virtual const TargetRegisterInfo * getRegisterInfo() const
unsigned getReg() const
getReg - Returns the register number.
BasicBlockListType::iterator iterator
const MCRegisterInfo & MRI
iterator find(const KeyT &Val)