32 #define DEBUG_TYPE "dwarfdebug" 50 auto &Ranges = VarInstrRanges[Var];
51 if (!Ranges.empty() && Ranges.back().second ==
nullptr &&
52 Ranges.back().first->isIdenticalTo(MI)) {
54 <<
"\t" << Ranges.back().first <<
"\t" << MI <<
"\n");
57 Ranges.push_back(std::make_pair(&MI,
nullptr));
62 auto &Ranges = VarInstrRanges[Var];
64 assert(!Ranges.empty() && Ranges.back().second ==
nullptr);
68 Ranges.back().second = &
MI;
72 const auto &
I = VarInstrRanges.
find(Var);
73 if (
I == VarInstrRanges.
end())
75 const auto &Ranges =
I->second;
76 if (Ranges.empty() || Ranges.back().second !=
nullptr)
85 using RegDescribedVarsMap = std::map<unsigned, SmallVector<InlinedVariable, 1>>;
92 const auto &
I = RegVars.find(RegNo);
93 assert(RegNo != 0U &&
I != RegVars.end());
94 auto &VarSet =
I->second;
96 assert(VarPos != VarSet.end());
107 auto &VarSet = RegVars[RegNo];
109 VarSet.push_back(Var);
115 RegDescribedVarsMap::iterator
I,
120 for (
const auto &Var : I->second)
130 const auto &
I = RegVars.find(RegNo);
131 if (
I == RegVars.end())
140 if (LastMI == MBB.
end() || !LastMI->isReturn())
144 DebugLoc LastLoc = LastMI->getDebugLoc();
149 if (
I->getDebugLoc() != LastLoc)
155 return &*MBB.
begin();
163 for (
const auto &MBB : *MF) {
166 for (
const auto &
MI : MBB) {
168 if (&
MI == FirstEpilogueInst)
177 if (MO.isReg() && MO.isDef() && MO.getReg() &&
182 }
else if (MO.isRegMask()) {
198 RegDescribedVarsMap RegVars;
199 for (
const auto &MBB : *MF) {
200 for (
const auto &
MI : MBB) {
201 if (!
MI.isDebugInstr()) {
205 if (MO.isReg() && MO.isDef() && MO.getReg()) {
208 if (
MI.isCall() && MO.getReg() == SP)
219 if (ChangingRegs.test(*AI))
222 }
else if (MO.isRegMask()) {
225 for (
unsigned I : ChangingRegs.set_bits()) {
228 MO.clobbersPhysReg(
I)) {
238 if (
MI.isDebugLabel())
241 assert(
MI.getNumOperands() > 1 &&
"Invalid DBG_VALUE instruction!");
246 assert(RawVar->isValidLocationForIntrinsic(
MI.getDebugLoc()) &&
247 "Expected inlined-at fields to agree");
262 if (!MBB.empty() && &MBB != &MF->back()) {
263 for (
auto I = RegVars.begin(),
E = RegVars.end();
I !=
E;) {
266 ChangingRegs.test(CurElem->first))
273 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 275 dbgs() <<
"DbgValueHistoryMap:\n";
276 for (
const auto &VarRangePair : *
this) {
286 dbgs() << Location->getFilename() <<
":" << Location->getLine() <<
":" 287 << Location->getColumn();
289 dbgs() <<
"<unknown location>";
294 dbgs() <<
" Begin: " << *Range.first;
296 dbgs() <<
" End : " << *Range.second;
void calculateDbgValueHistory(const MachineFunction *MF, const TargetRegisterInfo *TRI, DbgValueHistoryMap &Result)
Compute iterated dominance frontiers using a linear time algorithm.
std::pair< const DILocalVariable *, const DILocation * > InlinedVariable
unsigned getReg() const
getReg - Returns the register number.
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
virtual const TargetLowering * getTargetLowering() const
static void collectChangingRegs(const MachineFunction *MF, const TargetRegisterInfo *TRI, BitVector &Regs)
void setBitsNotInMask(const uint32_t *Mask, unsigned MaskWords=~0u)
setBitsNotInMask - Add a bit to this vector for every '0' bit in Mask.
unsigned const TargetRegisterInfo * TRI
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds...
static void clobberRegisterUses(RegDescribedVarsMap &RegVars, RegDescribedVarsMap::iterator I, DbgValueHistoryMap &HistMap, const MachineInstr &ClobberingInstr)
StringRef getName() const
static void dropRegDescribedVar(RegDescribedVarsMap &RegVars, unsigned RegNo, InlinedVariable Var)
unsigned getNumOperands() const
Access to explicit operands of the instruction.
MachineBasicBlock iterator that automatically skips over MIs that are inside bundles (i...
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
iterator getLastNonDebugInstr()
Returns an iterator to the last non-debug instruction in the basic block, or end().
iterator find(const KeyT &Key)
unsigned getNumRegs() const
Return the number of registers this target has (useful for sizing arrays holding per register informa...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
void startInstrRange(InlinedVariable Var, const MachineInstr &MI)
MCRegAliasIterator enumerates all registers aliasing Reg.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
auto find(R &&Range, const T &Val) -> decltype(adl_begin(Range))
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly...
static unsigned isDescribedByReg(const MachineInstr &MI)
bool isDebugValue() const
MachineOperand class - Representation of each machine instruction operand.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
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.
const MachineBasicBlock * getParent() const
Representation of each machine instruction.
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
std::pair< const MachineInstr *, const MachineInstr * > InstrRange
void endInstrRange(InlinedVariable Var, const MachineInstr &MI)
bool isReg() const
isReg - Tests if this is a MO_Register operand.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
unsigned getStackPointerRegisterToSaveRestore() const
If a physical register, this specifies the register that llvm.savestack/llvm.restorestack should save...
const MachineOperand & getOperand(unsigned i) const
LLVM_DUMP_METHOD void dump() const
This file describes how to lower LLVM code to machine code.
unsigned getRegisterForVar(InlinedVariable Var) const
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.