23 #define DEBUG_TYPE "dwarfdebug"
41 auto &
Ranges = VarInstrRanges[Var];
42 if (!Ranges.empty() && Ranges.back().second ==
nullptr &&
43 Ranges.back().first->isIdenticalTo(&MI)) {
44 DEBUG(
dbgs() <<
"Coalescing identical DBG_VALUE entries:\n"
45 <<
"\t" << Ranges.back().first <<
"\t" << MI <<
"\n");
48 Ranges.push_back(std::make_pair(&MI,
nullptr));
53 auto &
Ranges = VarInstrRanges[Var];
55 assert(!
Ranges.empty() &&
Ranges.back().second ==
nullptr);
63 const auto &
I = VarInstrRanges.
find(Var);
64 if (
I == VarInstrRanges.
end())
75 typedef std::map<unsigned, SmallVector<InlinedVariable, 1>> RegDescribedVarsMap;
80 InlinedVariable Var) {
81 const auto &
I = RegVars.find(RegNo);
82 assert(RegNo != 0U &&
I != RegVars.end());
83 auto &VarSet =
I->second;
84 const auto &VarPos = std::find(VarSet.begin(), VarSet.end(), Var);
85 assert(VarPos != VarSet.end());
94 InlinedVariable Var) {
96 auto &VarSet = RegVars[RegNo];
97 assert(std::find(VarSet.begin(), VarSet.end(), Var) == VarSet.end());
98 VarSet.push_back(Var);
104 RegDescribedVarsMap::iterator
I,
109 for (
const auto &Var : I->second)
119 const auto &
I = RegVars.find(RegNo);
120 if (
I == RegVars.end())
133 template<
typename Callable>
138 if (!MO.isReg() || !MO.isDef() || !MO.getReg())
149 if (LastMI == MBB.
end() || !LastMI->isReturn())
153 DebugLoc LastLoc = LastMI->getDebugLoc();
158 if (
I->getDebugLoc() != LastLoc)
172 for (
const auto &MBB : *MF) {
175 for (
const auto &
MI : MBB) {
176 if (&
MI == FirstEpilogueInst)
190 RegDescribedVarsMap RegVars;
191 for (
const auto &MBB : *MF) {
192 for (
const auto &
MI : MBB) {
193 if (!
MI.isDebugValue()) {
197 if (ChangingRegs.test(RegNo))
203 assert(
MI.getNumOperands() > 1 &&
"Invalid DBG_VALUE instruction!");
208 assert(RawVar->isValidLocationForIntrinsic(
MI.getDebugLoc()) &&
209 "Expected inlined-at fields to agree");
210 InlinedVariable Var(RawVar,
MI.getDebugLoc()->getInlinedAt());
224 if (!MBB.empty() && &MBB != &MF->back()) {
225 for (
auto I = RegVars.begin(), E = RegVars.end();
I != E;) {
227 if (ChangingRegs.test(CurElem->first))
void calculateDbgValueHistory(const MachineFunction *MF, const TargetRegisterInfo *TRI, DbgValueHistoryMap &Result)
static void collectChangingRegs(const MachineFunction *MF, const TargetRegisterInfo *TRI, BitVector &Regs)
static void clobberRegisterUses(RegDescribedVarsMap &RegVars, RegDescribedVarsMap::iterator I, DbgValueHistoryMap &HistMap, const MachineInstr &ClobberingInstr)
iterator_range< mop_iterator > operands()
static void dropRegDescribedVar(RegDescribedVarsMap &RegVars, unsigned RegNo, InlinedVariable Var)
bool isReg() const
isReg - Tests if this is a MO_Register operand.
unsigned getNumOperands() const
Access to explicit operands of the instruction.
unsigned getNumRegs() const
Return the number of registers this target has (useful for sizing arrays holding per register informa...
iterator getLastNonDebugInstr()
getLastNonDebugInstr - returns an iterator to the last non-debug instruction in the basic block...
iterator find(const KeyT &Key)
const MachineBasicBlock * getParent() const
bool isDebugValue() const
const MachineOperand & getOperand(unsigned i) const
void startInstrRange(InlinedVariable Var, const MachineInstr &MI)
MCRegAliasIterator enumerates all registers aliasing Reg.
std::reverse_iterator< const_iterator > const_reverse_iterator
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
static unsigned isDescribedByReg(const MachineInstr &MI)
MachineOperand class - Representation of each machine instruction operand.
static const MachineInstr * getFirstEpilogueInst(const MachineBasicBlock &MBB)
static void addRegDescribedVar(RegDescribedVarsMap &RegVars, unsigned RegNo, InlinedVariable Var)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
static void applyToClobberedRegisters(const MachineInstr &MI, const TargetRegisterInfo *TRI, Callable Func)
Representation of each machine instruction.
void endInstrRange(InlinedVariable Var, const MachineInstr &MI)
unsigned getReg() const
getReg - Returns the register number.
unsigned getRegisterForVar(InlinedVariable Var) const
std::pair< const DILocalVariable *, const DILocation * > InlinedVariable