26#define DEBUG_TYPE "processimpdefs"
46class ProcessImplicitDefs {
61char ProcessImplicitDefsLegacy::ID = 0;
65 "Process Implicit Definitions",
false,
false)
67void ProcessImplicitDefsLegacy::getAnalysisUsage(
AnalysisUsage &AU)
const {
74bool ProcessImplicitDefs::canTurnIntoImplicitDef(
MachineInstr *
MI) {
75 if (!
MI->isCopyLike() &&
76 !
MI->isInsertSubreg() &&
77 !
MI->isRegSequence() &&
80 for (
const MachineOperand &MO :
MI->all_uses())
86void ProcessImplicitDefs::processImplicitDef(MachineInstr *
MI) {
95 MachineInstr *UserMI = MO.getParent();
96 if (!canTurnIntoImplicitDef(UserMI))
99 UserMI->
setDesc(
TII->get(TargetOpcode::IMPLICIT_DEF));
100 WorkList.insert(UserMI);
102 MI->eraseFromParent();
108 for (
unsigned i =
MI->getNumOperands() - 1; i; --i)
109 MI->removeOperand(i);
115 bool ImplicitDefIsDead =
false;
116 bool SearchedWholeBlock =
true;
117 constexpr unsigned SearchLimit = 35;
119 for (++SearchMI; SearchMI != SearchE; ++SearchMI) {
120 if (SearchMI->isDebugInstr())
122 if (++
Count > SearchLimit) {
123 SearchedWholeBlock =
false;
126 for (MachineOperand &MO : SearchMI->operands()) {
134 if (
TRI->isSubRegisterEq(
Reg, SearchReg)) {
142 if (
TRI->isSubRegisterEq(SearchReg,
Reg)) {
143 ImplicitDefIsDead =
true;
151 if (ImplicitDefIsDead) {
159 if (ImplicitDefIsDead ||
160 (SearchedWholeBlock &&
MI->getParent()->succ_empty())) {
161 MI->eraseFromParent();
166bool ProcessImplicitDefsLegacy::runOnMachineFunction(MachineFunction &MF) {
167 return ProcessImplicitDefs().run(MF);
173 if (!ProcessImplicitDefs().
run(MF))
178 .preserve<AAManager>();
185 LLVM_DEBUG(
dbgs() <<
"********** PROCESS IMPLICIT DEFS **********\n"
186 <<
"********** Function: " << MF.
getName() <<
'\n');
193 assert(WorkList.empty() &&
"Inconsistent worklist state");
198 if (
MI.isImplicitDef())
199 WorkList.insert(&
MI);
201 if (WorkList.empty())
205 <<
" implicit defs.\n");
209 do processImplicitDef(WorkList.pop_back_val());
210 while (!WorkList.empty());
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
const HexagonInstrInfo * TII
Register const TargetRegisterInfo * TRI
Promote Memory to Register
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
This file implements a set that has insertion order iteration characteristics.
A wrapper pass to provide the legacy pass manager access to a suitably prepared AAResults object.
Represent the analysis usage information of a pass.
Represents analyses that only rely on functions' control flow.
Instructions::iterator instr_iterator
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.
Properties which a MachineFunction may have at a given point in time.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Representation of each machine instruction.
LLVM_ABI void setDesc(const MCInstrDesc &TID)
Replace the instruction descriptor (thus opcode) of the current instruction with a new one.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
iterator_range< use_nodbg_iterator > use_nodbg_operands(Register Reg) const
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
PreservedAnalyses & preserveSet()
Mark an analysis set as preserved.
LLVM_ABI PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
constexpr bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
constexpr bool isPhysical() const
Return true if the specified register number is in the physical register namespace.
A SetVector that performs no allocations if smaller than a certain size.
TargetInstrInfo - Interface to description of machine instruction set.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
virtual const TargetInstrInfo * getInstrInfo() const
virtual const TargetRegisterInfo * getRegisterInfo() const =0
Return the target's register information.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
LLVM_ABI PreservedAnalyses getMachineFunctionPassPreservedAnalyses()
Returns the minimum set of Analyses that all machine function passes must preserve.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ABI char & ProcessImplicitDefsID
ProcessImpicitDefs pass - This pass removes IMPLICIT_DEFs.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Count
LLVM_ABI Printable printMBBReference(const MachineBasicBlock &MBB)
Prints a machine basic block reference.