58 bool DeadCodeElimination::isLiveInstr(
const MachineInstr *
MI)
const {
72 SetQueue<NodeId> &WorkQ) {
78 if (!LiveNodes.count(RA.Id))
79 WorkQ.push_back(RA.Id);
84 SetQueue<NodeId> &WorkQ) {
87 if (!LiveNodes.count(UA.Id))
88 WorkQ.push_back(UA.Id);
91 LiveNodes.insert(
TA.Id);
95 SetQueue<NodeId> &WorkQ) {
97 if (!LiveNodes.count(DA.
Id))
98 WorkQ.push_back(DA.
Id);
116 SetQueue<NodeId> WorkQ;
119 scanInstr(IA, WorkQ);
121 while (!WorkQ.empty()) {
126 processDef(RA, WorkQ);
128 processUse(RA, WorkQ);
132 dbgs() <<
"Live nodes:\n";
141 if (LiveNodes.count(DA.
Id))
149 if (!LiveNodes.count(RA.Id))
150 DeadNodes.insert(RA.Id);
155 DeadInstrs.insert(IA.
Id);
162 return !DeadNodes.empty();
176 for (
auto I : Nodes) {
178 uint16_t
Type = BA.Addr->getType();
185 uint16_t
Kind = BA.Addr->getKind();
199 uint16_t KindA = A.
Addr->
getKind(), KindB =
B.Addr->getKind();
206 std::sort(DRNs.begin(), DRNs.end(), UsesFirst);
209 dbgs() <<
"Removing dead ref nodes:\n";
215 else if (DFG.
IsDef(RA))
228 dbgs() <<
"erasing: " << *
MI;
NodeList members(const DataFlowGraph &G) const
bool isBranch(QueryType Type=AnyInBundle) const
Returns true if this is a conditional, unconditional, or indirect branch.
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.
std::vector< NodeAddr< NodeBase * > > NodeList
static bool IsDef(const NodeAddr< NodeBase * > BA)
bool empty() const
Determine if the SetVector is empty or not.
NodeList getAllReachingDefs(RegisterRef RefRR, NodeAddr< RefNode * > RefA, bool FullChain, const RegisterAggr &DefRRs)
static GCRegistry::Add< OcamlGC > B("ocaml","ocaml 3.10-compatible GC")
NodeAddr< NodeBase * > getOwner(const DataFlowGraph &G)
NodeList members_if(Predicate P, const DataFlowGraph &G) 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.
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)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
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)
Representation of each machine instruction.
NodeAddr< NodeBase * > getOwner(const DataFlowGraph &G)
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
static GCRegistry::Add< ErlangGC > A("erlang","erlang-compatible garbage collector")