27#define DEBUG_TYPE "dead-mi-elimination"
29STATISTIC(NumDeletes,
"Number of dead instructions deleted");
32class DeadMachineInstructionElimImpl {
48 DeadMachineInstructionElim() : MachineFunctionPass(ID) {}
53 return DeadMachineInstructionElimImpl().runImpl(MF);
56 void getAnalysisUsage(AnalysisUsage &AU)
const override {
61 MachineFunctionProperties getRequiredProperties()
const override {
62 return MachineFunctionProperties().setIsSSA();
72 if (!DeadMachineInstructionElimImpl().
runImpl(MF))
79char DeadMachineInstructionElim::ID = 0;
83 "Remove dead machine instructions",
false,
false)
86 MRI = &MF.getRegInfo();
89 TII = ST.getInstrInfo();
92 bool NeedAnotherIteration;
93 bool AnyChanges = eliminateDeadMI(MF, NeedAnotherIteration);
94 while (NeedAnotherIteration)
95 eliminateDeadMI(MF, NeedAnotherIteration);
99bool DeadMachineInstructionElimImpl::eliminateDeadMI(
101 bool AnyChanges =
false;
114 if (
MI.isDebugInstr())
126 MI.eraseFromParent();
143 NeedAnotherIteration = !NeedsProcessing.
empty();
static bool runImpl(MachineFunction &MF)
const HexagonInstrInfo * TII
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
This file builds on the ADT/GraphTraits.h file to build a generic graph post order iterator.
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
LLVM_ABI void setPreservesCFG()
This function should be called by the pass, iff they do not:
Represents analyses that only rely on functions' control flow.
LLVM_ABI PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
A set of physical registers with utility functions to track liveness when walking backward/forward th...
void clear()
Clears the set.
LLVM_ABI void stepBackward(const MachineInstr &MI)
Simulates liveness when stepping backwards over an instruction(bundle).
void init(const TargetRegisterInfo &TRI)
(re-)initializes and clears the set.
LLVM_ABI bool available(const MachineRegisterInfo &MRI, MCRegister Reg) const
Returns true if register Reg and no aliasing register is in the set.
LLVM_ABI void addLiveOuts(const MachineBasicBlock &MBB)
Adds all live-out registers of basic block MBB.
A set of register units used to track register liveness.
An RAII based helper class to modify MachineFunctionProperties when running pass.
iterator_range< pred_iterator > predecessors()
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
Function & getFunction()
Return the LLVM function that this machine code represents.
Representation of each machine instruction.
MachineOperand class - Representation of each machine instruction operand.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
PreservedAnalyses & preserveSet()
Mark an analysis set as preserved.
Wrapper class representing virtual and physical registers.
constexpr bool isPhysical() const
Return true if the specified register number is in the physical register namespace.
bool erase(PtrType Ptr)
Remove pointer from the set.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
TargetInstrInfo - Interface to description of machine instruction set.
TargetSubtargetInfo - Generic base class for all target subtargets.
This is an optimization pass for GlobalISel generic memory operations.
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...
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
LLVM_ABI PreservedAnalyses getMachineFunctionPassPreservedAnalyses()
Returns the minimum set of Analyses that all machine function passes must preserve.
auto reverse(ContainerTy &&C)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
auto post_order(const T &G)
Post-order traversal of a graph.
LLVM_ABI char & DeadMachineInstructionElimID
DeadMachineInstructionElim - This pass removes dead machine instructions.