58 bool DeadCodeElimination::isLiveInstr(
const MachineInstr *
MI)
const {
71 if (BM[R/32] & (1u << (R%32)))
82 SetQueue<NodeId> &WorkQ) {
88 if (!LiveNodes.count(RA.Id))
89 WorkQ.push_back(RA.Id);
94 SetQueue<NodeId> &WorkQ) {
97 if (!LiveNodes.count(UA.Id))
98 WorkQ.push_back(UA.Id);
101 LiveNodes.insert(
TA.Id);
105 SetQueue<NodeId> &WorkQ) {
107 if (!LiveNodes.count(DA.
Id))
108 WorkQ.push_back(DA.
Id);
126 SetQueue<NodeId> WorkQ;
129 scanInstr(IA, WorkQ);
131 while (!WorkQ.empty()) {
136 processDef(RA, WorkQ);
138 processUse(RA, WorkQ);
142 dbgs() <<
"Live nodes:\n";
151 if (LiveNodes.count(DA.
Id))
159 if (!LiveNodes.count(RA.Id))
160 DeadNodes.insert(RA.Id);
165 DeadInstrs.insert(IA.
Id);
172 return !DeadNodes.empty();
186 for (
auto I : Nodes) {
188 uint16_t
Type = BA.Addr->getType();
195 uint16_t
Kind = BA.Addr->getKind();
209 uint16_t KindA = A.
Addr->
getKind(), KindB =
B.Addr->getKind();
219 dbgs() <<
"Removing dead ref nodes:\n";
225 else if (DFG.
IsDef(RA))
238 dbgs() <<
"erasing: " << *
MI;
NodeList members(const DataFlowGraph &G) const
void push_back(const T &Elt)
bool isBranch(QueryType Type=AnyInBundle) const
Returns true if this is a conditional, unconditional, or indirect branch.
NodeList getAllReachingDefs(RegisterRef RefRR, NodeAddr< RefNode * > RefA, bool TopShadows, bool FullChain, const RegisterAggr &DefRRs)
bool mayStore(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly modify memory.
bool hasOrderedMemoryRef() const
Return true if this instruction may have an ordered or volatile memory reference, or if the informati...
iterator_range< mop_iterator > operands()
void unlinkUse(NodeAddr< UseNode * > UA, bool RemoveFromOwner)
NodeList getRelatedRefs(NodeAddr< InstrNode * > IA, NodeAddr< RefNode * > RA) const
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
unsigned getNumRegs() const
Return the number of registers this target has (useful for sizing arrays holding per register informa...
static bool IsDef(const NodeAddr< NodeBase * > BA)
bool empty() const
Determine if the SetVector is empty or not.
NodeAddr< NodeBase * > getOwner(const DataFlowGraph &G)
NodeList members_if(Predicate P, const DataFlowGraph &G) const
const TargetRegisterInfo & getTRI() const
bool isReturn(QueryType Type=AnyInBundle) const
The instances of the Type class are immutable: once they are created, they are never changed...
bool isReserved(unsigned PhysReg) const
isReserved - Returns true when PhysReg is a reserved register.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
bool hasUnmodeledSideEffects() const
Return true if this instruction has side effects that are not modeled by mayLoad / mayStore...
static bool IsCode(const NodeAddr< NodeBase * > BA)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
NodeAddr< FuncNode * > getFunc() const
static bool IsUse(const NodeAddr< NodeBase * > BA)
llvm_unreachable("Unknown RegBank!")
Representation of each machine instruction.
NodeAddr< NodeBase * > getOwner(const DataFlowGraph &G)
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
bool isCall(QueryType Type=AnyInBundle) const
bool erase(const SetVector< NodeId > &Nodes)
void removeMember(NodeAddr< NodeBase * > NA, const DataFlowGraph &G)
void unlinkDef(NodeAddr< DefNode * > DA, bool RemoveFromOwner)
A vector that has set insertion semantics.
NodeAddr< T > addr(NodeId N) const
void sort(Policy policy, RandomAccessIterator Start, RandomAccessIterator End, const Comparator &Comp=Comparator())