Skip to content

Commit d92252b

Browse files
committed
rebase fallout
1 parent 356f5b4 commit d92252b

17 files changed

+117
-85
lines changed

llvm/include/llvm/IR/DebugProgramInstruction.h

+18-12
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,10 @@ class raw_ostream;
7777
/// We need a discriminator for dyn/isa casts. In order to avoid paying for a
7878
/// vtable for "virtual" functions too, subclasses must add a new discriminator
7979
/// value (RecordKind) and cases to a few functions in the base class:
80-
/// deleteRecord()
81-
/// clone()
80+
/// deleteRecord
81+
/// clone
82+
/// isIdenticalToWhenDefined
83+
/// isEquivalentTo
8284
/// both print methods
8385
class DbgRecord : public ilist_node<DbgRecord> {
8486
public:
@@ -101,6 +103,8 @@ class DbgRecord : public ilist_node<DbgRecord> {
101103
DbgRecord *clone() const;
102104
void print(raw_ostream &O, bool IsForDebug = false) const;
103105
void print(raw_ostream &O, ModuleSlotTracker &MST, bool IsForDebug) const;
106+
bool isIdenticalToWhenDefined(const DbgRecord &R) const;
107+
bool isEquivalentTo(const DbgRecord &R) const;
104108
///@}
105109

106110
Kind getRecordKind() const { return RecordKind; }
@@ -129,11 +133,12 @@ class DbgRecord : public ilist_node<DbgRecord> {
129133
void removeFromParent();
130134
void eraseFromParent();
131135

132-
DPValue *getNextNode() { return &*std::next(getIterator()); }
133-
DPValue *getPrevNode() { return &*std::prev(getIterator()); }
134-
135-
DPValue *getNextNode() { return &*std::next(getIterator()); }
136-
DPValue *getPrevNode() { return &*std::prev(getIterator()); }
136+
DbgRecord *getNextNode() { return &*std::next(getIterator()); }
137+
DbgRecord *getPrevNode() { return &*std::prev(getIterator()); }
138+
void insertBefore(DbgRecord *InsertBefore);
139+
void insertAfter(DbgRecord *InsertAfter);
140+
void moveBefore(DbgRecord *MoveBefore);
141+
void moveAfter(DbgRecord *MoveAfter);
137142

138143
DebugLoc getDebugLoc() const { return DbgLoc; }
139144
void setDebugLoc(DebugLoc Loc) { DbgLoc = std::move(Loc); }
@@ -180,6 +185,7 @@ class DPValue : public DbgRecord, protected DebugValueUser {
180185

181186
DILocalVariable *Variable;
182187
DIExpression *Expression;
188+
DIExpression *AddressExpression;
183189

184190
public:
185191
/// Create a new DPValue representing the intrinsic \p DVI, for example the
@@ -331,12 +337,12 @@ class DPValue : public DbgRecord, protected DebugValueUser {
331337
/// is described.
332338
std::optional<uint64_t> getFragmentSizeInBits() const;
333339

334-
bool isEquivalentTo(const DPValue &Other) {
340+
bool isEquivalentTo(const DPValue &Other) const {
335341
return DbgLoc == Other.DbgLoc && isIdenticalToWhenDefined(Other);
336342
}
337343
// Matches the definition of the Instruction version, equivalent to above but
338344
// without checking DbgLoc.
339-
bool isIdenticalToWhenDefined(const DPValue &Other) {
345+
bool isIdenticalToWhenDefined(const DPValue &Other) const {
340346
return std::tie(Type, DebugValues, Variable, Expression,
341347
AddressExpression) ==
342348
std::tie(Other.Type, Other.DebugValues, Other.Variable,
@@ -464,9 +470,9 @@ class DPMarker {
464470
/// \p InsertAtHead is true, at the start.
465471
void insertDPValue(DbgRecord *New, bool InsertAtHead);
466472
/// Insert a DPValue prior to a DPValue contained within this marker.
467-
void insertDPValue(DbgRecord *New, DPValue *InsertBefore);
473+
void insertDPValue(DbgRecord *New, DbgRecord *InsertBefore);
468474
/// Insert a DPValue after a DPValue contained within this marker.
469-
void insertDPValueAfter(DbgRecord *New, DPValue *InsertAfter);
475+
void insertDPValueAfter(DbgRecord *New, DbgRecord *InsertAfter);
470476
/// Clone all DPMarkers from \p From into this marker. There are numerous
471477
/// options to customise the source/destination, due to gnarliness, see class
472478
/// comment.
@@ -513,7 +519,7 @@ inline raw_ostream &operator<<(raw_ostream &OS, const DPValue &Value) {
513519
/// to be inlined as it's frequently called, but also come after the declaration
514520
/// of DPMarker. Thus: it's pre-declared by users like Instruction, then an
515521
/// inlineable body defined here.
516-
inline iterator_range<simple_ilist<DPValue>::iterator>
522+
inline iterator_range<simple_ilist<DbgRecord>::iterator>
517523
getDbgValueRange(DPMarker *DbgMarker) {
518524
if (!DbgMarker)
519525
return DPMarker::getEmptyDPValueRange();

llvm/include/llvm/IR/Instruction.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ template <> struct ilist_alloc_traits<Instruction> {
4141
static inline void deleteNode(Instruction *V);
4242
};
4343

44-
iterator_range<simple_ilist<DPValue>::iterator> getDbgValueRange(DPMarker *);
44+
iterator_range<simple_ilist<DbgRecord>::iterator> getDbgValueRange(DPMarker *);
4545

4646
class Instruction : public User,
4747
public ilist_node_with_parent<Instruction, BasicBlock,

llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ template <> struct llvm::DenseMapInfo<VariableID> {
8282
}
8383
};
8484

85-
using VarLocInsertPt = PointerUnion<const Instruction *, const DPValue *>;
85+
using VarLocInsertPt = PointerUnion<const Instruction *, const DbgRecord *>;
8686

8787
namespace std {
8888
template <> struct hash<VarLocInsertPt> {
@@ -218,14 +218,14 @@ void FunctionVarLocs::init(FunctionVarLocsBuilder &Builder) {
218218
// block includes VarLocs for any DPValues attached to that instruction.
219219
for (auto &P : Builder.VarLocsBeforeInst) {
220220
// Process VarLocs attached to a DPValue alongside their marker Instruction.
221-
if (isa<const DPValue *>(P.first))
221+
if (isa<const DbgRecord *>(P.first))
222222
continue;
223223
const Instruction *I = cast<const Instruction *>(P.first);
224224
unsigned BlockStart = VarLocRecords.size();
225225
// Any VarLocInfos attached to a DPValue should now be remapped to their
226226
// marker Instruction, in order of DPValue appearance and prior to any
227227
// VarLocInfos attached directly to that instruction.
228-
for (const DPValue &DPV : I->getDbgValueRange()) {
228+
for (const DPValue &DPV : DPValue::filter(I->getDbgValueRange())) {
229229
// Even though DPV defines a variable location, VarLocsBeforeInst can
230230
// still be empty if that VarLoc was redundant.
231231
if (!Builder.VarLocsBeforeInst.count(&DPV))
@@ -829,7 +829,7 @@ class MemLocFragmentFill {
829829
void process(BasicBlock &BB, VarFragMap &LiveSet) {
830830
BBInsertBeforeMap[&BB].clear();
831831
for (auto &I : BB) {
832-
for (auto &DPV : I.getDbgValueRange()) {
832+
for (DPValue &DPV : DPValue::filter(I.getDbgValueRange())) {
833833
if (const auto *Locs = FnVarLocs->getWedge(&DPV)) {
834834
for (const VarLocInfo &Loc : *Locs) {
835835
addDef(Loc, &DPV, *I.getParent(), LiveSet);
@@ -1492,7 +1492,7 @@ const char *locStr(AssignmentTrackingLowering::LocKind Loc) {
14921492
}
14931493
#endif
14941494

1495-
VarLocInsertPt getNextNode(const DPValue *DPV) {
1495+
VarLocInsertPt getNextNode(const DbgRecord *DPV) {
14961496
auto NextIt = ++(DPV->getIterator());
14971497
if (NextIt == DPV->getMarker()->getDbgValueRange().end())
14981498
return DPV->getMarker()->MarkedInstr;
@@ -1507,7 +1507,7 @@ VarLocInsertPt getNextNode(const Instruction *Inst) {
15071507
VarLocInsertPt getNextNode(VarLocInsertPt InsertPt) {
15081508
if (isa<const Instruction *>(InsertPt))
15091509
return getNextNode(cast<const Instruction *>(InsertPt));
1510-
return getNextNode(cast<const DPValue *>(InsertPt));
1510+
return getNextNode(cast<const DbgRecord *>(InsertPt));
15111511
}
15121512

15131513
DbgAssignIntrinsic *CastToDbgAssign(DbgVariableIntrinsic *DVI) {
@@ -1915,7 +1915,7 @@ void AssignmentTrackingLowering::process(BasicBlock &BB, BlockInfo *LiveSet) {
19151915
// attached DPValues, or a non-debug instruction with attached unprocessed
19161916
// DPValues.
19171917
if (II != EI && II->hasDbgValues()) {
1918-
for (DPValue &DPV : II->getDbgValueRange()) {
1918+
for (DPValue &DPV : DPValue::filter(II->getDbgValueRange())) {
19191919
resetInsertionPoint(DPV);
19201920
processDPValue(DPV, LiveSet);
19211921
assert(LiveSet->isValid());
@@ -2172,7 +2172,7 @@ static AssignmentTrackingLowering::OverlapMap buildOverlapMapAndRecordDeclares(
21722172
};
21732173
for (auto &BB : Fn) {
21742174
for (auto &I : BB) {
2175-
for (auto &DPV : I.getDbgValueRange())
2175+
for (DPValue &DPV : DPValue::filter(I.getDbgValueRange()))
21762176
ProcessDbgRecord(&DPV, DPDeclares);
21772177
if (auto *DII = dyn_cast<DbgVariableIntrinsic>(&I)) {
21782178
ProcessDbgRecord(DII, InstDeclares);
@@ -2462,7 +2462,7 @@ bool AssignmentTrackingLowering::emitPromotedVarLocs(
24622462
for (auto &BB : Fn) {
24632463
for (auto &I : BB) {
24642464
// Skip instructions other than dbg.values and dbg.assigns.
2465-
for (DPValue &DPV : I.getDbgValueRange())
2465+
for (DPValue &DPV : DPValue::filter(I.getDbgValueRange()))
24662466
if (DPV.isDbgValue() || DPV.isDbgAssign())
24672467
TranslateDbgRecord(&DPV);
24682468
auto *DVI = dyn_cast<DbgValueInst>(&I);
@@ -2564,7 +2564,7 @@ removeRedundantDbgLocsUsingBackwardScan(const BasicBlock *BB,
25642564
}
25652565
};
25662566
HandleLocsForWedge(&I);
2567-
for (DPValue &DPV : reverse(I.getDbgValueRange()))
2567+
for (DPValue &DPV : reverse(DPValue::filter(I.getDbgValueRange())))
25682568
HandleLocsForWedge(&DPV);
25692569
}
25702570

@@ -2629,7 +2629,7 @@ removeRedundantDbgLocsUsingForwardScan(const BasicBlock *BB,
26292629
}
26302630
};
26312631

2632-
for (DPValue &DPV : I.getDbgValueRange())
2632+
for (DPValue &DPV : DPValue::filter(I.getDbgValueRange()))
26332633
HandleLocsForWedge(&DPV);
26342634
HandleLocsForWedge(&I);
26352635
}
@@ -2715,7 +2715,7 @@ removeUndefDbgLocsFromEntryBlock(const BasicBlock *BB,
27152715
Changed = true;
27162716
}
27172717
};
2718-
for (DPValue &DPV : I.getDbgValueRange())
2718+
for (DPValue &DPV : DPValue::filter(I.getDbgValueRange()))
27192719
HandleLocsForWedge(&DPV);
27202720
HandleLocsForWedge(&I);
27212721
}

llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -3274,7 +3274,7 @@ void IRTranslator::translateDbgDeclareRecord(Value *Address, bool HasArgList,
32743274

32753275
void IRTranslator::translateDbgInfo(const Instruction &Inst,
32763276
MachineIRBuilder &MIRBuilder) {
3277-
for (DPValue &DPV : Inst.getDbgValueRange()) {
3277+
for (DPValue &DPV : DPValue::filter(Inst.getDbgValueRange())) {
32783278
const DILocalVariable *Variable = DPV.getVariable();
32793279
const DIExpression *Expression = DPV.getExpression();
32803280
Value *V = DPV.getVariableLocationOp(0);

llvm/lib/IR/AsmWriter.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -1131,19 +1131,19 @@ void SlotTracker::processFunctionMetadata(const Function &F) {
11311131
processGlobalObjectMetadata(F);
11321132
for (auto &BB : F) {
11331133
for (auto &I : BB) {
1134-
for (const DbgRecord &DPV : I.getDbgValueRange())
1135-
processDbgRecordMetadata(DPV);
1134+
for (const DbgRecord &DR : I.getDbgValueRange())
1135+
processDbgRecordMetadata(DR);
11361136
processInstructionMetadata(I);
11371137
}
11381138
}
11391139
}
11401140

1141-
void SlotTracker::processDPValueMetadata(const DPValue &DPV) {
1141+
void SlotTracker::processDbgRecordMetadata(const DbgRecord &DR) {
11421142
if (const DPValue *DPV = dyn_cast<const DPValue>(&DR)) {
11431143
CreateMetadataSlot(DPV->getVariable());
11441144
CreateMetadataSlot(DPV->getDebugLoc());
1145-
if (DPV.isDbgAssign()) {
1146-
CreateMetadataSlot(DPV.getAssignID());
1145+
if (DPV->isDbgAssign())
1146+
CreateMetadataSlot(DPV->getAssignID());
11471147
} else {
11481148
llvm_unreachable("unsupported DbgRecord kind");
11491149
}

llvm/lib/IR/DebugInfo.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1827,7 +1827,7 @@ void at::deleteAll(Function *F) {
18271827
SmallVector<DPValue *, 12> DPToDelete;
18281828
for (BasicBlock &BB : *F) {
18291829
for (Instruction &I : BB) {
1830-
for (auto &DPV : I.getDbgValueRange())
1830+
for (DPValue &DPV : DPValue::filter(I.getDbgValueRange()))
18311831
if (DPV.isDbgAssign())
18321832
DPToDelete.push_back(&DPV);
18331833
if (auto *DAI = dyn_cast<DbgAssignIntrinsic>(&I))
@@ -2251,7 +2251,7 @@ bool AssignmentTrackingPass::runOnFunction(Function &F) {
22512251
};
22522252
for (auto &BB : F) {
22532253
for (auto &I : BB) {
2254-
for (auto &DPV : I.getDbgValueRange()) {
2254+
for (DPValue &DPV : DPValue::filter(I.getDbgValueRange())) {
22552255
if (DPV.isDbgDeclare())
22562256
ProcessDeclare(&DPV, DPVDeclares);
22572257
}

0 commit comments

Comments
 (0)