32 #define DEBUG_TYPE "dwarfdebug" 59 auto &
Entries = VarEntries[Var];
60 if (!Entries.empty() && Entries.back().isDbgValue() &&
61 !Entries.back().isClosed() &&
62 Entries.back().getInstr()->isIdenticalTo(MI)) {
64 <<
"\t" << Entries.back().getInstr() <<
"\t" << MI
68 Entries.emplace_back(&MI, Entry::DbgValue);
69 NewIndex = Entries.size() - 1;
75 auto &
Entries = VarEntries[Var];
87 assert(isDbgValue() &&
"Setting end index for non-debug value");
88 assert(!isClosed() &&
"End index has already been set");
94 LabelInstr[Label] = &
MI;
101 using RegDescribedVarsMap = std::map<unsigned, SmallVector<InlinedEntity, 1>>;
107 using DbgValueEntriesMap = std::map<InlinedEntity, SmallSet<EntryIndex, 1>>;
114 const auto &
I = RegVars.find(RegNo);
115 assert(RegNo != 0U &&
I != RegVars.end());
116 auto &VarSet =
I->second;
118 assert(VarPos != VarSet.end());
119 VarSet.erase(VarPos);
129 auto &VarSet = RegVars[RegNo];
131 VarSet.push_back(Var);
138 DbgValueEntriesMap &LiveEntries,
140 EntryIndex ClobberIndex = HistMap.
startClobber(Var, ClobberingInstr);
144 for (
auto Index : LiveEntries[Var]) {
146 assert(
Entry.isDbgValue() &&
"Not a DBG_VALUE in LiveEntries");
149 Entry.endEntry(ClobberIndex);
154 for (
auto Index : IndicesToErase)
155 LiveEntries[Var].erase(
Index);
160 RegDescribedVarsMap &RegVars,
161 DbgValueEntriesMap &LiveEntries,
171 for (
auto Index : LiveEntries[Var]) {
173 assert(
Entry.isDbgValue() &&
"Not a DBG_VALUE in LiveEntries");
178 Entry.endEntry(NewIndex);
181 TrackedRegs[
Reg] |= !Overlaps;
187 if (!TrackedRegs.
count(NewReg))
189 LiveEntries[Var].insert(NewIndex);
190 TrackedRegs[NewReg] =
true;
194 for (
auto I : TrackedRegs)
199 for (
auto Index : IndicesToErase)
200 LiveEntries[Var].erase(
Index);
201 LiveEntries[Var].insert(NewIndex);
208 RegDescribedVarsMap::iterator
I,
210 DbgValueEntriesMap &LiveEntries,
214 for (
const auto &Var : I->second)
223 DbgValueEntriesMap &LiveEntries,
225 const auto &
I = RegVars.find(RegNo);
226 if (
I == RegVars.end())
238 RegDescribedVarsMap RegVars;
239 DbgValueEntriesMap LiveEntries;
240 for (
const auto &MBB : *MF) {
241 for (
const auto &
MI : MBB) {
242 if (
MI.isDebugValue()) {
243 assert(
MI.getNumOperands() > 1 &&
"Invalid DBG_VALUE instruction!");
248 assert(RawVar->isValidLocationForIntrinsic(
MI.getDebugLoc()) &&
249 "Expected inlined-at fields to agree");
250 InlinedEntity Var(RawVar,
MI.getDebugLoc()->getInlinedAt());
253 }
else if (
MI.isDebugLabel()) {
254 assert(
MI.getNumOperands() == 1 &&
"Invalid DBG_LABEL instruction!");
255 const DILabel *RawLabel =
MI.getDebugLabel();
256 assert(RawLabel->isValidLocationForIntrinsic(
MI.getDebugLoc()) &&
257 "Expected inlined-at fields to agree");
261 InlinedEntity L(RawLabel,
MI.getDebugLoc()->getInlinedAt());
267 if (
MI.isMetaInstruction())
273 if (MO.isReg() && MO.isDef() && MO.getReg()) {
276 if (
MI.isCall() && MO.getReg() == SP)
287 else if (MO.getReg() != FrameReg ||
294 }
else if (MO.isRegMask()) {
299 for (
auto It : RegVars) {
300 unsigned int Reg = It.first;
302 MO.clobbersPhysReg(Reg))
306 for (
unsigned Reg : RegsToClobber) {
316 if (!MBB.empty() && &MBB != &MF->back()) {
318 for (
auto &Pair : LiveEntries) {
319 if (Pair.second.empty())
323 EntryIndex ClobIdx = DbgValues.
startClobber(Pair.first, MBB.back());
326 for (EntryIndex Idx : Pair.second) {
339 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 341 dbgs() <<
"DbgValueHistoryMap:\n";
342 for (
const auto &VarRangePair : *
this) {
352 dbgs() << Location->getFilename() <<
":" << Location->getLine() <<
":" 353 << Location->getColumn();
355 dbgs() <<
"<unknown location>";
360 const auto &
Entry =
E.value();
361 dbgs() <<
" Entry[" <<
E.index() <<
"]: ";
363 dbgs() <<
"Debug value\n";
365 dbgs() <<
"Clobber\n";
369 dbgs() <<
" - Valid until end of function\n";
For each inlined instance of a source-level label, keep the corresponding DBG_LABEL instruction...
reference emplace_back(ArgTypes &&... Args)
bool isDebugLabel() const
bool isEntryValue() const
Check if the expression consists of exactly one entry value operand.
static void dropRegDescribedVar(RegDescribedVarsMap &RegVars, unsigned RegNo, InlinedEntity Var)
static bool fragmentsOverlap(const FragmentInfo &A, const FragmentInfo &B)
Check if fragments overlap between a pair of FragmentInfos.
This class represents lattice values for constants.
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds...
void push_back(const T &Elt)
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
virtual const TargetLowering * getTargetLowering() const
unsigned const TargetRegisterInfo * TRI
For each user variable, keep a list of instruction ranges where this variable is accessible.
static Register isDescribedByReg(const MachineInstr &MI)
void calculateDbgEntityHistory(const MachineFunction *MF, const TargetRegisterInfo *TRI, DbgValueHistoryMap &DbgValues, DbgLabelInstrMap &DbgLabels)
std::pair< const DINode *, const DILocation * > InlinedEntity
StringRef getName() const
unsigned getNumOperands() const
Retuns the total number of operands.
void endEntry(EntryIndex EndIndex)
static void clobberRegEntries(InlinedEntity Var, unsigned RegNo, const MachineInstr &ClobberingInstr, DbgValueEntriesMap &LiveEntries, DbgValueHistoryMap &HistMap)
Create a clobbering entry and end all open debug value entries for Var that are described by RegNo us...
static void addRegDescribedVar(RegDescribedVarsMap &RegVars, unsigned RegNo, InlinedEntity Var)
size_t EntryIndex
Index in the entry vector.
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
EntryIndex getEndIndex() const
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")
Specifies a change in a variable's debug value history.
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...
std::pair< const DINode *, const DILocation * > InlinedEntity
const DIExpression * getDebugExpression() const
Return the complex address expression referenced by this DBG_VALUE instruction.
void addInstr(InlinedEntity Label, const MachineInstr &MI)
bool isDebugValue() const
MachineOperand class - Representation of each machine instruction operand.
virtual Register getFrameRegister(const MachineFunction &MF) const =0
Debug information queries.
Promote Memory to Register
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
static cl::opt< bool > NoEntry("spp-no-entry", cl::Hidden, cl::init(false))
Representation of each machine instruction.
Entry & getEntry(InlinedEntity Var, EntryIndex Index)
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
unsigned getStackPointerRegisterToSaveRestore() const
If a physical register, this specifies the register that llvm.savestack/llvm.restorestack should save...
static void clobberRegisterUses(RegDescribedVarsMap &RegVars, RegDescribedVarsMap::iterator I, DbgValueHistoryMap &HistMap, DbgValueEntriesMap &LiveEntries, const MachineInstr &ClobberingInstr)
const MachineInstr * getInstr() const
Register getReg() const
getReg - Returns the register number.
const MachineOperand & getOperand(unsigned i) const
bool startDbgValue(InlinedEntity Var, const MachineInstr &MI, EntryIndex &NewIndex)
LLVM_DUMP_METHOD void dump() const
EntryIndex startClobber(InlinedEntity Var, const MachineInstr &MI)
Wrapper class representing virtual and physical registers.
detail::enumerator< R > enumerate(R &&TheRange)
Given an input range, returns a new range whose values are are pair (A,B) such that A is the 0-based ...
This file describes how to lower LLVM code to machine code.
static void handleNewDebugValue(InlinedEntity Var, const MachineInstr &DV, RegDescribedVarsMap &RegVars, DbgValueEntriesMap &LiveEntries, DbgValueHistoryMap &HistMap)
Add a new debug value for Var. Closes all overlapping debug values.
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.