Movatterモバイル変換


[0]ホーム

URL:


LLVM 20.0.0git
LiveDebugVariables.cpp
Go to the documentation of this file.
1//===- LiveDebugVariables.cpp - Tracking debug info variables -------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements the LiveDebugVariables analysis.
10//
11// Remove all DBG_VALUE instructions referencing virtual registers and replace
12// them with a data structure tracking where live user variables are kept - in a
13// virtual register or in a stack slot.
14//
15// Allow the data structure to be updated during register allocation when values
16// are moved between registers and stack slots. Finally emit new DBG_VALUE
17// instructions after register allocation is complete.
18//
19//===----------------------------------------------------------------------===//
20
21#include "llvm/CodeGen/LiveDebugVariables.h"
22#include "llvm/ADT/ArrayRef.h"
23#include "llvm/ADT/DenseMap.h"
24#include "llvm/ADT/IntervalMap.h"
25#include "llvm/ADT/MapVector.h"
26#include "llvm/ADT/STLExtras.h"
27#include "llvm/ADT/SmallSet.h"
28#include "llvm/ADT/SmallVector.h"
29#include "llvm/ADT/Statistic.h"
30#include "llvm/ADT/StringRef.h"
31#include "llvm/BinaryFormat/Dwarf.h"
32#include "llvm/CodeGen/LexicalScopes.h"
33#include "llvm/CodeGen/LiveInterval.h"
34#include "llvm/CodeGen/LiveIntervals.h"
35#include "llvm/CodeGen/MachineBasicBlock.h"
36#include "llvm/CodeGen/MachineDominators.h"
37#include "llvm/CodeGen/MachineFunction.h"
38#include "llvm/CodeGen/MachineInstr.h"
39#include "llvm/CodeGen/MachineInstrBuilder.h"
40#include "llvm/CodeGen/MachineOperand.h"
41#include "llvm/CodeGen/MachinePassManager.h"
42#include "llvm/CodeGen/MachineRegisterInfo.h"
43#include "llvm/CodeGen/SlotIndexes.h"
44#include "llvm/CodeGen/TargetInstrInfo.h"
45#include "llvm/CodeGen/TargetOpcodes.h"
46#include "llvm/CodeGen/TargetRegisterInfo.h"
47#include "llvm/CodeGen/TargetSubtargetInfo.h"
48#include "llvm/CodeGen/VirtRegMap.h"
49#include "llvm/Config/llvm-config.h"
50#include "llvm/IR/DebugInfoMetadata.h"
51#include "llvm/IR/DebugLoc.h"
52#include "llvm/IR/Function.h"
53#include "llvm/InitializePasses.h"
54#include "llvm/Pass.h"
55#include "llvm/Support/Casting.h"
56#include "llvm/Support/CommandLine.h"
57#include "llvm/Support/Debug.h"
58#include "llvm/Support/raw_ostream.h"
59#include <algorithm>
60#include <cassert>
61#include <iterator>
62#include <map>
63#include <memory>
64#include <optional>
65#include <utility>
66
67using namespacellvm;
68
69#define DEBUG_TYPE "livedebugvars"
70
71staticcl::opt<bool>
72EnableLDV("live-debug-variables",cl::init(true),
73cl::desc("Enable the live debug variables pass"),cl::Hidden);
74
75STATISTIC(NumInsertedDebugValues,"Number of DBG_VALUEs inserted");
76STATISTIC(NumInsertedDebugLabels,"Number of DBG_LABELs inserted");
77
78charLiveDebugVariablesWrapperLegacy::ID = 0;
79
80INITIALIZE_PASS_BEGIN(LiveDebugVariablesWrapperLegacy,DEBUG_TYPE,
81"Debug Variable Analysis",false,false)
82INITIALIZE_PASS_DEPENDENCY(MachineDominatorTreeWrapperPass)
83INITIALIZE_PASS_DEPENDENCY(LiveIntervalsWrapperPass)
84INITIALIZE_PASS_END(LiveDebugVariablesWrapperLegacy,DEBUG_TYPE,
85 "Debug VariableAnalysis",false,true)
86
87voidLiveDebugVariablesWrapperLegacy::getAnalysisUsage(
88AnalysisUsage &AU) const{
89 AU.addRequired<MachineDominatorTreeWrapperPass>();
90 AU.addRequiredTransitive<LiveIntervalsWrapperPass>();
91 AU.setPreservesAll();
92MachineFunctionPass::getAnalysisUsage(AU);
93}
94
95LiveDebugVariablesWrapperLegacy::LiveDebugVariablesWrapperLegacy()
96 :MachineFunctionPass(ID) {
97initializeLiveDebugVariablesWrapperLegacyPass(
98 *PassRegistry::getPassRegistry());
99}
100
101enum :unsigned {UndefLocNo = ~0U };
102
103namespace{
104/// Describes a debug variable value by location number and expression along
105/// with some flags about the original usage of the location.
106classDbgVariableValue {
107public:
108 DbgVariableValue(ArrayRef<unsigned> NewLocs,bool WasIndirect,bool WasList,
109constDIExpression &Expr)
110 : WasIndirect(WasIndirect), WasList(WasList),Expression(&Expr) {
111assert(!(WasIndirect && WasList) &&
112"DBG_VALUE_LISTs should not be indirect.");
113SmallVector<unsigned> LocNoVec;
114for (unsigned LocNo : NewLocs) {
115auto It =find(LocNoVec, LocNo);
116if (It == LocNoVec.end())
117 LocNoVec.push_back(LocNo);
118else {
119// Loc duplicates an element in LocNos; replace references to Op
120// with references to the duplicating element.
121unsigned OpIdx = LocNoVec.size();
122unsigned DuplicatingIdx = std::distance(LocNoVec.begin(), It);
123Expression =
124DIExpression::replaceArg(Expression, OpIdx, DuplicatingIdx);
125 }
126 }
127// FIXME: Debug values referencing 64+ unique machine locations are rare and
128// currently unsupported for performance reasons. If we can verify that
129// performance is acceptable for such debug values, we can increase the
130// bit-width of LocNoCount to 14 to enable up to 16384 unique machine
131// locations. We will also need to verify that this does not cause issues
132// with LiveDebugVariables' use of IntervalMap.
133if (LocNoVec.size() < 64) {
134 LocNoCount = LocNoVec.size();
135if (LocNoCount > 0) {
136 LocNos = std::make_unique<unsigned[]>(LocNoCount);
137 std::copy(LocNoVec.begin(), LocNoVec.end(), loc_nos_begin());
138 }
139 }else {
140LLVM_DEBUG(dbgs() <<"Found debug value with 64+ unique machine "
141"locations, dropping...\n");
142 LocNoCount = 1;
143// Turn this into an undef debug value list; right now, the simplest form
144// of this is an expression with one arg, and an undef debug operand.
145Expression =
146 DIExpression::get(Expr.getContext(), {dwarf::DW_OP_LLVM_arg, 0});
147if (auto FragmentInfoOpt = Expr.getFragmentInfo())
148Expression = *DIExpression::createFragmentExpression(
149Expression, FragmentInfoOpt->OffsetInBits,
150 FragmentInfoOpt->SizeInBits);
151 LocNos = std::make_unique<unsigned[]>(LocNoCount);
152 LocNos[0] =UndefLocNo;
153 }
154 }
155
156 DbgVariableValue() : LocNoCount(0), WasIndirect(false), WasList(false) {}
157 DbgVariableValue(const DbgVariableValue &Other)
158 : LocNoCount(Other.LocNoCount), WasIndirect(Other.getWasIndirect()),
159 WasList(Other.getWasList()),Expression(Other.getExpression()) {
160if (Other.getLocNoCount()) {
161 LocNos.reset(newunsigned[Other.getLocNoCount()]);
162 std::copy(Other.loc_nos_begin(),Other.loc_nos_end(), loc_nos_begin());
163 }
164 }
165
166 DbgVariableValue &operator=(const DbgVariableValue &Other) {
167if (this == &Other)
168return *this;
169if (Other.getLocNoCount()) {
170 LocNos.reset(newunsigned[Other.getLocNoCount()]);
171 std::copy(Other.loc_nos_begin(),Other.loc_nos_end(), loc_nos_begin());
172 }else {
173 LocNos.release();
174 }
175 LocNoCount =Other.getLocNoCount();
176 WasIndirect =Other.getWasIndirect();
177 WasList =Other.getWasList();
178Expression =Other.getExpression();
179return *this;
180 }
181
182constDIExpression *getExpression() const{returnExpression; }
183uint8_t getLocNoCount() const{return LocNoCount; }
184bool containsLocNo(unsigned LocNo) const{
185returnis_contained(loc_nos(), LocNo);
186 }
187bool getWasIndirect() const{return WasIndirect; }
188bool getWasList() const{return WasList; }
189boolisUndef() const{return LocNoCount == 0 || containsLocNo(UndefLocNo); }
190
191 DbgVariableValue decrementLocNosAfterPivot(unsigned Pivot) const{
192SmallVector<unsigned, 4> NewLocNos;
193for (unsigned LocNo : loc_nos())
194 NewLocNos.push_back(LocNo !=UndefLocNo && LocNo > Pivot ? LocNo - 1
195 : LocNo);
196return DbgVariableValue(NewLocNos, WasIndirect, WasList, *Expression);
197 }
198
199 DbgVariableValue remapLocNos(ArrayRef<unsigned> LocNoMap) const{
200SmallVector<unsigned> NewLocNos;
201for (unsigned LocNo : loc_nos())
202// Undef values don't exist in locations (and thus not in LocNoMap
203// either) so skip over them. See getLocationNo().
204 NewLocNos.push_back(LocNo ==UndefLocNo ?UndefLocNo : LocNoMap[LocNo]);
205return DbgVariableValue(NewLocNos, WasIndirect, WasList, *Expression);
206 }
207
208 DbgVariableValue changeLocNo(unsigned OldLocNo,unsigned NewLocNo) const{
209SmallVector<unsigned> NewLocNos;
210 NewLocNos.assign(loc_nos_begin(), loc_nos_end());
211auto OldLocIt =find(NewLocNos, OldLocNo);
212assert(OldLocIt != NewLocNos.end() &&"Old location must be present.");
213 *OldLocIt = NewLocNo;
214return DbgVariableValue(NewLocNos, WasIndirect, WasList, *Expression);
215 }
216
217bool hasLocNoGreaterThan(unsigned LocNo) const{
218returnany_of(loc_nos(),
219 [LocNo](unsigned ThisLocNo) {return ThisLocNo > LocNo; });
220 }
221
222void printLocNos(llvm::raw_ostream &OS) const{
223for (constunsigned &Loc : loc_nos())
224OS << (&Loc == loc_nos_begin() ?" " :", ") << Loc;
225 }
226
227friendinlinebooloperator==(const DbgVariableValue &LHS,
228const DbgVariableValue &RHS) {
229if (std::tie(LHS.LocNoCount,LHS.WasIndirect,LHS.WasList,
230LHS.Expression) !=
231 std::tie(RHS.LocNoCount,RHS.WasIndirect,RHS.WasList,RHS.Expression))
232returnfalse;
233return std::equal(LHS.loc_nos_begin(),LHS.loc_nos_end(),
234RHS.loc_nos_begin());
235 }
236
237friendinlinebooloperator!=(const DbgVariableValue &LHS,
238const DbgVariableValue &RHS) {
239return !(LHS ==RHS);
240 }
241
242unsigned *loc_nos_begin() {return LocNos.get(); }
243constunsigned *loc_nos_begin() const{return LocNos.get(); }
244unsigned *loc_nos_end() {return LocNos.get() + LocNoCount; }
245constunsigned *loc_nos_end() const{return LocNos.get() + LocNoCount; }
246ArrayRef<unsigned> loc_nos() const{
247returnArrayRef<unsigned>(LocNos.get(), LocNoCount);
248 }
249
250private:
251// IntervalMap requires the value object to be very small, to the extent
252// that we do not have enough room for an std::vector. Using a C-style array
253// (with a unique_ptr wrapper for convenience) allows us to optimize for this
254// specific case by packing the array size into only 6 bits (it is highly
255// unlikely that any debug value will need 64+ locations).
256 std::unique_ptr<unsigned[]> LocNos;
257uint8_t LocNoCount : 6;
258bool WasIndirect : 1;
259bool WasList : 1;
260constDIExpression *Expression =nullptr;
261};
262}// namespace
263
264/// Map of where a user value is live to that value.
265usingLocMap =IntervalMap<SlotIndex, DbgVariableValue, 4>;
266
267/// Map of stack slot offsets for spilled locations.
268/// Non-spilled locations are not added to the map.
269usingSpillOffsetMap =DenseMap<unsigned, unsigned>;
270
271/// Cache to save the location where it can be used as the starting
272/// position as input for calling MachineBasicBlock::SkipPHIsLabelsAndDebug.
273/// This is to prevent MachineBasicBlock::SkipPHIsLabelsAndDebug from
274/// repeatedly searching the same set of PHIs/Labels/Debug instructions
275/// if it is called many times for the same block.
276usingBlockSkipInstsMap =
277DenseMap<MachineBasicBlock *, MachineBasicBlock::iterator>;
278
279namespace{
280
281/// A user value is a part of a debug info user variable.
282///
283/// A DBG_VALUE instruction notes that (a sub-register of) a virtual register
284/// holds part of a user variable. The part is identified by a byte offset.
285///
286/// UserValues are grouped into equivalence classes for easier searching. Two
287/// user values are related if they are held by the same virtual register. The
288/// equivalence class is the transitive closure of that relation.
289classUserValue {
290usingLDVImpl =LiveDebugVariables::LDVImpl;
291
292constDILocalVariable *Variable;///< The debug info variable we are part of.
293 /// The part of the variable we describe.
294const std::optional<DIExpression::FragmentInfo> Fragment;
295DebugLoc dl;///< The debug location for the variable. This is
296 ///< used by dwarf writer to find lexical scope.
297 UserValue *leader;///< Equivalence class leader.
298 UserValue *next =nullptr;///< Next value in equivalence class, or null.
299
300 /// Numbered locations referenced by locmap.
301SmallVector<MachineOperand, 4> locations;
302
303 /// Map of slot indices where this value is live.
304LocMap locInts;
305
306 /// Set of interval start indexes that have been trimmed to the
307 /// lexical scope.
308SmallSet<SlotIndex, 2> trimmedDefs;
309
310 /// Insert a DBG_VALUE into MBB at Idx for DbgValue.
311void insertDebugValue(MachineBasicBlock *MBB,SlotIndex StartIdx,
312SlotIndex StopIdx, DbgVariableValueDbgValue,
313ArrayRef<bool> LocSpills,
314ArrayRef<unsigned> SpillOffsets,LiveIntervals &LIS,
315constTargetInstrInfo &TII,
316constTargetRegisterInfo &TRI,
317BlockSkipInstsMap &BBSkipInstsMap);
318
319 /// Replace OldLocNo ranges with NewRegs ranges where NewRegs
320 /// is live. Returns true if any changes were made.
321bool splitLocation(unsigned OldLocNo,ArrayRef<Register> NewRegs,
322LiveIntervals &LIS);
323
324public:
325 /// Create a new UserValue.
326 UserValue(constDILocalVariable *var,
327 std::optional<DIExpression::FragmentInfo> Fragment,DebugLoc L,
328LocMap::Allocator &alloc)
329 : Variable(var), Fragment(Fragment), dl(std::move(L)), leader(this),
330 locInts(alloc) {}
331
332 /// Get the leader of this value's equivalence class.
333 UserValue *getLeader() {
334 UserValue *l = leader;
335while (l != l->leader)
336 l = l->leader;
337return leader = l;
338 }
339
340 /// Return the next UserValue in the equivalence class.
341 UserValue *getNext() const{return next; }
342
343 /// Merge equivalence classes.
344static UserValue *merge(UserValue *L1, UserValue *L2) {
345 L2 = L2->getLeader();
346if (!L1)
347return L2;
348 L1 = L1->getLeader();
349if (L1 == L2)
350return L1;
351// Splice L2 before L1's members.
352 UserValue *End = L2;
353while (End->next) {
354End->leader = L1;
355End =End->next;
356 }
357End->leader = L1;
358End->next = L1->next;
359 L1->next = L2;
360return L1;
361 }
362
363 /// Return the location number that matches Loc.
364 ///
365 /// For undef values we always return location number UndefLocNo without
366 /// inserting anything in locations. Since locations is a vector and the
367 /// location number is the position in the vector and UndefLocNo is ~0,
368 /// we would need a very big vector to put the value at the right position.
369unsigned getLocationNo(constMachineOperand &LocMO) {
370if (LocMO.isReg()) {
371if (LocMO.getReg() == 0)
372returnUndefLocNo;
373// For register locations we dont care about use/def and other flags.
374for (unsigned i = 0, e = locations.size(); i != e; ++i)
375if (locations[i].isReg() &&
376 locations[i].getReg() == LocMO.getReg() &&
377 locations[i].getSubReg() == LocMO.getSubReg())
378return i;
379 }else
380for (unsigned i = 0, e = locations.size(); i != e; ++i)
381if (LocMO.isIdenticalTo(locations[i]))
382return i;
383 locations.push_back(LocMO);
384// We are storing a MachineOperand outside a MachineInstr.
385 locations.back().clearParent();
386// Don't store def operands.
387if (locations.back().isReg()) {
388if (locations.back().isDef())
389 locations.back().setIsDead(false);
390 locations.back().setIsUse();
391 }
392return locations.size() - 1;
393 }
394
395 /// Remove (recycle) a location number. If \p LocNo still is used by the
396 /// locInts nothing is done.
397void removeLocationIfUnused(unsigned LocNo) {
398// Bail out if LocNo still is used.
399for (LocMap::const_iteratorI = locInts.begin();I.valid(); ++I) {
400const DbgVariableValue &DbgValue =I.value();
401if (DbgValue.containsLocNo(LocNo))
402return;
403 }
404// Remove the entry in the locations vector, and adjust all references to
405// location numbers above the removed entry.
406 locations.erase(locations.begin() + LocNo);
407for (LocMap::iteratorI = locInts.begin();I.valid(); ++I) {
408const DbgVariableValue &DbgValue =I.value();
409if (DbgValue.hasLocNoGreaterThan(LocNo))
410I.setValueUnchecked(DbgValue.decrementLocNosAfterPivot(LocNo));
411 }
412 }
413
414 /// Ensure that all virtual register locations are mapped.
415void mapVirtRegs(LDVImpl *LDV);
416
417 /// Add a definition point to this user value.
418void addDef(SlotIndexIdx,ArrayRef<MachineOperand> LocMOs,bool IsIndirect,
419bool IsList,constDIExpression &Expr) {
420SmallVector<unsigned> Locs;
421for (constMachineOperand &Op : LocMOs)
422 Locs.push_back(getLocationNo(Op));
423 DbgVariableValueDbgValue(Locs, IsIndirect, IsList, Expr);
424// Add a singular (Idx,Idx) -> value mapping.
425LocMap::iteratorI = locInts.find(Idx);
426if (!I.valid() ||I.start() !=Idx)
427I.insert(Idx,Idx.getNextSlot(), std::move(DbgValue));
428else
429// A later DBG_VALUE at the same SlotIndex overrides the old location.
430I.setValue(std::move(DbgValue));
431 }
432
433 /// Extend the current definition as far as possible down.
434 ///
435 /// Stop when meeting an existing def or when leaving the live
436 /// range of VNI. End points where VNI is no longer live are added to Kills.
437 ///
438 /// We only propagate DBG_VALUES locally here. LiveDebugValues performs a
439 /// data-flow analysis to propagate them beyond basic block boundaries.
440 ///
441 /// \param Idx Starting point for the definition.
442 /// \param DbgValue value to propagate.
443 /// \param LiveIntervalInfo For each location number key in this map,
444 /// restricts liveness to where the LiveRange has the value equal to the\
445 /// VNInfo.
446 /// \param [out] Kills Append end points of VNI's live range to Kills.
447 /// \param LIS Live intervals analysis.
448void
449 extendDef(SlotIndexIdx, DbgVariableValueDbgValue,
450SmallDenseMap<unsigned, std::pair<LiveRange *, const VNInfo *>>
451 &LiveIntervalInfo,
452 std::optional<std::pair<SlotIndex,SmallVector<unsigned>>> &Kills,
453LiveIntervals &LIS);
454
455 /// The value in LI may be copies to other registers. Determine if
456 /// any of the copies are available at the kill points, and add defs if
457 /// possible.
458 ///
459 /// \param DbgValue Location number of LI->reg, and DIExpression.
460 /// \param LocIntervals Scan for copies of the value for each location in the
461 /// corresponding LiveInterval->reg.
462 /// \param KilledAt The point where the range of DbgValue could be extended.
463 /// \param [in,out] NewDefs Append (Idx, DbgValue) of inserted defs here.
464void addDefsFromCopies(
465 DbgVariableValueDbgValue,
466SmallVectorImpl<std::pair<unsigned, LiveInterval *>> &LocIntervals,
467SlotIndex KilledAt,
468SmallVectorImpl<std::pair<SlotIndex, DbgVariableValue>> &NewDefs,
469MachineRegisterInfo &MRI,LiveIntervals &LIS);
470
471 /// Compute the live intervals of all locations after collecting all their
472 /// def points.
473void computeIntervals(MachineRegisterInfo &MRI,constTargetRegisterInfo &TRI,
474LiveIntervals &LIS,LexicalScopes &LS);
475
476 /// Replace OldReg ranges with NewRegs ranges where NewRegs is
477 /// live. Returns true if any changes were made.
478bool splitRegister(Register OldReg,ArrayRef<Register> NewRegs,
479LiveIntervals &LIS);
480
481 /// Rewrite virtual register locations according to the provided virtual
482 /// register map. Record the stack slot offsets for the locations that
483 /// were spilled.
484void rewriteLocations(VirtRegMap &VRM,constMachineFunction &MF,
485constTargetInstrInfo &TII,
486constTargetRegisterInfo &TRI,
487SpillOffsetMap &SpillOffsets);
488
489 /// Recreate DBG_VALUE instruction from data structures.
490void emitDebugValues(VirtRegMap *VRM,LiveIntervals &LIS,
491constTargetInstrInfo &TII,
492constTargetRegisterInfo &TRI,
493constSpillOffsetMap &SpillOffsets,
494BlockSkipInstsMap &BBSkipInstsMap);
495
496 /// Return DebugLoc of this UserValue.
497constDebugLoc &getDebugLoc() {return dl; }
498
499voidprint(raw_ostream &,constTargetRegisterInfo *);
500};
501
502/// A user label is a part of a debug info user label.
503classUserLabel {
504constDILabel *Label;///< The debug info label we are part of.
505DebugLoc dl;///< The debug location for the label. This is
506 ///< used by dwarf writer to find lexical scope.
507SlotIndex loc;///< Slot used by the debug label.
508
509 /// Insert a DBG_LABEL into MBB at Idx.
510void insertDebugLabel(MachineBasicBlock *MBB,SlotIndexIdx,
511LiveIntervals &LIS,constTargetInstrInfo &TII,
512BlockSkipInstsMap &BBSkipInstsMap);
513
514public:
515 /// Create a new UserLabel.
516 UserLabel(constDILabel *label,DebugLoc L,SlotIndexIdx)
517 : Label(label), dl(std::move(L)), loc(Idx) {}
518
519 /// Does this UserLabel match the parameters?
520bool matches(constDILabel *L,constDILocation *IA,
521constSlotIndexIndex) const{
522return Label == L && dl->getInlinedAt() == IA && loc ==Index;
523 }
524
525 /// Recreate DBG_LABEL instruction from data structures.
526void emitDebugLabel(LiveIntervals &LIS,constTargetInstrInfo &TII,
527BlockSkipInstsMap &BBSkipInstsMap);
528
529 /// Return DebugLoc of this UserLabel.
530constDebugLoc &getDebugLoc() {return dl; }
531
532voidprint(raw_ostream &,constTargetRegisterInfo *);
533};
534
535}// end anonymous namespace
536
537namespacellvm {
538
539/// Implementation of the LiveDebugVariables pass.
540
541LiveDebugVariables::LiveDebugVariables() =default;
542LiveDebugVariables::~LiveDebugVariables() =default;
543LiveDebugVariables::LiveDebugVariables(LiveDebugVariables &&) =default;
544
545classLiveDebugVariables::LDVImpl {
546LocMap::Allocator allocator;
547MachineFunction *MF =nullptr;
548LiveIntervals *LIS;
549constTargetRegisterInfo *TRI;
550
551 /// Position and VReg of a PHI instruction during register allocation.
552structPHIValPos {
553SlotIndex SI;/// Slot where this PHI occurs.
554Register Reg;/// VReg this PHI occurs in.
555unsignedSubReg;/// Qualifiying subregister for Reg.
556 };
557
558 /// Map from debug instruction number to PHI position during allocation.
559 std::map<unsigned, PHIValPos> PHIValToPos;
560 /// Index of, for each VReg, which debug instruction numbers and corresponding
561 /// PHIs are sensitive to splitting. Each VReg may have multiple PHI defs,
562 /// at different positions.
563DenseMap<Register, std::vector<unsigned>> RegToPHIIdx;
564
565 /// Record for any debug instructions unlinked from their blocks during
566 /// regalloc. Stores the instr and it's location, so that they can be
567 /// re-inserted after regalloc is over.
568structInstrPos {
569MachineInstr *MI;///< Debug instruction, unlinked from it's block.
570SlotIndexIdx;///< Slot position where MI should be re-inserted.
571MachineBasicBlock *MBB;///< Block that MI was in.
572 };
573
574 /// Collection of stored debug instructions, preserved until after regalloc.
575SmallVector<InstrPos, 32> StashedDebugInstrs;
576
577 /// Whether emitDebugValues is called.
578bool EmitDone =false;
579
580 /// Whether the machine function is modified during the pass.
581bool ModifiedMF =false;
582
583 /// All allocated UserValue instances.
584SmallVector<std::unique_ptr<UserValue>, 8> userValues;
585
586 /// All allocated UserLabel instances.
587SmallVector<std::unique_ptr<UserLabel>, 2> userLabels;
588
589 /// Map virtual register to eq class leader.
590usingVRMap =DenseMap<unsigned, UserValue *>;
591VRMap virtRegToEqClass;
592
593 /// Map to find existing UserValue instances.
594usingUVMap =DenseMap<DebugVariable, UserValue *>;
595UVMap userVarMap;
596
597 /// Find or create a UserValue.
598 UserValue *getUserValue(constDILocalVariable *Var,
599 std::optional<DIExpression::FragmentInfo> Fragment,
600constDebugLoc &DL);
601
602 /// Find the EC leader for VirtReg or null.
603 UserValue *lookupVirtReg(Register VirtReg);
604
605 /// Add DBG_VALUE instruction to our maps.
606 ///
607 /// \param MI DBG_VALUE instruction
608 /// \param Idx Last valid SLotIndex before instruction.
609 ///
610 /// \returns True if the DBG_VALUE instruction should be deleted.
611bool handleDebugValue(MachineInstr &MI,SlotIndexIdx);
612
613 /// Track variable location debug instructions while using the instruction
614 /// referencing implementation. Such debug instructions do not need to be
615 /// updated during regalloc because they identify instructions rather than
616 /// register locations. However, they needs to be removed from the
617 /// MachineFunction during regalloc, then re-inserted later, to avoid
618 /// disrupting the allocator.
619 ///
620 /// \param MI Any DBG_VALUE / DBG_INSTR_REF / DBG_PHI instruction
621 /// \param Idx Last valid SlotIndex before instruction
622 ///
623 /// \returns Iterator to continue processing from after unlinking.
624MachineBasicBlock::iterator handleDebugInstr(MachineInstr &MI,SlotIndexIdx);
625
626 /// Add DBG_LABEL instruction to UserLabel.
627 ///
628 /// \param MI DBG_LABEL instruction
629 /// \param Idx Last valid SlotIndex before instruction.
630 ///
631 /// \returns True if the DBG_LABEL instruction should be deleted.
632bool handleDebugLabel(MachineInstr &MI,SlotIndexIdx);
633
634 /// Collect and erase all DBG_VALUE instructions, adding a UserValue def
635 /// for each instruction.
636 ///
637 /// \param mf MachineFunction to be scanned.
638 /// \param InstrRef Whether to operate in instruction referencing mode. If
639 /// true, most of LiveDebugVariables doesn't run.
640 ///
641 /// \returns True if any debug values were found.
642bool collectDebugValues(MachineFunction &mf,bool InstrRef);
643
644 /// Compute the live intervals of all user values after collecting all
645 /// their def points.
646void computeIntervals();
647
648public:
649LDVImpl(LiveIntervals *LIS) : LIS(LIS) {}
650
651boolrunOnMachineFunction(MachineFunction &mf,bool InstrRef);
652
653 /// Release all memory.
654voidclear() {
655 MF =nullptr;
656 PHIValToPos.clear();
657 RegToPHIIdx.clear();
658 StashedDebugInstrs.clear();
659 userValues.clear();
660 userLabels.clear();
661 virtRegToEqClass.clear();
662 userVarMap.clear();
663// Make sure we call emitDebugValues if the machine function was modified.
664assert((!ModifiedMF || EmitDone) &&
665"Dbg values are not emitted in LDV");
666 EmitDone =false;
667 ModifiedMF =false;
668 }
669
670 /// Map virtual register to an equivalence class.
671voidmapVirtReg(Register VirtReg, UserValue *EC);
672
673 /// Replace any PHI referring to OldReg with its corresponding NewReg, if
674 /// present.
675voidsplitPHIRegister(Register OldReg,ArrayRef<Register> NewRegs);
676
677 /// Replace all references to OldReg with NewRegs.
678voidsplitRegister(Register OldReg,ArrayRef<Register> NewRegs);
679
680 /// Recreate DBG_VALUE instruction from data structures.
681voidemitDebugValues(VirtRegMap *VRM);
682
683voidprint(raw_ostream&);
684};
685
686}// namespace llvm
687
688staticvoidprintDebugLoc(constDebugLoc &DL,raw_ostream &CommentOS,
689constLLVMContext &Ctx) {
690if (!DL)
691return;
692
693auto *Scope = cast<DIScope>(DL.getScope());
694// Omit the directory, because it's likely to be long and uninteresting.
695 CommentOS << Scope->getFilename();
696 CommentOS <<':' <<DL.getLine();
697if (DL.getCol() != 0)
698 CommentOS <<':' <<DL.getCol();
699
700DebugLoc InlinedAtDL =DL.getInlinedAt();
701if (!InlinedAtDL)
702return;
703
704 CommentOS <<" @[ ";
705printDebugLoc(InlinedAtDL, CommentOS, Ctx);
706 CommentOS <<" ]";
707}
708
709staticvoidprintExtendedName(raw_ostream &OS,constDINode *Node,
710constDILocation *DL) {
711constLLVMContext &Ctx =Node->getContext();
712StringRef Res;
713unsigned Line = 0;
714if (constauto *V = dyn_cast<const DILocalVariable>(Node)) {
715 Res = V->getName();
716 Line = V->getLine();
717 }elseif (constauto *L = dyn_cast<const DILabel>(Node)) {
718 Res = L->getName();
719 Line = L->getLine();
720 }
721
722if (!Res.empty())
723OS << Res <<"," << Line;
724auto *InlinedAt =DL ?DL->getInlinedAt() :nullptr;
725if (InlinedAt) {
726if (DebugLoc InlinedAtDL = InlinedAt) {
727OS <<" @[";
728printDebugLoc(InlinedAtDL,OS, Ctx);
729OS <<"]";
730 }
731 }
732}
733
734void UserValue::print(raw_ostream &OS,constTargetRegisterInfo *TRI) {
735OS <<"!\"";
736printExtendedName(OS, Variable, dl);
737
738OS <<"\"\t";
739for (LocMap::const_iteratorI = locInts.begin();I.valid(); ++I) {
740OS <<" [" <<I.start() <<';' <<I.stop() <<"):";
741if (I.value().isUndef())
742OS <<" undef";
743else {
744I.value().printLocNos(OS);
745if (I.value().getWasIndirect())
746OS <<" ind";
747elseif (I.value().getWasList())
748OS <<" list";
749 }
750 }
751for (unsigned i = 0, e = locations.size(); i != e; ++i) {
752OS <<" Loc" << i <<'=';
753 locations[i].print(OS,TRI);
754 }
755OS <<'\n';
756}
757
758void UserLabel::print(raw_ostream &OS,constTargetRegisterInfo *TRI) {
759OS <<"!\"";
760printExtendedName(OS, Label, dl);
761
762OS <<"\"\t";
763OS << loc;
764OS <<'\n';
765}
766
767voidLiveDebugVariables::LDVImpl::print(raw_ostream &OS) {
768OS <<"********** DEBUG VARIABLES **********\n";
769for (auto &userValue : userValues)
770 userValue->print(OS,TRI);
771OS <<"********** DEBUG LABELS **********\n";
772for (auto &userLabel : userLabels)
773 userLabel->print(OS,TRI);
774}
775
776void UserValue::mapVirtRegs(LiveDebugVariables::LDVImpl *LDV) {
777for (constMachineOperand &MO : locations)
778if (MO.isReg() && MO.getReg().isVirtual())
779 LDV->mapVirtReg(MO.getReg(),this);
780}
781
782UserValue *LiveDebugVariables::LDVImpl::getUserValue(
783constDILocalVariable *Var,
784 std::optional<DIExpression::FragmentInfo> Fragment,constDebugLoc &DL) {
785// FIXME: Handle partially overlapping fragments. See
786// https://reviews.llvm.org/D70121#1849741.
787DebugVariableID(Var, Fragment,DL->getInlinedAt());
788 UserValue *&UV = userVarMap[ID];
789if (!UV) {
790 userValues.push_back(
791 std::make_unique<UserValue>(Var, Fragment,DL,allocator));
792 UV = userValues.back().get();
793 }
794return UV;
795}
796
797voidLiveDebugVariables::LDVImpl::mapVirtReg(Register VirtReg, UserValue *EC) {
798assert(VirtReg.isVirtual() &&"Only map VirtRegs");
799 UserValue *&Leader = virtRegToEqClass[VirtReg];
800 Leader = UserValue::merge(Leader, EC);
801}
802
803UserValue *LiveDebugVariables::LDVImpl::lookupVirtReg(Register VirtReg) {
804if (UserValue *UV = virtRegToEqClass.lookup(VirtReg))
805return UV->getLeader();
806returnnullptr;
807}
808
809bool LiveDebugVariables::LDVImpl::handleDebugValue(MachineInstr &MI,
810SlotIndexIdx) {
811// DBG_VALUE loc, offset, variable, expr
812// DBG_VALUE_LIST variable, expr, locs...
813if (!MI.isDebugValue()) {
814LLVM_DEBUG(dbgs() <<"Can't handle non-DBG_VALUE*: " <<MI);
815returnfalse;
816 }
817if (!MI.getDebugVariableOp().isMetadata()) {
818LLVM_DEBUG(dbgs() <<"Can't handle DBG_VALUE* with invalid variable: "
819 <<MI);
820returnfalse;
821 }
822if (MI.isNonListDebugValue() &&
823 (MI.getNumOperands() != 4 ||
824 !(MI.getDebugOffset().isImm() ||MI.getDebugOffset().isReg()))) {
825LLVM_DEBUG(dbgs() <<"Can't handle malformed DBG_VALUE: " <<MI);
826returnfalse;
827 }
828
829// Detect invalid DBG_VALUE instructions, with a debug-use of a virtual
830// register that hasn't been defined yet. If we do not remove those here, then
831// the re-insertion of the DBG_VALUE instruction after register allocation
832// will be incorrect.
833bool Discard =false;
834for (constMachineOperand &Op :MI.debug_operands()) {
835if (Op.isReg() &&Op.getReg().isVirtual()) {
836constRegisterReg =Op.getReg();
837if (!LIS->hasInterval(Reg)) {
838// The DBG_VALUE is described by a virtual register that does not have a
839// live interval. Discard the DBG_VALUE.
840 Discard =true;
841LLVM_DEBUG(dbgs() <<"Discarding debug info (no LIS interval): " <<Idx
842 <<" " <<MI);
843 }else {
844// The DBG_VALUE is only valid if either Reg is live out from Idx, or
845// Reg is defined dead at Idx (where Idx is the slot index for the
846// instruction preceding the DBG_VALUE).
847constLiveInterval &LI = LIS->getInterval(Reg);
848LiveQueryResult LRQ = LI.Query(Idx);
849if (!LRQ.valueOutOrDead()) {
850// We have found a DBG_VALUE with the value in a virtual register that
851// is not live. Discard the DBG_VALUE.
852 Discard =true;
853LLVM_DEBUG(dbgs() <<"Discarding debug info (reg not live): " <<Idx
854 <<" " <<MI);
855 }
856 }
857 }
858 }
859
860// Get or create the UserValue for (variable,offset) here.
861bool IsIndirect =MI.isDebugOffsetImm();
862if (IsIndirect)
863assert(MI.getDebugOffset().getImm() == 0 &&
864"DBG_VALUE with nonzero offset");
865bool IsList =MI.isDebugValueList();
866constDILocalVariable *Var =MI.getDebugVariable();
867constDIExpression *Expr =MI.getDebugExpression();
868 UserValue *UV = getUserValue(Var, Expr->getFragmentInfo(),MI.getDebugLoc());
869if (!Discard)
870 UV->addDef(Idx,
871ArrayRef<MachineOperand>(MI.debug_operands().begin(),
872MI.debug_operands().end()),
873 IsIndirect, IsList, *Expr);
874else {
875MachineOperand MO =MachineOperand::CreateReg(0U,false);
876 MO.setIsDebug();
877// We should still pass a list the same size as MI.debug_operands() even if
878// all MOs are undef, so that DbgVariableValue can correctly adjust the
879// expression while removing the duplicated undefs.
880SmallVector<MachineOperand, 4> UndefMOs(MI.getNumDebugOperands(), MO);
881 UV->addDef(Idx, UndefMOs,false, IsList, *Expr);
882 }
883returntrue;
884}
885
886MachineBasicBlock::iterator
887LiveDebugVariables::LDVImpl::handleDebugInstr(MachineInstr &MI,SlotIndexIdx) {
888assert(MI.isDebugValueLike() ||MI.isDebugPHI());
889
890// In instruction referencing mode, there should be no DBG_VALUE instructions
891// that refer to virtual registers. They might still refer to constants.
892if (MI.isDebugValueLike())
893assert(none_of(MI.debug_operands(),
894 [](constMachineOperand &MO) {
895 return MO.isReg() && MO.getReg().isVirtual();
896 }) &&
897"MIs should not refer to Virtual Registers in InstrRef mode.");
898
899// Unlink the instruction, store it in the debug instructions collection.
900auto NextInst = std::next(MI.getIterator());
901auto *MBB =MI.getParent();
902MI.removeFromParent();
903 StashedDebugInstrs.push_back({&MI,Idx,MBB});
904return NextInst;
905}
906
907bool LiveDebugVariables::LDVImpl::handleDebugLabel(MachineInstr &MI,
908SlotIndexIdx) {
909// DBG_LABEL label
910if (MI.getNumOperands() != 1 || !MI.getOperand(0).isMetadata()) {
911LLVM_DEBUG(dbgs() <<"Can't handle " <<MI);
912returnfalse;
913 }
914
915// Get or create the UserLabel for label here.
916constDILabel *Label =MI.getDebugLabel();
917constDebugLoc &DL =MI.getDebugLoc();
918bool Found =false;
919for (autoconst &L : userLabels) {
920if (L->matches(Label,DL->getInlinedAt(),Idx)) {
921 Found =true;
922break;
923 }
924 }
925if (!Found)
926 userLabels.push_back(std::make_unique<UserLabel>(Label,DL,Idx));
927
928returntrue;
929}
930
931bool LiveDebugVariables::LDVImpl::collectDebugValues(MachineFunction &mf,
932bool InstrRef) {
933bool Changed =false;
934for (MachineBasicBlock &MBB : mf) {
935for (MachineBasicBlock::iteratorMBBI =MBB.begin(), MBBE =MBB.end();
936MBBI != MBBE;) {
937// Use the first debug instruction in the sequence to get a SlotIndex
938// for following consecutive debug instructions.
939if (!MBBI->isDebugOrPseudoInstr()) {
940 ++MBBI;
941continue;
942 }
943// Debug instructions has no slot index. Use the previous
944// non-debug instruction's SlotIndex as its SlotIndex.
945SlotIndexIdx =
946MBBI ==MBB.begin()
947 ? LIS->getMBBStartIdx(&MBB)
948 : LIS->getInstructionIndex(*std::prev(MBBI)).getRegSlot();
949// Handle consecutive debug instructions with the same slot index.
950do {
951// In instruction referencing mode, pass each instr to handleDebugInstr
952// to be unlinked. Ignore DBG_VALUE_LISTs -- they refer to vregs, and
953// need to go through the normal live interval splitting process.
954if (InstrRef && (MBBI->isNonListDebugValue() ||MBBI->isDebugPHI() ||
955MBBI->isDebugRef())) {
956MBBI = handleDebugInstr(*MBBI,Idx);
957 Changed =true;
958// In normal debug mode, use the dedicated DBG_VALUE / DBG_LABEL handler
959// to track things through register allocation, and erase the instr.
960 }elseif ((MBBI->isDebugValue() && handleDebugValue(*MBBI,Idx)) ||
961 (MBBI->isDebugLabel() && handleDebugLabel(*MBBI,Idx))) {
962MBBI =MBB.erase(MBBI);
963 Changed =true;
964 }else
965 ++MBBI;
966 }while (MBBI != MBBE &&MBBI->isDebugOrPseudoInstr());
967 }
968 }
969return Changed;
970}
971
972void UserValue::extendDef(
973SlotIndexIdx, DbgVariableValueDbgValue,
974SmallDenseMap<unsigned, std::pair<LiveRange *, const VNInfo *>>
975 &LiveIntervalInfo,
976 std::optional<std::pair<SlotIndex,SmallVector<unsigned>>> &Kills,
977LiveIntervals &LIS) {
978SlotIndex Start =Idx;
979MachineBasicBlock *MBB = LIS.getMBBFromIndex(Start);
980SlotIndex Stop = LIS.getMBBEndIdx(MBB);
981LocMap::iteratorI = locInts.find(Start);
982
983// Limit to the intersection of the VNIs' live ranges.
984for (auto &LII : LiveIntervalInfo) {
985LiveRange *LR = LII.second.first;
986assert(LR && LII.second.second &&"Missing range info for Idx.");
987LiveInterval::Segment *Segment = LR->getSegmentContaining(Start);
988assert(Segment && Segment->valno == LII.second.second &&
989"Invalid VNInfo for Idx given?");
990if (Segment->end < Stop) {
991 Stop = Segment->end;
992 Kills = {Stop, {LII.first}};
993 }elseif (Segment->end == Stop && Kills) {
994// If multiple locations end at the same place, track all of them in
995// Kills.
996 Kills->second.push_back(LII.first);
997 }
998 }
999
1000// There could already be a short def at Start.
1001if (I.valid() &&I.start() <= Start) {
1002// Stop when meeting a different location or an already extended interval.
1003 Start = Start.getNextSlot();
1004if (I.value() !=DbgValue ||I.stop() != Start) {
1005// Clear `Kills`, as we have a new def available.
1006 Kills = std::nullopt;
1007return;
1008 }
1009// This is a one-slot placeholder. Just skip it.
1010 ++I;
1011 }
1012
1013// Limited by the next def.
1014if (I.valid() &&I.start() < Stop) {
1015 Stop =I.start();
1016// Clear `Kills`, as we have a new def available.
1017 Kills = std::nullopt;
1018 }
1019
1020if (Start < Stop) {
1021 DbgVariableValue ExtDbgValue(DbgValue);
1022I.insert(Start, Stop, std::move(ExtDbgValue));
1023 }
1024}
1025
1026void UserValue::addDefsFromCopies(
1027 DbgVariableValueDbgValue,
1028SmallVectorImpl<std::pair<unsigned, LiveInterval *>> &LocIntervals,
1029SlotIndex KilledAt,
1030SmallVectorImpl<std::pair<SlotIndex, DbgVariableValue>> &NewDefs,
1031MachineRegisterInfo &MRI,LiveIntervals &LIS) {
1032// Don't track copies from physregs, there are too many uses.
1033if (any_of(LocIntervals,
1034 [](auto LocI) {return !LocI.second->reg().isVirtual(); }))
1035return;
1036
1037// Collect all the (vreg, valno) pairs that are copies of LI.
1038SmallDenseMap<unsigned,
1039SmallVector<std::pair<LiveInterval *, const VNInfo *>, 4>>
1040 CopyValues;
1041for (auto &LocInterval : LocIntervals) {
1042unsigned LocNo = LocInterval.first;
1043LiveInterval *LI = LocInterval.second;
1044for (MachineOperand &MO :MRI.use_nodbg_operands(LI->reg())) {
1045MachineInstr *MI = MO.getParent();
1046// Copies of the full value.
1047if (MO.getSubReg() || !MI->isCopy())
1048continue;
1049Register DstReg =MI->getOperand(0).getReg();
1050
1051// Don't follow copies to physregs. These are usually setting up call
1052// arguments, and the argument registers are always call clobbered. We are
1053// better off in the source register which could be a callee-saved
1054// register, or it could be spilled.
1055if (!DstReg.isVirtual())
1056continue;
1057
1058// Is the value extended to reach this copy? If not, another def may be
1059// blocking it, or we are looking at a wrong value of LI.
1060SlotIndexIdx = LIS.getInstructionIndex(*MI);
1061LocMap::iteratorI = locInts.find(Idx.getRegSlot(true));
1062if (!I.valid() ||I.value() !=DbgValue)
1063continue;
1064
1065if (!LIS.hasInterval(DstReg))
1066continue;
1067LiveInterval *DstLI = &LIS.getInterval(DstReg);
1068constVNInfo *DstVNI = DstLI->getVNInfoAt(Idx.getRegSlot());
1069assert(DstVNI && DstVNI->def ==Idx.getRegSlot() &&"Bad copy value");
1070 CopyValues[LocNo].push_back(std::make_pair(DstLI, DstVNI));
1071 }
1072 }
1073
1074if (CopyValues.empty())
1075return;
1076
1077#if !defined(NDEBUG)
1078for (auto &LocInterval : LocIntervals)
1079LLVM_DEBUG(dbgs() <<"Got " << CopyValues[LocInterval.first].size()
1080 <<" copies of " << *LocInterval.second <<'\n');
1081#endif
1082
1083// Try to add defs of the copied values for the kill point. Check that there
1084// isn't already a def at Idx.
1085LocMap::iteratorI = locInts.find(KilledAt);
1086if (I.valid() &&I.start() <= KilledAt)
1087return;
1088 DbgVariableValue NewValue(DbgValue);
1089for (auto &LocInterval : LocIntervals) {
1090unsigned LocNo = LocInterval.first;
1091bool FoundCopy =false;
1092for (auto &LIAndVNI : CopyValues[LocNo]) {
1093LiveInterval *DstLI = LIAndVNI.first;
1094constVNInfo *DstVNI = LIAndVNI.second;
1095if (DstLI->getVNInfoAt(KilledAt) != DstVNI)
1096continue;
1097LLVM_DEBUG(dbgs() <<"Kill at " << KilledAt <<" covered by valno #"
1098 << DstVNI->id <<" in " << *DstLI <<'\n');
1099MachineInstr *CopyMI = LIS.getInstructionFromIndex(DstVNI->def);
1100assert(CopyMI && CopyMI->isCopy() &&"Bad copy value");
1101unsigned NewLocNo = getLocationNo(CopyMI->getOperand(0));
1102 NewValue = NewValue.changeLocNo(LocNo, NewLocNo);
1103 FoundCopy =true;
1104break;
1105 }
1106// If there are any killed locations we can't find a copy for, we can't
1107// extend the variable value.
1108if (!FoundCopy)
1109return;
1110 }
1111I.insert(KilledAt, KilledAt.getNextSlot(), NewValue);
1112 NewDefs.push_back(std::make_pair(KilledAt, NewValue));
1113}
1114
1115void UserValue::computeIntervals(MachineRegisterInfo &MRI,
1116constTargetRegisterInfo &TRI,
1117LiveIntervals &LIS,LexicalScopes &LS) {
1118SmallVector<std::pair<SlotIndex, DbgVariableValue>, 16> Defs;
1119
1120// Collect all defs to be extended (Skipping undefs).
1121for (LocMap::const_iteratorI = locInts.begin();I.valid(); ++I)
1122if (!I.value().isUndef())
1123 Defs.push_back(std::make_pair(I.start(),I.value()));
1124
1125// Extend all defs, and possibly add new ones along the way.
1126for (unsigned i = 0; i != Defs.size(); ++i) {
1127SlotIndexIdx = Defs[i].first;
1128 DbgVariableValueDbgValue = Defs[i].second;
1129SmallDenseMap<unsigned, std::pair<LiveRange *, const VNInfo *>> LIs;
1130SmallVector<const VNInfo *, 4> VNIs;
1131bool ShouldExtendDef =false;
1132for (unsigned LocNo :DbgValue.loc_nos()) {
1133constMachineOperand &LocMO = locations[LocNo];
1134if (!LocMO.isReg() || !LocMO.getReg().isVirtual()) {
1135 ShouldExtendDef |= !LocMO.isReg();
1136continue;
1137 }
1138 ShouldExtendDef =true;
1139LiveInterval *LI =nullptr;
1140constVNInfo *VNI =nullptr;
1141if (LIS.hasInterval(LocMO.getReg())) {
1142 LI = &LIS.getInterval(LocMO.getReg());
1143 VNI = LI->getVNInfoAt(Idx);
1144 }
1145if (LI && VNI)
1146 LIs[LocNo] = {LI, VNI};
1147 }
1148if (ShouldExtendDef) {
1149 std::optional<std::pair<SlotIndex, SmallVector<unsigned>>> Kills;
1150 extendDef(Idx,DbgValue, LIs, Kills, LIS);
1151
1152if (Kills) {
1153SmallVector<std::pair<unsigned, LiveInterval *>, 2> KilledLocIntervals;
1154bool AnySubreg =false;
1155for (unsigned LocNo : Kills->second) {
1156constMachineOperand &LocMO = this->locations[LocNo];
1157if (LocMO.getSubReg()) {
1158 AnySubreg =true;
1159break;
1160 }
1161LiveInterval *LI = &LIS.getInterval(LocMO.getReg());
1162 KilledLocIntervals.push_back({LocNo, LI});
1163 }
1164
1165// FIXME: Handle sub-registers in addDefsFromCopies. The problem is that
1166// if the original location for example is %vreg0:sub_hi, and we find a
1167// full register copy in addDefsFromCopies (at the moment it only
1168// handles full register copies), then we must add the sub1 sub-register
1169// index to the new location. However, that is only possible if the new
1170// virtual register is of the same regclass (or if there is an
1171// equivalent sub-register in that regclass). For now, simply skip
1172// handling copies if a sub-register is involved.
1173if (!AnySubreg)
1174 addDefsFromCopies(DbgValue, KilledLocIntervals, Kills->first, Defs,
1175MRI, LIS);
1176 }
1177 }
1178
1179// For physregs, we only mark the start slot idx. DwarfDebug will see it
1180// as if the DBG_VALUE is valid up until the end of the basic block, or
1181// the next def of the physical register. So we do not need to extend the
1182// range. It might actually happen that the DBG_VALUE is the last use of
1183// the physical register (e.g. if this is an unused input argument to a
1184// function).
1185 }
1186
1187// The computed intervals may extend beyond the range of the debug
1188// location's lexical scope. In this case, splitting of an interval
1189// can result in an interval outside of the scope being created,
1190// causing extra unnecessary DBG_VALUEs to be emitted. To prevent
1191// this, trim the intervals to the lexical scope in the case of inlined
1192// variables, since heavy inlining may cause production of dramatically big
1193// number of DBG_VALUEs to be generated.
1194if (!dl.getInlinedAt())
1195return;
1196
1197LexicalScope *Scope =LS.findLexicalScope(dl);
1198if (!Scope)
1199return;
1200
1201SlotIndex PrevEnd;
1202LocMap::iteratorI = locInts.begin();
1203
1204// Iterate over the lexical scope ranges. Each time round the loop
1205// we check the intervals for overlap with the end of the previous
1206// range and the start of the next. The first range is handled as
1207// a special case where there is no PrevEnd.
1208for (constInsnRange &Range :Scope->getRanges()) {
1209SlotIndex RStart = LIS.getInstructionIndex(*Range.first);
1210SlotIndex REnd = LIS.getInstructionIndex(*Range.second);
1211
1212// Variable locations at the first instruction of a block should be
1213// based on the block's SlotIndex, not the first instruction's index.
1214if (Range.first ==Range.first->getParent()->begin())
1215 RStart = LIS.getSlotIndexes()->getIndexBefore(*Range.first);
1216
1217// At the start of each iteration I has been advanced so that
1218// I.stop() >= PrevEnd. Check for overlap.
1219if (PrevEnd &&I.start() < PrevEnd) {
1220SlotIndex IStop =I.stop();
1221 DbgVariableValueDbgValue =I.value();
1222
1223// Stop overlaps previous end - trim the end of the interval to
1224// the scope range.
1225I.setStopUnchecked(PrevEnd);
1226 ++I;
1227
1228// If the interval also overlaps the start of the "next" (i.e.
1229// current) range create a new interval for the remainder (which
1230// may be further trimmed).
1231if (RStart < IStop)
1232I.insert(RStart, IStop,DbgValue);
1233 }
1234
1235// Advance I so that I.stop() >= RStart, and check for overlap.
1236I.advanceTo(RStart);
1237if (!I.valid())
1238return;
1239
1240if (I.start() < RStart) {
1241// Interval start overlaps range - trim to the scope range.
1242I.setStartUnchecked(RStart);
1243// Remember that this interval was trimmed.
1244 trimmedDefs.insert(RStart);
1245 }
1246
1247// The end of a lexical scope range is the last instruction in the
1248// range. To convert to an interval we need the index of the
1249// instruction after it.
1250 REnd = REnd.getNextIndex();
1251
1252// Advance I to first interval outside current range.
1253I.advanceTo(REnd);
1254if (!I.valid())
1255return;
1256
1257 PrevEnd = REnd;
1258 }
1259
1260// Check for overlap with end of final range.
1261if (PrevEnd &&I.start() < PrevEnd)
1262I.setStopUnchecked(PrevEnd);
1263}
1264
1265void LiveDebugVariables::LDVImpl::computeIntervals() {
1266LexicalScopesLS;
1267LS.initialize(*MF);
1268
1269for (constauto &UV : userValues) {
1270 UV->computeIntervals(MF->getRegInfo(), *TRI, *LIS, LS);
1271 UV->mapVirtRegs(this);
1272 }
1273}
1274
1275boolLiveDebugVariables::LDVImpl::runOnMachineFunction(MachineFunction &mf,
1276bool InstrRef) {
1277 clear();
1278 MF = &mf;
1279TRI = mf.getSubtarget().getRegisterInfo();
1280LLVM_DEBUG(dbgs() <<"********** COMPUTING LIVE DEBUG VARIABLES: "
1281 << mf.getName() <<" **********\n");
1282
1283bool Changed = collectDebugValues(mf, InstrRef);
1284 computeIntervals();
1285LLVM_DEBUG(print(dbgs()));
1286
1287// Collect the set of VReg / SlotIndexs where PHIs occur; index the sensitive
1288// VRegs too, for when we're notified of a range split.
1289SlotIndexes *Slots = LIS->getSlotIndexes();
1290for (constauto &PHIIt : MF->DebugPHIPositions) {
1291constMachineFunction::DebugPHIRegallocPos &Position = PHIIt.second;
1292MachineBasicBlock *MBB = Position.MBB;
1293Register Reg = Position.Reg;
1294unsignedSubReg = Position.SubReg;
1295SlotIndex SI = Slots->getMBBStartIdx(MBB);
1296 PHIValPos VP = {SI, Reg,SubReg};
1297 PHIValToPos.insert(std::make_pair(PHIIt.first, VP));
1298 RegToPHIIdx[Reg].push_back(PHIIt.first);
1299 }
1300
1301 ModifiedMF = Changed;
1302return Changed;
1303}
1304
1305staticvoidremoveDebugInstrs(MachineFunction &mf) {
1306for (MachineBasicBlock &MBB : mf) {
1307for (MachineInstr &MI :llvm::make_early_inc_range(MBB))
1308if (MI.isDebugInstr())
1309MBB.erase(&MI);
1310 }
1311}
1312
1313boolLiveDebugVariablesWrapperLegacy::runOnMachineFunction(
1314MachineFunction &mf) {
1315auto *LIS = &getAnalysis<LiveIntervalsWrapperPass>().getLIS();
1316
1317 Impl = std::make_unique<LiveDebugVariables>();
1318 Impl->analyze(mf, LIS);
1319returnfalse;
1320}
1321
1322AnalysisKey LiveDebugVariablesAnalysis::Key;
1323
1324LiveDebugVariables
1325LiveDebugVariablesAnalysis::run(MachineFunction &MF,
1326MachineFunctionAnalysisManager &MFAM) {
1327MFPropsModifier_(*this, MF);
1328
1329auto *LIS = &MFAM.getResult<LiveIntervalsAnalysis>(MF);
1330LiveDebugVariables LDV;
1331 LDV.analyze(MF, LIS);
1332return LDV;
1333}
1334
1335PreservedAnalyses
1336LiveDebugVariablesPrinterPass::run(MachineFunction &MF,
1337MachineFunctionAnalysisManager &MFAM) {
1338auto &LDV = MFAM.getResult<LiveDebugVariablesAnalysis>(MF);
1339 LDV.print(OS);
1340returnPreservedAnalyses::all();
1341}
1342
1343voidLiveDebugVariables::releaseMemory() {
1344if (PImpl)
1345 PImpl->clear();
1346}
1347
1348boolLiveDebugVariables::invalidate(
1349MachineFunction &,constPreservedAnalyses &PA,
1350MachineFunctionAnalysisManager::Invalidator &) {
1351auto PAC = PA.getChecker<LiveDebugVariablesAnalysis>();
1352// Some architectures split the register allocation into multiple phases based
1353// on register classes. This requires preserving analyses between the phases
1354// by default.
1355return !PAC.preservedWhenStateless();
1356}
1357
1358voidLiveDebugVariables::analyze(MachineFunction &MF,LiveIntervals *LIS) {
1359if (!EnableLDV)
1360return;
1361if (!MF.getFunction().getSubprogram()) {
1362removeDebugInstrs(MF);
1363return;
1364 }
1365
1366 PImpl.reset(newLDVImpl(LIS));
1367
1368// Have we been asked to track variable locations using instruction
1369// referencing?
1370bool InstrRef = MF.useDebugInstrRef();
1371 PImpl->runOnMachineFunction(MF, InstrRef);
1372}
1373
1374//===----------------------------------------------------------------------===//
1375// Live Range Splitting
1376//===----------------------------------------------------------------------===//
1377
1378bool
1379UserValue::splitLocation(unsigned OldLocNo,ArrayRef<Register> NewRegs,
1380LiveIntervals& LIS) {
1381LLVM_DEBUG({
1382dbgs() <<"Splitting Loc" << OldLocNo <<'\t';
1383print(dbgs(),nullptr);
1384 });
1385bool DidChange =false;
1386LocMap::iterator LocMapI;
1387 LocMapI.setMap(locInts);
1388for (Register NewReg : NewRegs) {
1389LiveInterval *LI = &LIS.getInterval(NewReg);
1390if (LI->empty())
1391continue;
1392
1393// Don't allocate the new LocNo until it is needed.
1394unsigned NewLocNo =UndefLocNo;
1395
1396// Iterate over the overlaps between locInts and LI.
1397 LocMapI.find(LI->beginIndex());
1398if (!LocMapI.valid())
1399continue;
1400LiveInterval::iterator LII = LI->advanceTo(LI->begin(), LocMapI.start());
1401LiveInterval::iterator LIE = LI->end();
1402while (LocMapI.valid() && LII != LIE) {
1403// At this point, we know that LocMapI.stop() > LII->start.
1404 LII = LI->advanceTo(LII, LocMapI.start());
1405if (LII == LIE)
1406break;
1407
1408// Now LII->end > LocMapI.start(). Do we have an overlap?
1409if (LocMapI.value().containsLocNo(OldLocNo) &&
1410 LII->start < LocMapI.stop()) {
1411// Overlapping correct location. Allocate NewLocNo now.
1412if (NewLocNo ==UndefLocNo) {
1413MachineOperand MO =MachineOperand::CreateReg(LI->reg(),false);
1414 MO.setSubReg(locations[OldLocNo].getSubReg());
1415 NewLocNo = getLocationNo(MO);
1416 DidChange =true;
1417 }
1418
1419SlotIndex LStart = LocMapI.start();
1420SlotIndex LStop = LocMapI.stop();
1421 DbgVariableValue OldDbgValue = LocMapI.value();
1422
1423// Trim LocMapI down to the LII overlap.
1424if (LStart < LII->start)
1425 LocMapI.setStartUnchecked(LII->start);
1426if (LStop > LII->end)
1427 LocMapI.setStopUnchecked(LII->end);
1428
1429// Change the value in the overlap. This may trigger coalescing.
1430 LocMapI.setValue(OldDbgValue.changeLocNo(OldLocNo, NewLocNo));
1431
1432// Re-insert any removed OldDbgValue ranges.
1433if (LStart < LocMapI.start()) {
1434 LocMapI.insert(LStart, LocMapI.start(), OldDbgValue);
1435 ++LocMapI;
1436assert(LocMapI.valid() &&"Unexpected coalescing");
1437 }
1438if (LStop > LocMapI.stop()) {
1439 ++LocMapI;
1440 LocMapI.insert(LII->end, LStop, OldDbgValue);
1441 --LocMapI;
1442 }
1443 }
1444
1445// Advance to the next overlap.
1446if (LII->end < LocMapI.stop()) {
1447if (++LII == LIE)
1448break;
1449 LocMapI.advanceTo(LII->start);
1450 }else {
1451 ++LocMapI;
1452if (!LocMapI.valid())
1453break;
1454 LII = LI->advanceTo(LII, LocMapI.start());
1455 }
1456 }
1457 }
1458
1459// Finally, remove OldLocNo unless it is still used by some interval in the
1460// locInts map. One case when OldLocNo still is in use is when the register
1461// has been spilled. In such situations the spilled register is kept as a
1462// location until rewriteLocations is called (VirtRegMap is mapping the old
1463// register to the spill slot). So for a while we can have locations that map
1464// to virtual registers that have been removed from both the MachineFunction
1465// and from LiveIntervals.
1466//
1467// We may also just be using the location for a value with a different
1468// expression.
1469 removeLocationIfUnused(OldLocNo);
1470
1471LLVM_DEBUG({
1472dbgs() <<"Split result: \t";
1473print(dbgs(),nullptr);
1474 });
1475return DidChange;
1476}
1477
1478bool
1479UserValue::splitRegister(Register OldReg,ArrayRef<Register> NewRegs,
1480LiveIntervals &LIS) {
1481bool DidChange =false;
1482// Split locations referring to OldReg. Iterate backwards so splitLocation can
1483// safely erase unused locations.
1484for (unsigned i = locations.size(); i ; --i) {
1485unsigned LocNo = i-1;
1486constMachineOperand *Loc = &locations[LocNo];
1487if (!Loc->isReg() || Loc->getReg() != OldReg)
1488continue;
1489 DidChange |= splitLocation(LocNo, NewRegs, LIS);
1490 }
1491return DidChange;
1492}
1493
1494voidLiveDebugVariables::LDVImpl::splitPHIRegister(Register OldReg,
1495ArrayRef<Register> NewRegs) {
1496auto RegIt = RegToPHIIdx.find(OldReg);
1497if (RegIt == RegToPHIIdx.end())
1498return;
1499
1500 std::vector<std::pair<Register, unsigned>> NewRegIdxes;
1501// Iterate over all the debug instruction numbers affected by this split.
1502for (unsigned InstrID : RegIt->second) {
1503auto PHIIt = PHIValToPos.find(InstrID);
1504assert(PHIIt != PHIValToPos.end());
1505constSlotIndex &Slot = PHIIt->second.SI;
1506assert(OldReg == PHIIt->second.Reg);
1507
1508// Find the new register that covers this position.
1509for (auto NewReg : NewRegs) {
1510constLiveInterval &LI = LIS->getInterval(NewReg);
1511auto LII = LI.find(Slot);
1512if (LII != LI.end() && LII->start <= Slot) {
1513// This new register covers this PHI position, record this for indexing.
1514 NewRegIdxes.push_back(std::make_pair(NewReg, InstrID));
1515// Record that this value lives in a different VReg now.
1516 PHIIt->second.Reg = NewReg;
1517break;
1518 }
1519 }
1520
1521// If we do not find a new register covering this PHI, then register
1522// allocation has dropped its location, for example because it's not live.
1523// The old VReg will not be mapped to a physreg, and the instruction
1524// number will have been optimized out.
1525 }
1526
1527// Re-create register index using the new register numbers.
1528 RegToPHIIdx.erase(RegIt);
1529for (auto &RegAndInstr : NewRegIdxes)
1530 RegToPHIIdx[RegAndInstr.first].push_back(RegAndInstr.second);
1531}
1532
1533voidLiveDebugVariables::LDVImpl::splitRegister(Register OldReg,
1534ArrayRef<Register> NewRegs) {
1535// Consider whether this split range affects any PHI locations.
1536 splitPHIRegister(OldReg, NewRegs);
1537
1538// Check whether any intervals mapped by a DBG_VALUE were split and need
1539// updating.
1540bool DidChange =false;
1541for (UserValue *UV = lookupVirtReg(OldReg); UV; UV = UV->getNext())
1542 DidChange |= UV->splitRegister(OldReg, NewRegs, *LIS);
1543
1544if (!DidChange)
1545return;
1546
1547// Map all of the new virtual registers.
1548 UserValue *UV = lookupVirtReg(OldReg);
1549for (Register NewReg : NewRegs)
1550 mapVirtReg(NewReg, UV);
1551}
1552
1553voidLiveDebugVariables::
1554splitRegister(Register OldReg,ArrayRef<Register> NewRegs,LiveIntervals &LIS) {
1555if (PImpl)
1556 PImpl->splitRegister(OldReg, NewRegs);
1557}
1558
1559void UserValue::rewriteLocations(VirtRegMap &VRM,constMachineFunction &MF,
1560constTargetInstrInfo &TII,
1561constTargetRegisterInfo &TRI,
1562SpillOffsetMap &SpillOffsets) {
1563// Build a set of new locations with new numbers so we can coalesce our
1564// IntervalMap if two vreg intervals collapse to the same physical location.
1565// Use MapVector instead of SetVector because MapVector::insert returns the
1566// position of the previously or newly inserted element. The boolean value
1567// tracks if the location was produced by a spill.
1568// FIXME: This will be problematic if we ever support direct and indirect
1569// frame index locations, i.e. expressing both variables in memory and
1570// 'int x, *px = &x'. The "spilled" bit must become part of the location.
1571MapVector<MachineOperand, std::pair<bool, unsigned>> NewLocations;
1572SmallVector<unsigned, 4> LocNoMap(locations.size());
1573for (unsignedI = 0, E = locations.size();I != E; ++I) {
1574bool Spilled =false;
1575unsigned SpillOffset = 0;
1576MachineOperand Loc = locations[I];
1577// Only virtual registers are rewritten.
1578if (Loc.isReg() && Loc.getReg() && Loc.getReg().isVirtual()) {
1579Register VirtReg = Loc.getReg();
1580if (VRM.isAssignedReg(VirtReg) && VRM.hasPhys(VirtReg)) {
1581// This can create a %noreg operand in rare cases when the sub-register
1582// index is no longer available. That means the user value is in a
1583// non-existent sub-register, and %noreg is exactly what we want.
1584 Loc.substPhysReg(VRM.getPhys(VirtReg),TRI);
1585 }elseif (VRM.getStackSlot(VirtReg) !=VirtRegMap::NO_STACK_SLOT) {
1586// Retrieve the stack slot offset.
1587unsigned SpillSize;
1588constMachineRegisterInfo &MRI = MF.getRegInfo();
1589constTargetRegisterClass *TRC =MRI.getRegClass(VirtReg);
1590boolSuccess =TII.getStackSlotRange(TRC, Loc.getSubReg(), SpillSize,
1591 SpillOffset, MF);
1592
1593// FIXME: Invalidate the location if the offset couldn't be calculated.
1594 (void)Success;
1595
1596 Loc =MachineOperand::CreateFI(VRM.getStackSlot(VirtReg));
1597 Spilled =true;
1598 }else {
1599 Loc.setReg(0);
1600 Loc.setSubReg(0);
1601 }
1602 }
1603
1604// Insert this location if it doesn't already exist and record a mapping
1605// from the old number to the new number.
1606auto InsertResult = NewLocations.insert({Loc, {Spilled, SpillOffset}});
1607unsigned NewLocNo = std::distance(NewLocations.begin(), InsertResult.first);
1608 LocNoMap[I] = NewLocNo;
1609 }
1610
1611// Rewrite the locations and record the stack slot offsets for spills.
1612 locations.clear();
1613 SpillOffsets.clear();
1614for (auto &Pair : NewLocations) {
1615bool Spilled;
1616unsigned SpillOffset;
1617 std::tie(Spilled, SpillOffset) = Pair.second;
1618 locations.push_back(Pair.first);
1619if (Spilled) {
1620unsigned NewLocNo = std::distance(&*NewLocations.begin(), &Pair);
1621 SpillOffsets[NewLocNo] = SpillOffset;
1622 }
1623 }
1624
1625// Update the interval map, but only coalesce left, since intervals to the
1626// right use the old location numbers. This should merge two contiguous
1627// DBG_VALUE intervals with different vregs that were allocated to the same
1628// physical register.
1629for (LocMap::iteratorI = locInts.begin();I.valid(); ++I) {
1630I.setValueUnchecked(I.value().remapLocNos(LocNoMap));
1631I.setStart(I.start());
1632 }
1633}
1634
1635/// Find an iterator for inserting a DBG_VALUE instruction.
1636staticMachineBasicBlock::iterator
1637findInsertLocation(MachineBasicBlock *MBB,SlotIndexIdx,LiveIntervals &LIS,
1638BlockSkipInstsMap &BBSkipInstsMap) {
1639SlotIndex Start = LIS.getMBBStartIdx(MBB);
1640Idx =Idx.getBaseIndex();
1641
1642// Try to find an insert location by going backwards from Idx.
1643MachineInstr *MI;
1644while (!(MI = LIS.getInstructionFromIndex(Idx))) {
1645// We've reached the beginning of MBB.
1646if (Idx == Start) {
1647// Retrieve the last PHI/Label/Debug location found when calling
1648// SkipPHIsLabelsAndDebug last time. Start searching from there.
1649//
1650// Note the iterator kept in BBSkipInstsMap is one step back based
1651// on the iterator returned by SkipPHIsLabelsAndDebug last time.
1652// One exception is when SkipPHIsLabelsAndDebug returns MBB->begin(),
1653// BBSkipInstsMap won't save it. This is to consider the case that
1654// new instructions may be inserted at the beginning of MBB after
1655// last call of SkipPHIsLabelsAndDebug. If we save MBB->begin() in
1656// BBSkipInstsMap, after new non-phi/non-label/non-debug instructions
1657// are inserted at the beginning of the MBB, the iterator in
1658// BBSkipInstsMap won't point to the beginning of the MBB anymore.
1659// Therefore The next search in SkipPHIsLabelsAndDebug will skip those
1660// newly added instructions and that is unwanted.
1661MachineBasicBlock::iterator BeginIt;
1662auto MapIt = BBSkipInstsMap.find(MBB);
1663if (MapIt == BBSkipInstsMap.end())
1664 BeginIt =MBB->begin();
1665else
1666 BeginIt = std::next(MapIt->second);
1667autoI =MBB->SkipPHIsLabelsAndDebug(BeginIt);
1668if (I != BeginIt)
1669 BBSkipInstsMap[MBB] = std::prev(I);
1670returnI;
1671 }
1672Idx =Idx.getPrevIndex();
1673 }
1674
1675// Don't insert anything after the first terminator, though.
1676auto It =MI->isTerminator() ?MBB->getFirstTerminator()
1677 : std::next(MachineBasicBlock::iterator(MI));
1678returnskipDebugInstructionsForward(It,MBB->end());
1679}
1680
1681/// Find an iterator for inserting the next DBG_VALUE instruction
1682/// (or end if no more insert locations found).
1683staticMachineBasicBlock::iterator
1684findNextInsertLocation(MachineBasicBlock *MBB,MachineBasicBlock::iteratorI,
1685SlotIndex StopIdx,ArrayRef<MachineOperand> LocMOs,
1686LiveIntervals &LIS,constTargetRegisterInfo &TRI) {
1687SmallVector<Register, 4> Regs;
1688for (constMachineOperand &LocMO : LocMOs)
1689if (LocMO.isReg())
1690 Regs.push_back(LocMO.getReg());
1691if (Regs.empty())
1692returnMBB->instr_end();
1693
1694// Find the next instruction in the MBB that define the register Reg.
1695while (I !=MBB->end() && !I->isTerminator()) {
1696if (!LIS.isNotInMIMap(*I) &&
1697SlotIndex::isEarlierEqualInstr(StopIdx, LIS.getInstructionIndex(*I)))
1698break;
1699if (any_of(Regs, [&I, &TRI](Register &Reg) {
1700returnI->definesRegister(Reg, &TRI);
1701 }))
1702// The insert location is directly after the instruction/bundle.
1703return std::next(I);
1704 ++I;
1705 }
1706returnMBB->end();
1707}
1708
1709void UserValue::insertDebugValue(MachineBasicBlock *MBB,SlotIndex StartIdx,
1710SlotIndex StopIdx, DbgVariableValueDbgValue,
1711ArrayRef<bool> LocSpills,
1712ArrayRef<unsigned> SpillOffsets,
1713LiveIntervals &LIS,constTargetInstrInfo &TII,
1714constTargetRegisterInfo &TRI,
1715BlockSkipInstsMap &BBSkipInstsMap) {
1716SlotIndex MBBEndIdx = LIS.getMBBEndIdx(&*MBB);
1717// Only search within the current MBB.
1718 StopIdx = (MBBEndIdx < StopIdx) ? MBBEndIdx : StopIdx;
1719MachineBasicBlock::iteratorI =
1720findInsertLocation(MBB, StartIdx, LIS, BBSkipInstsMap);
1721// Undef values don't exist in locations so create new "noreg" register MOs
1722// for them. See getLocationNo().
1723SmallVector<MachineOperand, 8> MOs;
1724if (DbgValue.isUndef()) {
1725 MOs.assign(DbgValue.loc_nos().size(),
1726MachineOperand::CreateReg(
1727/* Reg */ 0,/* isDef */false,/* isImp */false,
1728/* isKill */false,/* isDead */false,
1729/* isUndef */false,/* isEarlyClobber */false,
1730/* SubReg */ 0,/* isDebug */true));
1731 }else {
1732for (unsigned LocNo :DbgValue.loc_nos())
1733 MOs.push_back(locations[LocNo]);
1734 }
1735
1736 ++NumInsertedDebugValues;
1737
1738assert(cast<DILocalVariable>(Variable)
1739 ->isValidLocationForIntrinsic(getDebugLoc()) &&
1740"Expected inlined-at fields to agree");
1741
1742// If the location was spilled, the new DBG_VALUE will be indirect. If the
1743// original DBG_VALUE was indirect, we need to add DW_OP_deref to indicate
1744// that the original virtual register was a pointer. Also, add the stack slot
1745// offset for the spilled register to the expression.
1746constDIExpression *Expr =DbgValue.getExpression();
1747bool IsIndirect =DbgValue.getWasIndirect();
1748bool IsList =DbgValue.getWasList();
1749for (unsignedI = 0, E = LocSpills.size();I != E; ++I) {
1750if (LocSpills[I]) {
1751if (!IsList) {
1752uint8_t DIExprFlags =DIExpression::ApplyOffset;
1753if (IsIndirect)
1754 DIExprFlags |=DIExpression::DerefAfter;
1755 Expr =DIExpression::prepend(Expr, DIExprFlags, SpillOffsets[I]);
1756 IsIndirect =true;
1757 }else {
1758SmallVector<uint64_t, 4> Ops;
1759DIExpression::appendOffset(Ops, SpillOffsets[I]);
1760 Ops.push_back(dwarf::DW_OP_deref);
1761 Expr =DIExpression::appendOpsToArg(Expr, Ops,I);
1762 }
1763 }
1764
1765assert((!LocSpills[I] || MOs[I].isFI()) &&
1766"a spilled location must be a frame index");
1767 }
1768
1769unsigned DbgValueOpcode =
1770 IsList ? TargetOpcode::DBG_VALUE_LIST : TargetOpcode::DBG_VALUE;
1771do {
1772BuildMI(*MBB,I,getDebugLoc(),TII.get(DbgValueOpcode), IsIndirect, MOs,
1773 Variable, Expr);
1774
1775// Continue and insert DBG_VALUES after every redefinition of a register
1776// associated with the debug value within the range
1777I =findNextInsertLocation(MBB,I, StopIdx, MOs, LIS,TRI);
1778 }while (I !=MBB->end());
1779}
1780
1781void UserLabel::insertDebugLabel(MachineBasicBlock *MBB,SlotIndexIdx,
1782LiveIntervals &LIS,constTargetInstrInfo &TII,
1783BlockSkipInstsMap &BBSkipInstsMap) {
1784MachineBasicBlock::iteratorI =
1785findInsertLocation(MBB,Idx, LIS, BBSkipInstsMap);
1786 ++NumInsertedDebugLabels;
1787BuildMI(*MBB,I,getDebugLoc(),TII.get(TargetOpcode::DBG_LABEL))
1788 .addMetadata(Label);
1789}
1790
1791void UserValue::emitDebugValues(VirtRegMap *VRM,LiveIntervals &LIS,
1792constTargetInstrInfo &TII,
1793constTargetRegisterInfo &TRI,
1794constSpillOffsetMap &SpillOffsets,
1795BlockSkipInstsMap &BBSkipInstsMap) {
1796MachineFunction::iterator MFEnd = VRM->getMachineFunction().end();
1797
1798for (LocMap::const_iteratorI = locInts.begin();I.valid();) {
1799SlotIndex Start =I.start();
1800SlotIndex Stop =I.stop();
1801 DbgVariableValueDbgValue =I.value();
1802
1803SmallVector<bool> SpilledLocs;
1804SmallVector<unsigned> LocSpillOffsets;
1805for (unsigned LocNo :DbgValue.loc_nos()) {
1806auto SpillIt =
1807 !DbgValue.isUndef() ? SpillOffsets.find(LocNo) : SpillOffsets.end();
1808bool Spilled = SpillIt != SpillOffsets.end();
1809 SpilledLocs.push_back(Spilled);
1810 LocSpillOffsets.push_back(Spilled ? SpillIt->second : 0);
1811 }
1812
1813// If the interval start was trimmed to the lexical scope insert the
1814// DBG_VALUE at the previous index (otherwise it appears after the
1815// first instruction in the range).
1816if (trimmedDefs.count(Start))
1817 Start = Start.getPrevIndex();
1818
1819LLVM_DEBUG(auto &dbg =dbgs(); dbg <<"\t[" << Start <<';' << Stop <<"):";
1820DbgValue.printLocNos(dbg));
1821MachineFunction::iteratorMBB = LIS.getMBBFromIndex(Start)->getIterator();
1822SlotIndex MBBEnd = LIS.getMBBEndIdx(&*MBB);
1823
1824LLVM_DEBUG(dbgs() <<' ' <<printMBBReference(*MBB) <<'-' << MBBEnd);
1825 insertDebugValue(&*MBB, Start, Stop,DbgValue, SpilledLocs, LocSpillOffsets,
1826 LIS,TII,TRI, BBSkipInstsMap);
1827// This interval may span multiple basic blocks.
1828// Insert a DBG_VALUE into each one.
1829while (Stop > MBBEnd) {
1830// Move to the next block.
1831 Start = MBBEnd;
1832if (++MBB == MFEnd)
1833break;
1834 MBBEnd = LIS.getMBBEndIdx(&*MBB);
1835LLVM_DEBUG(dbgs() <<' ' <<printMBBReference(*MBB) <<'-' << MBBEnd);
1836 insertDebugValue(&*MBB, Start, Stop,DbgValue, SpilledLocs,
1837 LocSpillOffsets, LIS,TII,TRI, BBSkipInstsMap);
1838 }
1839LLVM_DEBUG(dbgs() <<'\n');
1840if (MBB == MFEnd)
1841break;
1842
1843 ++I;
1844 }
1845}
1846
1847void UserLabel::emitDebugLabel(LiveIntervals &LIS,constTargetInstrInfo &TII,
1848BlockSkipInstsMap &BBSkipInstsMap) {
1849LLVM_DEBUG(dbgs() <<"\t" << loc);
1850MachineFunction::iteratorMBB = LIS.getMBBFromIndex(loc)->getIterator();
1851
1852LLVM_DEBUG(dbgs() <<' ' <<printMBBReference(*MBB));
1853 insertDebugLabel(&*MBB, loc, LIS,TII, BBSkipInstsMap);
1854
1855LLVM_DEBUG(dbgs() <<'\n');
1856}
1857
1858voidLiveDebugVariables::LDVImpl::emitDebugValues(VirtRegMap *VRM) {
1859LLVM_DEBUG(dbgs() <<"********** EMITTING LIVE DEBUG VARIABLES **********\n");
1860if (!MF)
1861return;
1862
1863BlockSkipInstsMap BBSkipInstsMap;
1864constTargetInstrInfo *TII = MF->getSubtarget().getInstrInfo();
1865SpillOffsetMap SpillOffsets;
1866for (auto &userValue : userValues) {
1867LLVM_DEBUG(userValue->print(dbgs(),TRI));
1868 userValue->rewriteLocations(*VRM, *MF, *TII, *TRI, SpillOffsets);
1869 userValue->emitDebugValues(VRM, *LIS, *TII, *TRI, SpillOffsets,
1870 BBSkipInstsMap);
1871 }
1872LLVM_DEBUG(dbgs() <<"********** EMITTING LIVE DEBUG LABELS **********\n");
1873for (auto &userLabel : userLabels) {
1874LLVM_DEBUG(userLabel->print(dbgs(),TRI));
1875 userLabel->emitDebugLabel(*LIS, *TII, BBSkipInstsMap);
1876 }
1877
1878LLVM_DEBUG(dbgs() <<"********** EMITTING DEBUG PHIS **********\n");
1879
1880auto Slots = LIS->getSlotIndexes();
1881for (auto &It : PHIValToPos) {
1882// For each ex-PHI, identify its physreg location or stack slot, and emit
1883// a DBG_PHI for it.
1884unsigned InstNum = It.first;
1885auto Slot = It.second.SI;
1886Register Reg = It.second.Reg;
1887unsignedSubReg = It.second.SubReg;
1888
1889MachineBasicBlock *OrigMBB = Slots->getMBBFromIndex(Slot);
1890if (VRM->isAssignedReg(Reg) && VRM->hasPhys(Reg)) {
1891unsigned PhysReg = VRM->getPhys(Reg);
1892if (SubReg != 0)
1893 PhysReg =TRI->getSubReg(PhysReg,SubReg);
1894
1895auto Builder =BuildMI(*OrigMBB, OrigMBB->begin(),DebugLoc(),
1896TII->get(TargetOpcode::DBG_PHI));
1897 Builder.addReg(PhysReg);
1898 Builder.addImm(InstNum);
1899 }elseif (VRM->getStackSlot(Reg) !=VirtRegMap::NO_STACK_SLOT) {
1900constMachineRegisterInfo &MRI = MF->getRegInfo();
1901constTargetRegisterClass *TRC =MRI.getRegClass(Reg);
1902unsigned SpillSize, SpillOffset;
1903
1904unsigned regSizeInBits =TRI->getRegSizeInBits(*TRC);
1905if (SubReg)
1906 regSizeInBits =TRI->getSubRegIdxSize(SubReg);
1907
1908// Test whether this location is legal with the given subreg. If the
1909// subregister has a nonzero offset, drop this location, it's too complex
1910// to describe. (TODO: future work).
1911boolSuccess =
1912TII->getStackSlotRange(TRC,SubReg, SpillSize, SpillOffset, *MF);
1913
1914if (Success && SpillOffset == 0) {
1915auto Builder =BuildMI(*OrigMBB, OrigMBB->begin(),DebugLoc(),
1916TII->get(TargetOpcode::DBG_PHI));
1917 Builder.addFrameIndex(VRM->getStackSlot(Reg));
1918 Builder.addImm(InstNum);
1919// Record how large the original value is. The stack slot might be
1920// merged and altered during optimisation, but we will want to know how
1921// large the value is, at this DBG_PHI.
1922 Builder.addImm(regSizeInBits);
1923 }
1924
1925LLVM_DEBUG(if (SpillOffset != 0) {
1926dbgs() <<"DBG_PHI for " <<printReg(Reg,TRI,SubReg)
1927 <<" has nonzero offset\n";
1928 });
1929 }
1930// If there was no mapping for a value ID, it's optimized out. Create no
1931// DBG_PHI, and any variables using this value will become optimized out.
1932 }
1933 MF->DebugPHIPositions.clear();
1934
1935LLVM_DEBUG(dbgs() <<"********** EMITTING INSTR REFERENCES **********\n");
1936
1937// Re-insert any debug instrs back in the position they were. We must
1938// re-insert in the same order to ensure that debug instructions don't swap,
1939// which could re-order assignments. Do so in a batch -- once we find the
1940// insert position, insert all instructions at the same SlotIdx. They are
1941// guaranteed to appear in-sequence in StashedDebugInstrs because we insert
1942// them in order.
1943for (auto *StashIt = StashedDebugInstrs.begin();
1944 StashIt != StashedDebugInstrs.end(); ++StashIt) {
1945SlotIndexIdx = StashIt->Idx;
1946MachineBasicBlock *MBB = StashIt->MBB;
1947MachineInstr *MI = StashIt->MI;
1948
1949auto EmitInstsHere = [this, &StashIt,MBB,Idx,
1950MI](MachineBasicBlock::iterator InsertPos) {
1951// Insert this debug instruction.
1952MBB->insert(InsertPos,MI);
1953
1954// Look at subsequent stashed debug instructions: if they're at the same
1955// index, insert those too.
1956auto NextItem = std::next(StashIt);
1957while (NextItem != StashedDebugInstrs.end() && NextItem->Idx ==Idx) {
1958assert(NextItem->MBB ==MBB &&"Instrs with same slot index should be"
1959"in the same block");
1960MBB->insert(InsertPos, NextItem->MI);
1961 StashIt = NextItem;
1962 NextItem = std::next(StashIt);
1963 };
1964 };
1965
1966// Start block index: find the first non-debug instr in the block, and
1967// insert before it.
1968if (Idx == Slots->getMBBStartIdx(MBB)) {
1969MachineBasicBlock::iterator InsertPos =
1970findInsertLocation(MBB,Idx, *LIS, BBSkipInstsMap);
1971 EmitInstsHere(InsertPos);
1972continue;
1973 }
1974
1975if (MachineInstr *Pos = Slots->getInstructionFromIndex(Idx)) {
1976// Insert at the end of any debug instructions.
1977auto PostDebug = std::next(Pos->getIterator());
1978 PostDebug =skipDebugInstructionsForward(PostDebug,MBB->instr_end());
1979 EmitInstsHere(PostDebug);
1980 }else {
1981// Insert position disappeared; walk forwards through slots until we
1982// find a new one.
1983SlotIndexEnd = Slots->getMBBEndIdx(MBB);
1984for (;Idx <End;Idx = Slots->getNextNonNullIndex(Idx)) {
1985 Pos = Slots->getInstructionFromIndex(Idx);
1986if (Pos) {
1987 EmitInstsHere(Pos->getIterator());
1988break;
1989 }
1990 }
1991
1992// We have reached the end of the block and didn't find anywhere to
1993// insert! It's not safe to discard any debug instructions; place them
1994// in front of the first terminator, or in front of end().
1995if (Idx >=End) {
1996auto TermIt =MBB->getFirstTerminator();
1997 EmitInstsHere(TermIt);
1998 }
1999 }
2000 }
2001
2002 EmitDone =true;
2003 BBSkipInstsMap.clear();
2004}
2005
2006voidLiveDebugVariables::emitDebugValues(VirtRegMap *VRM) {
2007if (PImpl)
2008 PImpl->emitDebugValues(VRM);
2009}
2010
2011#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
2012LLVM_DUMP_METHODvoidLiveDebugVariables::dump() const{print(dbgs()); }
2013#endif
2014
2015voidLiveDebugVariables::print(raw_ostream &OS) const{
2016if (PImpl)
2017 PImpl->print(OS);
2018}
SubReg
unsigned SubReg
Definition:AArch64AdvSIMDScalarPass.cpp:104
MRI
unsigned const MachineRegisterInfo * MRI
Definition:AArch64AdvSIMDScalarPass.cpp:105
Success
#define Success
Definition:AArch64Disassembler.cpp:220
MBB
MachineBasicBlock & MBB
Definition:ARMSLSHardening.cpp:71
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition:ARMSLSHardening.cpp:73
MBBI
MachineBasicBlock MachineBasicBlock::iterator MBBI
Definition:ARMSLSHardening.cpp:72
print
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
Definition:ArchiveWriter.cpp:205
ArrayRef.h
true
basic Basic Alias true
Definition:BasicAliasAnalysis.cpp:1981
Casting.h
CommandLine.h
LLVM_DUMP_METHOD
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
Definition:Compiler.h:622
Idx
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
Definition:DeadArgumentElimination.cpp:353
DebugInfoMetadata.h
DebugLoc.h
Debug
static ManagedStatic< cl::opt< bool, true >, CreateDebug > Debug
Definition:Debug.cpp:108
Debug.h
LLVM_DEBUG
#define LLVM_DEBUG(...)
Definition:Debug.h:106
DenseMap.h
This file defines the DenseMap class.
Dwarf.h
This file contains constants used for implementing Dwarf debug support.
Index
uint32_t Index
Definition:ELFObjHandler.cpp:83
Other
std::optional< std::vector< StOtherPiece > > Other
Definition:ELFYAML.cpp:1315
End
bool End
Definition:ELF_riscv.cpp:480
TII
const HexagonInstrInfo * TII
Definition:HexagonCopyToCombine.cpp:125
_
#define _
Definition:HexagonMCCodeEmitter.cpp:46
MI
IRTranslator LLVM IR MI
Definition:IRTranslator.cpp:112
Function.h
InitializePasses.h
IntervalMap.h
This file implements a coalescing interval map for small objects.
SpecialSubKind::allocator
@ allocator
LexicalScopes.h
UndefLocNo
@ UndefLocNo
Definition:LiveDebugVariables.cpp:101
printExtendedName
static void printExtendedName(raw_ostream &OS, const DINode *Node, const DILocation *DL)
Definition:LiveDebugVariables.cpp:709
findInsertLocation
static MachineBasicBlock::iterator findInsertLocation(MachineBasicBlock *MBB, SlotIndex Idx, LiveIntervals &LIS, BlockSkipInstsMap &BBSkipInstsMap)
Find an iterator for inserting a DBG_VALUE instruction.
Definition:LiveDebugVariables.cpp:1637
Analysis
Debug Variable Analysis
Definition:LiveDebugVariables.cpp:85
findNextInsertLocation
static MachineBasicBlock::iterator findNextInsertLocation(MachineBasicBlock *MBB, MachineBasicBlock::iterator I, SlotIndex StopIdx, ArrayRef< MachineOperand > LocMOs, LiveIntervals &LIS, const TargetRegisterInfo &TRI)
Find an iterator for inserting the next DBG_VALUE instruction (or end if no more insert locations fou...
Definition:LiveDebugVariables.cpp:1684
EnableLDV
static cl::opt< bool > EnableLDV("live-debug-variables", cl::init(true), cl::desc("Enable the live debug variables pass"), cl::Hidden)
DEBUG_TYPE
#define DEBUG_TYPE
Definition:LiveDebugVariables.cpp:69
printDebugLoc
static void printDebugLoc(const DebugLoc &DL, raw_ostream &CommentOS, const LLVMContext &Ctx)
Definition:LiveDebugVariables.cpp:688
removeDebugInstrs
static void removeDebugInstrs(MachineFunction &mf)
Definition:LiveDebugVariables.cpp:1305
LiveDebugVariables.h
LiveInterval.h
LiveIntervals.h
merge
static LoopDeletionResult merge(LoopDeletionResult A, LoopDeletionResult B)
Definition:LoopDeletion.cpp:51
I
#define I(x, y, z)
Definition:MD5.cpp:58
MachineBasicBlock.h
MachineDominators.h
MachineFunction.h
MachineInstrBuilder.h
getDebugLoc
static DebugLoc getDebugLoc(MachineBasicBlock::instr_iterator FirstMI, MachineBasicBlock::instr_iterator LastMI)
Return the first found DebugLoc that has a DILocation, given a range of instructions.
Definition:MachineInstrBundle.cpp:109
MachineInstr.h
MachineOperand.h
MachinePassManager.h
MachineRegisterInfo.h
isUndef
static bool isUndef(const MachineInstr &MI)
Definition:MachineSSAContext.cpp:57
TRI
unsigned const TargetRegisterInfo * TRI
Definition:MachineSink.cpp:2029
MapVector.h
This file implements a map that provides insertion order iteration.
getReg
static unsigned getReg(const MCDisassembler *D, unsigned RC, unsigned RegNo)
Definition:MipsDisassembler.cpp:520
isReg
static bool isReg(const MCInst &MI, unsigned OpNo)
Definition:MipsInstPrinter.cpp:31
Range
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
INITIALIZE_PASS_DEPENDENCY
#define INITIALIZE_PASS_DEPENDENCY(depName)
Definition:PassSupport.h:55
INITIALIZE_PASS_END
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
Definition:PassSupport.h:57
INITIALIZE_PASS_BEGIN
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
Definition:PassSupport.h:52
Pass.h
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
STLExtras.h
This file contains some templates that are useful if you are working with the STL at all.
OS
raw_pwrite_stream & OS
Definition:SampleProfWriter.cpp:51
SlotIndexes.h
SmallSet.h
This file defines the SmallSet class.
SmallVector.h
This file defines the SmallVector class.
Statistic.h
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
STATISTIC
#define STATISTIC(VARNAME, DESC)
Definition:Statistic.h:166
StringRef.h
TargetInstrInfo.h
TargetOpcodes.h
TargetRegisterInfo.h
TargetSubtargetInfo.h
VirtRegMap.h
RHS
Value * RHS
Definition:X86PartialReduction.cpp:74
LHS
Value * LHS
Definition:X86PartialReduction.cpp:73
LiveDebugValues::DbgValue
Class recording the (high level) value of a variable.
Definition:InstrRefBasedImpl.h:512
Node
Definition:ItaniumDemangle.h:163
T
llvm::AnalysisManager::Invalidator
API to communicate dependencies between analyses during invalidation.
Definition:PassManager.h:292
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition:PassManager.h:253
llvm::AnalysisManager::getResult
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Definition:PassManager.h:410
llvm::AnalysisUsage
Represent the analysis usage information of a pass.
Definition:PassAnalysisSupport.h:47
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition:ArrayRef.h:41
llvm::ArrayRef::size
size_t size() const
size - Get the array size.
Definition:ArrayRef.h:168
llvm::DIExpression
DWARF expression.
Definition:DebugInfoMetadata.h:2763
llvm::DIExpression::appendOffset
static void appendOffset(SmallVectorImpl< uint64_t > &Ops, int64_t Offset)
Append Ops with operations to apply the Offset.
Definition:DebugInfoMetadata.cpp:1721
llvm::DIExpression::appendOpsToArg
static DIExpression * appendOpsToArg(const DIExpression *Expr, ArrayRef< uint64_t > Ops, unsigned ArgNo, bool StackValue=false)
Create a copy of Expr by appending the given list of Ops to each instance of the operand DW_OP_LLVM_a...
Definition:DebugInfoMetadata.cpp:1858
llvm::DIExpression::ApplyOffset
@ ApplyOffset
Definition:DebugInfoMetadata.h:3044
llvm::DIExpression::DerefAfter
@ DerefAfter
Definition:DebugInfoMetadata.h:3046
llvm::DIExpression::getFragmentInfo
static std::optional< FragmentInfo > getFragmentInfo(expr_op_iterator Start, expr_op_iterator End)
Retrieve the details of this fragment expression.
Definition:DebugInfoMetadata.cpp:1677
llvm::DIExpression::replaceArg
static DIExpression * replaceArg(const DIExpression *Expr, uint64_t OldArg, uint64_t NewArg)
Create a copy of Expr with each instance of DW_OP_LLVM_arg, \p OldArg replaced with DW_OP_LLVM_arg,...
Definition:DebugInfoMetadata.cpp:1893
llvm::DIExpression::createFragmentExpression
static std::optional< DIExpression * > createFragmentExpression(const DIExpression *Expr, unsigned OffsetInBits, unsigned SizeInBits)
Create a DIExpression to describe one part of an aggregate variable that is fragmented across multipl...
Definition:DebugInfoMetadata.cpp:2006
llvm::DIExpression::prepend
static DIExpression * prepend(const DIExpression *Expr, uint8_t Flags, int64_t Offset=0)
Prepend DIExpr with a deref and offset operation and optionally turn it into a stack value or/and an ...
Definition:DebugInfoMetadata.cpp:1842
llvm::DILabel
Label.
Definition:DebugInfoMetadata.h:3551
llvm::DILocalVariable
Local variable.
Definition:DebugInfoMetadata.h:3460
llvm::DILocation
Debug location.
Definition:DebugInfoMetadata.h:1988
llvm::DINode
Tagged DWARF-like metadata node.
Definition:DebugInfoMetadata.h:135
llvm::DWARFExpression::Operation
This class represents an Operation in the Expression.
Definition:DWARFExpression.h:32
llvm::DebugLoc
A debug info location.
Definition:DebugLoc.h:33
llvm::DebugVariable
Identifies a unique instance of a variable.
Definition:DebugInfoMetadata.h:4024
llvm::DenseMapBase::find
iterator find(const_arg_type_t< KeyT > Val)
Definition:DenseMap.h:156
llvm::DenseMapBase::empty
bool empty() const
Definition:DenseMap.h:98
llvm::DenseMapBase::end
iterator end()
Definition:DenseMap.h:84
llvm::DenseMapBase::clear
void clear()
Definition:DenseMap.h:110
llvm::DenseMap< unsigned, unsigned >
llvm::Expression
Class representing an expression and its matching format.
Definition:FileCheckImpl.h:189
llvm::Function::getSubprogram
DISubprogram * getSubprogram() const
Get the attached subprogram.
Definition:Metadata.cpp:1874
llvm::IntervalMap::const_iterator
Definition:IntervalMap.h:1343
llvm::IntervalMap::const_iterator::setMap
void setMap(const IntervalMap &m)
setMap - Change the map iterated over.
Definition:IntervalMap.h:1407
llvm::IntervalMap::const_iterator::advanceTo
void advanceTo(KeyT x)
advanceTo - Move to the first interval with stop >= x, or end().
Definition:IntervalMap.h:1494
llvm::IntervalMap::const_iterator::stop
const KeyT & stop() const
stop - Return the end of the current interval.
Definition:IntervalMap.h:1419
llvm::IntervalMap::const_iterator::valid
bool valid() const
valid - Return true if the current position is valid, false for end().
Definition:IntervalMap.h:1410
llvm::IntervalMap::const_iterator::start
const KeyT & start() const
start - Return the beginning of the current interval.
Definition:IntervalMap.h:1416
llvm::IntervalMap::const_iterator::value
const ValT & value() const
value - Return the mapped value at the current interval.
Definition:IntervalMap.h:1422
llvm::IntervalMap::const_iterator::find
void find(KeyT x)
find - Move to the first interval with stop >= x, or end().
Definition:IntervalMap.h:1484
llvm::IntervalMap::iterator
Definition:IntervalMap.h:1572
llvm::IntervalMap::iterator::insert
void insert(KeyT a, KeyT b, ValT y)
insert - Insert mapping [a;b] -> y before the current position.
Definition:IntervalMap.h:1833
llvm::IntervalMap::iterator::setValue
void setValue(ValT x)
setValue - Change the mapped value of the current interval.
Definition:IntervalMap.h:1765
llvm::IntervalMap::iterator::setStartUnchecked
void setStartUnchecked(KeyT a)
setStartUnchecked - Move the start of the current interval without checking for coalescing or overlap...
Definition:IntervalMap.h:1611
llvm::IntervalMap::iterator::setStopUnchecked
void setStopUnchecked(KeyT b)
setStopUnchecked - Move the end of the current interval without checking for coalescing or overlaps.
Definition:IntervalMap.h:1617
llvm::IntervalMap
Definition:IntervalMap.h:936
llvm::IntervalMap::begin
const_iterator begin() const
Definition:IntervalMap.h:1146
llvm::IntervalMap::Allocator
typename Sizer::Allocator Allocator
Definition:IntervalMap.h:962
llvm::IntervalMap::find
const_iterator find(KeyT x) const
find - Return an iterator pointing to the first interval ending at or after x, or end().
Definition:IntervalMap.h:1172
llvm::LLVMContext
This is an important class for using LLVM in a threaded context.
Definition:LLVMContext.h:67
llvm::LexicalScope
LexicalScope - This class is used to track scope information.
Definition:LexicalScopes.h:44
llvm::LexicalScopes
LexicalScopes - This class provides interface to collect and use lexical scoping information from mac...
Definition:LexicalScopes.h:141
llvm::LiveDebugVariablesAnalysis
Definition:LiveDebugVariables.h:97
llvm::LiveDebugVariablesAnalysis::run
Result run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
Definition:LiveDebugVariables.cpp:1325
llvm::LiveDebugVariablesPrinterPass::run
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
Definition:LiveDebugVariables.cpp:1336
llvm::LiveDebugVariablesWrapperLegacy
Definition:LiveDebugVariables.h:71
llvm::LiveDebugVariablesWrapperLegacy::LiveDebugVariablesWrapperLegacy
LiveDebugVariablesWrapperLegacy()
Definition:LiveDebugVariables.cpp:95
llvm::LiveDebugVariablesWrapperLegacy::runOnMachineFunction
bool runOnMachineFunction(MachineFunction &) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
Definition:LiveDebugVariables.cpp:1313
llvm::LiveDebugVariablesWrapperLegacy::ID
static char ID
Definition:LiveDebugVariables.h:75
llvm::LiveDebugVariables::LDVImpl
Definition:LiveDebugVariables.cpp:545
llvm::LiveDebugVariables::LDVImpl::LDVImpl
LDVImpl(LiveIntervals *LIS)
Definition:LiveDebugVariables.cpp:649
llvm::LiveDebugVariables::LDVImpl::print
void print(raw_ostream &)
Definition:LiveDebugVariables.cpp:767
llvm::LiveDebugVariables::LDVImpl::splitRegister
void splitRegister(Register OldReg, ArrayRef< Register > NewRegs)
Replace all references to OldReg with NewRegs.
Definition:LiveDebugVariables.cpp:1533
llvm::LiveDebugVariables::LDVImpl::runOnMachineFunction
bool runOnMachineFunction(MachineFunction &mf, bool InstrRef)
Definition:LiveDebugVariables.cpp:1275
llvm::LiveDebugVariables::LDVImpl::mapVirtReg
void mapVirtReg(Register VirtReg, UserValue *EC)
Map virtual register to an equivalence class.
Definition:LiveDebugVariables.cpp:797
llvm::LiveDebugVariables::LDVImpl::clear
void clear()
Release all memory.
Definition:LiveDebugVariables.cpp:654
llvm::LiveDebugVariables::LDVImpl::emitDebugValues
void emitDebugValues(VirtRegMap *VRM)
Recreate DBG_VALUE instruction from data structures.
Definition:LiveDebugVariables.cpp:1858
llvm::LiveDebugVariables::LDVImpl::splitPHIRegister
void splitPHIRegister(Register OldReg, ArrayRef< Register > NewRegs)
Replace any PHI referring to OldReg with its corresponding NewReg, if present.
Definition:LiveDebugVariables.cpp:1494
llvm::LiveDebugVariables
Definition:LiveDebugVariables.h:35
llvm::LiveDebugVariables::~LiveDebugVariables
~LiveDebugVariables()
llvm::LiveDebugVariables::dump
void dump() const
dump - Print data structures to dbgs().
Definition:LiveDebugVariables.cpp:2012
llvm::LiveDebugVariables::splitRegister
void splitRegister(Register OldReg, ArrayRef< Register > NewRegs, LiveIntervals &LIS)
splitRegister - Move any user variables in OldReg to the live ranges in NewRegs where they are live.
Definition:LiveDebugVariables.cpp:1554
llvm::LiveDebugVariables::LiveDebugVariables
LiveDebugVariables()
Implementation of the LiveDebugVariables pass.
llvm::LiveDebugVariables::print
void print(raw_ostream &OS) const
Definition:LiveDebugVariables.cpp:2015
llvm::LiveDebugVariables::analyze
void analyze(MachineFunction &MF, LiveIntervals *LIS)
Definition:LiveDebugVariables.cpp:1358
llvm::LiveDebugVariables::releaseMemory
void releaseMemory()
Definition:LiveDebugVariables.cpp:1343
llvm::LiveDebugVariables::emitDebugValues
void emitDebugValues(VirtRegMap *VRM)
emitDebugValues - Emit new DBG_VALUE instructions reflecting the changes that happened during registe...
Definition:LiveDebugVariables.cpp:2006
llvm::LiveDebugVariables::invalidate
bool invalidate(MachineFunction &MF, const PreservedAnalyses &PA, MachineFunctionAnalysisManager::Invalidator &Inv)
Definition:LiveDebugVariables.cpp:1348
llvm::LiveInterval
LiveInterval - This class represents the liveness of a register, or stack slot.
Definition:LiveInterval.h:687
llvm::LiveInterval::reg
Register reg() const
Definition:LiveInterval.h:718
llvm::LiveIntervalsAnalysis
Definition:LiveIntervals.h:507
llvm::LiveIntervalsWrapperPass
Definition:LiveIntervals.h:527
llvm::LiveIntervals
Definition:LiveIntervals.h:55
llvm::LiveIntervals::hasInterval
bool hasInterval(Register Reg) const
Definition:LiveIntervals.h:144
llvm::LiveIntervals::getMBBStartIdx
SlotIndex getMBBStartIdx(const MachineBasicBlock *mbb) const
Return the first index in the given basic block.
Definition:LiveIntervals.h:255
llvm::LiveIntervals::getInstructionFromIndex
MachineInstr * getInstructionFromIndex(SlotIndex index) const
Returns the instruction associated with the given index.
Definition:LiveIntervals.h:250
llvm::LiveIntervals::getSlotIndexes
SlotIndexes * getSlotIndexes() const
Definition:LiveIntervals.h:236
llvm::LiveIntervals::getInstructionIndex
SlotIndex getInstructionIndex(const MachineInstr &Instr) const
Returns the base index of the given instruction.
Definition:LiveIntervals.h:245
llvm::LiveIntervals::getMBBEndIdx
SlotIndex getMBBEndIdx(const MachineBasicBlock *mbb) const
Return the last index in the given basic block.
Definition:LiveIntervals.h:260
llvm::LiveIntervals::getInterval
LiveInterval & getInterval(Register Reg)
Definition:LiveIntervals.h:133
llvm::LiveIntervals::isNotInMIMap
bool isNotInMIMap(const MachineInstr &Instr) const
Returns true if the specified machine instr has been removed or was never entered in the map.
Definition:LiveIntervals.h:240
llvm::LiveIntervals::getMBBFromIndex
MachineBasicBlock * getMBBFromIndex(SlotIndex index) const
Definition:LiveIntervals.h:272
llvm::LiveQueryResult
Result of a LiveRange query.
Definition:LiveInterval.h:90
llvm::LiveQueryResult::valueOutOrDead
VNInfo * valueOutOrDead() const
Returns the value alive at the end of the instruction, if any.
Definition:LiveInterval.h:129
llvm::LiveRange
This class represents the liveness of a register, stack slot, etc.
Definition:LiveInterval.h:157
llvm::LiveRange::getSegmentContaining
const Segment * getSegmentContaining(SlotIndex Idx) const
Return the segment that contains the specified index, or null if there is none.
Definition:LiveInterval.h:408
llvm::LiveRange::advanceTo
iterator advanceTo(iterator I, SlotIndex Pos)
advanceTo - Advance the specified iterator to point to the Segment containing the specified position,...
Definition:LiveInterval.h:271
llvm::LiveRange::empty
bool empty() const
Definition:LiveInterval.h:382
llvm::LiveRange::Query
LiveQueryResult Query(SlotIndex Idx) const
Query Liveness at Idx.
Definition:LiveInterval.h:542
llvm::LiveRange::end
iterator end()
Definition:LiveInterval.h:216
llvm::LiveRange::begin
iterator begin()
Definition:LiveInterval.h:215
llvm::LiveRange::beginIndex
SlotIndex beginIndex() const
beginIndex - Return the lowest numbered slot covered.
Definition:LiveInterval.h:385
llvm::LiveRange::getVNInfoAt
VNInfo * getVNInfoAt(SlotIndex Idx) const
getVNInfoAt - Return the VNInfo that is live at Idx, or NULL.
Definition:LiveInterval.h:421
llvm::LiveRange::find
iterator find(SlotIndex Pos)
find - Return an iterator pointing to the first segment that ends after Pos, or end().
Definition:LiveInterval.cpp:350
llvm::MDNode::getContext
LLVMContext & getContext() const
Definition:Metadata.h:1237
llvm::MFPropsModifier
An RAII based helper class to modify MachineFunctionProperties when running pass.
Definition:MachinePassManager.h:42
llvm::MachineBasicBlock
Definition:MachineBasicBlock.h:125
llvm::MachineBasicBlock::insert
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
Definition:MachineBasicBlock.cpp:1456
llvm::MachineBasicBlock::SkipPHIsLabelsAndDebug
iterator SkipPHIsLabelsAndDebug(iterator I, Register Reg=Register(), bool SkipPseudoOp=true)
Return the first instruction in MBB after I that is not a PHI, label or debug.
Definition:MachineBasicBlock.cpp:227
llvm::MachineBasicBlock::getFirstTerminator
iterator getFirstTerminator()
Returns an iterator to the first terminator instruction of this basic block.
Definition:MachineBasicBlock.cpp:244
llvm::MachineBasicBlock::begin
iterator begin()
Definition:MachineBasicBlock.h:355
llvm::MachineBasicBlock::instr_end
instr_iterator instr_end()
Definition:MachineBasicBlock.h:341
llvm::MachineBasicBlock::end
iterator end()
Definition:MachineBasicBlock.h:357
llvm::MachineBasicBlock::erase
instr_iterator erase(instr_iterator I)
Remove an instruction from the instruction list and delete it.
Definition:MachineBasicBlock.cpp:1443
llvm::MachineDominatorTreeWrapperPass
Analysis pass which computes a MachineDominatorTree.
Definition:MachineDominators.h:131
llvm::MachineFunctionPass
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
Definition:MachineFunctionPass.h:30
llvm::MachineFunctionPass::getAnalysisUsage
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
Definition:MachineFunctionPass.cpp:169
llvm::MachineFunction::DebugPHIRegallocPos
Location of a PHI instruction that is also a debug-info variable value, for the duration of register ...
Definition:MachineFunction.h:584
llvm::MachineFunction
Definition:MachineFunction.h:267
llvm::MachineFunction::useDebugInstrRef
bool useDebugInstrRef() const
Returns true if the function's variable locations are tracked with instruction referencing.
Definition:MachineFunction.cpp:1298
llvm::MachineFunction::getSubtarget
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
Definition:MachineFunction.h:733
llvm::MachineFunction::getName
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
Definition:MachineFunction.cpp:645
llvm::MachineFunction::getRegInfo
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Definition:MachineFunction.h:743
llvm::MachineFunction::getFunction
Function & getFunction()
Return the LLVM function that this machine code represents.
Definition:MachineFunction.h:704
llvm::MachineFunction::end
iterator end()
Definition:MachineFunction.h:949
llvm::MachineFunction::DebugPHIPositions
DenseMap< unsigned, DebugPHIRegallocPos > DebugPHIPositions
Map of debug instruction numbers to the position of their PHI instructions during register allocation...
Definition:MachineFunction.h:595
llvm::MachineInstrBuilder::addMetadata
const MachineInstrBuilder & addMetadata(const MDNode *MD) const
Definition:MachineInstrBuilder.h:238
llvm::MachineInstrBundleIterator< MachineInstr >
llvm::MachineInstr
Representation of each machine instruction.
Definition:MachineInstr.h:71
llvm::MachineInstr::isCopy
bool isCopy() const
Definition:MachineInstr.h:1440
llvm::MachineInstr::getOperand
const MachineOperand & getOperand(unsigned i) const
Definition:MachineInstr.h:587
llvm::MachineOperand
MachineOperand class - Representation of each machine instruction operand.
Definition:MachineOperand.h:48
llvm::MachineOperand::setSubReg
void setSubReg(unsigned subReg)
Definition:MachineOperand.h:490
llvm::MachineOperand::getSubReg
unsigned getSubReg() const
Definition:MachineOperand.h:374
llvm::MachineOperand::isReg
bool isReg() const
isReg - Tests if this is a MO_Register operand.
Definition:MachineOperand.h:329
llvm::MachineOperand::setReg
void setReg(Register Reg)
Change the register this operand corresponds to.
Definition:MachineOperand.cpp:61
llvm::MachineOperand::getParent
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
Definition:MachineOperand.h:243
llvm::MachineOperand::substPhysReg
void substPhysReg(MCRegister Reg, const TargetRegisterInfo &)
substPhysReg - Substitute the current register with the physical register Reg, taking any existing Su...
Definition:MachineOperand.cpp:93
llvm::MachineOperand::setIsDebug
void setIsDebug(bool Val=true)
Definition:MachineOperand.h:547
llvm::MachineOperand::getReg
Register getReg() const
getReg - Returns the register number.
Definition:MachineOperand.h:369
llvm::MachineOperand::isIdenticalTo
bool isIdenticalTo(const MachineOperand &Other) const
Returns true if this operand is identical to the specified operand except for liveness related flags ...
Definition:MachineOperand.cpp:319
llvm::MachineOperand::CreateReg
static MachineOperand CreateReg(Register Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isEarlyClobber=false, unsigned SubReg=0, bool isDebug=false, bool isInternalRead=false, bool isRenamable=false)
Definition:MachineOperand.h:838
llvm::MachineOperand::CreateFI
static MachineOperand CreateFI(int Idx)
Definition:MachineOperand.h:870
llvm::MachineRegisterInfo
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Definition:MachineRegisterInfo.h:51
llvm::MapVector
This class implements a map that also provides access to all stored values in a deterministic order.
Definition:MapVector.h:36
llvm::MapVector::begin
iterator begin()
Definition:MapVector.h:69
llvm::MapVector::insert
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Definition:MapVector.h:141
llvm::PassRegistry::getPassRegistry
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Definition:PassRegistry.cpp:24
llvm::PreservedAnalyses
A set of analyses that are preserved following a run of a transformation pass.
Definition:Analysis.h:111
llvm::PreservedAnalyses::all
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition:Analysis.h:117
llvm::PreservedAnalyses::getChecker
PreservedAnalysisChecker getChecker() const
Build a checker for this PreservedAnalyses and the specified analysis type.
Definition:Analysis.h:264
llvm::Register
Wrapper class representing virtual and physical registers.
Definition:Register.h:19
llvm::Register::isVirtual
constexpr bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
Definition:Register.h:91
llvm::LDVImpl
Definition:LiveDebugValues.h:25
llvm::SlotIndex
SlotIndex - An opaque wrapper around machine indexes.
Definition:SlotIndexes.h:65
llvm::SlotIndex::getNextIndex
SlotIndex getNextIndex() const
Returns the next index.
Definition:SlotIndexes.h:262
llvm::SlotIndex::isEarlierEqualInstr
static bool isEarlierEqualInstr(SlotIndex A, SlotIndex B)
Return true if A refers to the same instruction as B or an earlier one.
Definition:SlotIndexes.h:188
llvm::SlotIndex::getNextSlot
SlotIndex getNextSlot() const
Returns the next slot in the index list.
Definition:SlotIndexes.h:252
llvm::SlotIndexes
SlotIndexes pass.
Definition:SlotIndexes.h:297
llvm::SlotIndexes::getMBBStartIdx
SlotIndex getMBBStartIdx(unsigned Num) const
Returns the first index in the given basic block number.
Definition:SlotIndexes.h:460
llvm::SlotIndexes::getIndexBefore
SlotIndex getIndexBefore(const MachineInstr &MI) const
getIndexBefore - Returns the index of the last indexed instruction before MI, or the start index of i...
Definition:SlotIndexes.h:416
llvm::SmallDenseMap
Definition:DenseMap.h:883
llvm::SmallSet
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
Definition:SmallSet.h:132
llvm::SmallVectorBase::empty
bool empty() const
Definition:SmallVector.h:81
llvm::SmallVectorBase::size
size_t size() const
Definition:SmallVector.h:78
llvm::SmallVectorImpl
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition:SmallVector.h:573
llvm::SmallVectorImpl::assign
void assign(size_type NumElts, ValueParamT Elt)
Definition:SmallVector.h:704
llvm::SmallVectorImpl::erase
iterator erase(const_iterator CI)
Definition:SmallVector.h:737
llvm::SmallVectorImpl::clear
void clear()
Definition:SmallVector.h:610
llvm::SmallVectorTemplateBase::push_back
void push_back(const T &Elt)
Definition:SmallVector.h:413
llvm::SmallVectorTemplateCommon::end
iterator end()
Definition:SmallVector.h:269
llvm::SmallVectorTemplateCommon::begin
iterator begin()
Definition:SmallVector.h:267
llvm::SmallVectorTemplateCommon::back
reference back()
Definition:SmallVector.h:308
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition:SmallVector.h:1196
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition:StringRef.h:51
llvm::StringRef::empty
constexpr bool empty() const
empty - Check if the string is empty.
Definition:StringRef.h:147
llvm::TargetInstrInfo
TargetInstrInfo - Interface to description of machine instruction set.
Definition:TargetInstrInfo.h:112
llvm::TargetRegisterClass
Definition:TargetRegisterInfo.h:44
llvm::TargetRegisterInfo
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Definition:TargetRegisterInfo.h:235
llvm::TargetSubtargetInfo::getRegisterInfo
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
Definition:TargetSubtargetInfo.h:129
llvm::TargetSubtargetInfo::getInstrInfo
virtual const TargetInstrInfo * getInstrInfo() const
Definition:TargetSubtargetInfo.h:97
llvm::VNInfo
VNInfo - Value Number Information.
Definition:LiveInterval.h:53
llvm::VNInfo::id
unsigned id
The ID number of this value.
Definition:LiveInterval.h:58
llvm::VNInfo::def
SlotIndex def
The index of the defining instruction.
Definition:LiveInterval.h:61
llvm::VirtRegMap
Definition:VirtRegMap.h:34
llvm::VirtRegMap::getStackSlot
int getStackSlot(Register virtReg) const
returns the stack slot mapped to the specified virtual register
Definition:VirtRegMap.h:171
llvm::VirtRegMap::getMachineFunction
MachineFunction & getMachineFunction() const
Definition:VirtRegMap.h:74
llvm::VirtRegMap::getPhys
MCRegister getPhys(Register virtReg) const
returns the physical register mapped to the specified virtual register
Definition:VirtRegMap.h:90
llvm::VirtRegMap::hasPhys
bool hasPhys(Register virtReg) const
returns true if the specified virtual register is mapped to a physical register
Definition:VirtRegMap.h:86
llvm::VirtRegMap::isAssignedReg
bool isAssignedReg(Register virtReg) const
returns true if the specified virtual register is not mapped to a stack slot or rematerialized.
Definition:VirtRegMap.h:161
llvm::VirtRegMap::NO_STACK_SLOT
static constexpr int NO_STACK_SLOT
Definition:VirtRegMap.h:65
llvm::cl::opt
Definition:CommandLine.h:1423
llvm::ilist_node_impl::getIterator
self_iterator getIterator()
Definition:ilist_node.h:132
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition:raw_ostream.h:52
uint8_t
unsigned
false
Definition:StackSlotColoring.cpp:193
llvm::AArch64CC::LS
@ LS
Definition:AArch64BaseInfo.h:264
llvm::CallingConv::ID
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition:CallingConv.h:24
llvm::M68k::MemAddrModeKind::L
@ L
llvm::X86Disassembler::Reg
Reg
All possible values of the reg field in the ModR/M byte.
Definition:X86DisassemblerDecoder.h:621
llvm::cl::Hidden
@ Hidden
Definition:CommandLine.h:137
llvm::cl::init
initializer< Ty > init(const Ty &Val)
Definition:CommandLine.h:443
llvm::jitlink::Scope
Scope
Defines the scope in which this symbol should be visible: Default – Visible in the public interface o...
Definition:JITLink.h:412
llvm::pdb::PDB_SymType::Label
@ Label
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:AddressRanges.h:18
llvm::find
auto find(R &&Range, const T &Val)
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly.
Definition:STLExtras.h:1759
llvm::BuildMI
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
Definition:MachineInstrBuilder.h:373
llvm::operator!=
bool operator!=(uint64_t V1, const APInt &V2)
Definition:APInt.h:2082
llvm::make_early_inc_range
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
Definition:STLExtras.h:657
llvm::operator==
bool operator==(const AddressRangeValuePair &LHS, const AddressRangeValuePair &RHS)
Definition:AddressRanges.h:153
llvm::skipDebugInstructionsForward
IterT skipDebugInstructionsForward(IterT It, IterT End, bool SkipPseudoOp=true)
Increment It until it points to a non-debug instruction or to End and return the resulting iterator.
Definition:MachineBasicBlock.h:1416
llvm::any_of
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
Definition:STLExtras.h:1746
llvm::dbgs
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition:Debug.cpp:163
llvm::none_of
bool none_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::none_of which take ranges instead of having to pass begin/end explicitly.
Definition:STLExtras.h:1753
llvm::is_contained
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
Definition:STLExtras.h:1903
llvm::initializeLiveDebugVariablesWrapperLegacyPass
void initializeLiveDebugVariablesWrapperLegacyPass(PassRegistry &)
llvm::InsnRange
std::pair< const MachineInstr *, const MachineInstr * > InsnRange
InsnRange - This is used to track range of instructions with identical lexical scope.
Definition:LexicalScopes.h:39
llvm::printReg
Printable printReg(Register Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubIdx=0, const MachineRegisterInfo *MRI=nullptr)
Prints virtual and physical registers with or without a TRI instance.
Definition:TargetRegisterInfo.cpp:107
llvm::printMBBReference
Printable printMBBReference(const MachineBasicBlock &MBB)
Prints a machine basic block reference.
Definition:MachineBasicBlock.cpp:122
raw_ostream.h
llvm::AnalysisKey
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition:Analysis.h:28
llvm::LiveRange::Segment
This represents a simple continuous liveness interval for a value.
Definition:LiveInterval.h:162
llvm::LiveRange::Segment::valno
VNInfo * valno
Definition:LiveInterval.h:165
llvm::LiveRange::Segment::end
SlotIndex end
Definition:LiveInterval.h:164
llvm::cl::desc
Definition:CommandLine.h:409

Generated on Fri Jul 18 2025 10:41:15 for LLVM by doxygen 1.9.6
[8]ページ先頭

©2009-2025 Movatter.jp