37 "Limit number of copy propagations in RDF-based copy propagation"));
42 unsigned Opc =
MI->getOpcode();
44 case TargetOpcode::COPY: {
52 if (
TRI.getMinimalPhysRegClass(DstR.
asMCReg()) !=
55 if (!
DFG.isTracked(SrcR) || !
DFG.isTracked(DstR))
57 EM.insert(std::make_pair(DstR, SrcR));
60 case TargetOpcode::REG_SEQUENCE:
67 CopyMap.insert(std::make_pair(SA.
Id, EM));
71 auto FS = DefM.find(
I.second.Id);
72 if (FS == DefM.end() || FS->second.empty())
74 RDefMap[
I.second][SA.
Id] = FS->second.top()->Id;
82 RegisterSet RRs(DFG.getPRI());
84 RRs.insert(
RA.Addr->getRegRef(DFG));
86 for (
auto &R : RDefMap) {
87 if (!RRs.count(R.first))
95 for (
auto &R : RDefMap) {
96 if (!RRs.count(
R.first))
98 auto F = DefM.find(
R.first.Id);
99 if (
F == DefM.end() ||
F->second.empty())
101 R.second[
IA.Id] =
F->second.top()->Id;
105bool CopyPropagation::scanBlock(MachineBasicBlock *
B) {
107 NodeAddr<BlockNode*> BA = DFG.findBlock(
B);
108 DFG.markBlock(BA.
Id, DefM);
110 for (NodeAddr<InstrNode*> IA : BA.
Addr->members(DFG)) {
112 NodeAddr<StmtNode*> SA =
IA;
113 EqualityMap EM(RegisterRefLess(DFG.getPRI()));
114 if (interpretAsCopy(SA.
Addr->getCode(), EM))
119 DFG.pushAllDefs(IA, DefM);
124 Changed |= scanBlock(
I->getBlock());
126 DFG.releaseBlock(BA.
Id, DefM);
131 scanBlock(&
DFG.getMF().front());
134 dbgs() <<
"Copies:\n";
139 for (
auto J : It->second)
145 dbgs() <<
"\nRDef map:\n";
148 for (
auto &M : R.second)
157 bool HasLimit =
RDFCpLimit.getNumOccurrences() > 0;
166 if (RR.Mask ==
TRI.getSubRegIndexLaneMask(S.getSubRegIndex()))
167 return S.getSubReg();
187 auto FR = EM.find(DR);
197 for (
NodeId N = DA.Addr->getReachedUse(), NextN;
N;
N = NextN) {
208 if (RDefSR[IA.Id] != RDefSR_SA)
223 DFG.unlinkUse(UA,
false);
224 if (RDefSR_SA != 0) {
225 UA.Addr->linkToDef(UA.Id,
DFG.addr<
DefNode*>(RDefSR_SA));
227 UA.Addr->setReachingDef(0);
228 UA.Addr->setSibling(0);
241 auto &M = FC->second;
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
cl::opt< unsigned > RDFCpLimit
static unsigned RDFCpCount
Register const TargetRegisterInfo * TRI
cl::opt< unsigned > RDFCpLimit("rdf-cp-limit", cl::init(0), cl::Hidden, cl::desc("Limit number of copy propagations in RDF-based copy propagation"))
SI optimize exec mask operations pre RA
Wrapper class representing physical registers. Should be passed by value.
constexpr bool isPhysical() const
Return true if the specified register number is in the physical register namespace.
Iterator that enumerates the sub-registers of a Reg and the associated sub-register indices.
bool isValid() const
Returns true if this iterator is not yet at the end.
Representation of each machine instruction.
MachineOperand class - Representation of each machine instruction operand.
const LaneBitmask LaneMask
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
initializer< Ty > init(const Ty &Val)
Print(const T &, const DataFlowGraph &) -> Print< T >
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
DomTreeNodeBase< MachineBasicBlock > MachineDomTreeNode
DWARFExpression::Operation Op
std::map< NodeId, EqualityMap > CopyMap
std::map< RegisterRef, std::map< NodeId, NodeId >, RegisterRefLess > RDefMap
std::map< RegisterRef, RegisterRef, RegisterRefLess > EqualityMap
virtual bool interpretAsCopy(const MachineInstr *MI, EqualityMap &EM)
LLVM_ABI bool equal_to(RegisterRef A, RegisterRef B) const
NodeId getSibling() const
constexpr MCRegister asMCReg() const
MachineInstr * getCode() const