Go to the documentation of this file.
27 #define DEBUG_TYPE "removeredundantdebugvalues"
31 STATISTIC(NumRemovedBackward,
"Number of DBG_VALUEs removed (backward scan)");
32 STATISTIC(NumRemovedForward,
"Number of DBG_VALUEs removed (forward scan)");
40 RemoveRedundantDebugValues();
64 "Remove Redundant DEBUG_VALUE analysis",
false,
false)
67 RemoveRedundantDebugValues::RemoveRedundantDebugValues()
90 for (
auto &
MI :
MBB) {
91 if (
MI.isDebugValue()) {
93 MI.getDebugLoc()->getInlinedAt());
94 auto VMI = VariableMap.
find(Var);
101 if (
MI.isDebugValueList() && VMI != VariableMap.
end()) {
102 VariableMap.
erase(VMI);
109 if (VMI != VariableMap.
end())
110 VariableMap.
erase(VMI);
115 if (VMI == VariableMap.
end() ||
116 VMI->second.first->getReg() != Loc.
getReg() ||
117 VMI->second.second !=
MI.getDebugExpression()) {
118 VariableMap[Var] = {&Loc,
MI.getDebugExpression()};
124 DbgValsToBeRemoved.push_back(&
MI);
127 if (
MI.isMetaInstruction())
131 for (
auto &Var : VariableMap) {
132 auto &LocOp = Var.second.first;
133 if (
MI.modifiesRegister(LocOp->getReg(),
TRI))
134 VariableMap.
erase(Var.first);
138 for (
auto &Instr : DbgValsToBeRemoved) {
140 Instr->eraseFromParent();
144 return !DbgValsToBeRemoved.empty();
162 if (
MI.isDebugValue()) {
164 MI.getDebugLoc()->getInlinedAt());
165 auto R = VariableSet.
insert(Var);
170 if (
MI.isNonListDebugValue()) {
176 VariableSet.
erase(Var);
184 DbgValsToBeRemoved.push_back(&
MI);
193 for (
auto &Instr : DbgValsToBeRemoved) {
195 Instr->eraseFromParent();
196 ++NumRemovedBackward;
199 return !DbgValsToBeRemoved.empty();
202 bool RemoveRedundantDebugValues::reduceDbgValues(
MachineFunction &MF) {
205 bool Changed =
false;
207 for (
auto &
MBB : MF) {
215 bool RemoveRedundantDebugValues::runOnMachineFunction(
MachineFunction &MF) {
225 bool Changed = reduceDbgValues(MF);
This is an optimization pass for GlobalISel generic memory operations.
iterator erase(const_iterator CI)
static bool reduceDbgValsBackwardScan(MachineBasicBlock &MBB)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
DISubprogram * getSubprogram() const
Get the attached subprogram.
Implements a dense probed hash-table based set with some number of buckets stored inline.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
bool erase(const KeyT &Val)
std::pair< iterator, bool > insert(const ValueT &V)
unsigned const TargetRegisterInfo * TRI
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
static bool reduceDbgValsForwardScan(MachineBasicBlock &MBB)
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Represent the analysis usage information of a pass.
MachineOperand class - Representation of each machine instruction operand.
STATISTIC(NumFunctions, "Total number of functions")
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
Representation of each machine instruction.
Identifies a unique instance of a variable.
iterator find(const_arg_type_t< KeyT > Val)
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
Register getReg() const
getReg - Returns the register number.
void setPreservesCFG()
This function should be called by the pass, iff they do not:
Function & getFunction()
Return the LLVM function that this machine code represents.
void initializeRemoveRedundantDebugValuesPass(PassRegistry &)
bool erase(const ValueT &V)
auto reverse(ContainerTy &&C)
char & RemoveRedundantDebugValuesID
RemoveRedundantDebugValues pass.
INITIALIZE_PASS(RemoveRedundantDebugValues, DEBUG_TYPE, "Remove Redundant DEBUG_VALUE analysis", false, false) RemoveRedundantDebugValues
Default construct and initialize the pass.