Skip to content

Commit c862e61

Browse files
committed
Revert "[RemoveDIs] Enable DPLabels conversion [3b/3] (#82639)"
This reverts commit 71d47a0 because it causes clang to crash in some cases. See repro posted at 71d47a0
1 parent 10c48a7 commit c862e61

File tree

3 files changed

+8
-45
lines changed

3 files changed

+8
-45
lines changed

llvm/include/llvm/IR/DebugProgramInstruction.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ class BasicBlock;
6262
class MDNode;
6363
class Module;
6464
class DbgVariableIntrinsic;
65-
class DbgInfoIntrinsic;
66-
class DbgLabelInst;
6765
class DIAssignID;
6866
class DPMarker;
6967
class DPValue;
@@ -82,7 +80,6 @@ class raw_ostream;
8280
/// clone
8381
/// isIdenticalToWhenDefined
8482
/// both print methods
85-
/// createDebugIntrinsic
8683
class DbgRecord : public ilist_node<DbgRecord> {
8784
public:
8885
/// Marker that this DbgRecord is linked into.
@@ -106,11 +103,6 @@ class DbgRecord : public ilist_node<DbgRecord> {
106103
void print(raw_ostream &O, bool IsForDebug = false) const;
107104
void print(raw_ostream &O, ModuleSlotTracker &MST, bool IsForDebug) const;
108105
bool isIdenticalToWhenDefined(const DbgRecord &R) const;
109-
/// Convert this DbgRecord back into an appropriate llvm.dbg.* intrinsic.
110-
/// \p InsertBefore Optional position to insert this intrinsic.
111-
/// \returns A new llvm.dbg.* intrinsic representiung this DbgRecord.
112-
DbgInfoIntrinsic *createDebugIntrinsic(Module *M,
113-
Instruction *InsertBefore) const;
114106
///@}
115107

116108
/// Same as isIdenticalToWhenDefined but checks DebugLoc too.
@@ -185,8 +177,6 @@ class DPLabel : public DbgRecord {
185177
DPLabel *clone() const;
186178
void print(raw_ostream &O, bool IsForDebug = false) const;
187179
void print(raw_ostream &ROS, ModuleSlotTracker &MST, bool IsForDebug) const;
188-
DbgLabelInst *createDebugIntrinsic(Module *M,
189-
Instruction *InsertBefore) const;
190180

191181
void setLabel(DILabel *NewLabel) { Label = NewLabel; }
192182
DILabel *getLabel() const { return Label; }

llvm/lib/IR/BasicBlock.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,6 @@ void BasicBlock::convertToNewDbgValues() {
8181
continue;
8282
}
8383

84-
if (DbgLabelInst *DLI = dyn_cast<DbgLabelInst>(&I)) {
85-
DPVals.push_back(new DPLabel(DLI->getLabel(), DLI->getDebugLoc()));
86-
DLI->eraseFromParent();
87-
continue;
88-
}
89-
9084
if (DPVals.empty())
9185
continue;
9286

@@ -113,12 +107,16 @@ void BasicBlock::convertFromNewDbgValues() {
113107
continue;
114108

115109
DPMarker &Marker = *Inst.DbgMarker;
116-
for (DbgRecord &DR : Marker.getDbgValueRange())
117-
InstList.insert(Inst.getIterator(),
118-
DR.createDebugIntrinsic(getModule(), nullptr));
110+
for (DbgRecord &DR : Marker.getDbgValueRange()) {
111+
if (auto *DPV = dyn_cast<DPValue>(&DR))
112+
InstList.insert(Inst.getIterator(),
113+
DPV->createDebugIntrinsic(getModule(), nullptr));
114+
else
115+
llvm_unreachable("unsupported DbgRecord kind");
116+
}
119117

120118
Marker.eraseFromParent();
121-
}
119+
};
122120

123121
// Assume no trailing DPValues: we could technically create them at the end
124122
// of the block, after a terminator, but this would be non-cannonical and

llvm/lib/IR/DebugProgramInstruction.cpp

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -112,17 +112,6 @@ bool DbgRecord::isEquivalentTo(const DbgRecord &R) const {
112112
return getDebugLoc() == R.getDebugLoc() && isIdenticalToWhenDefined(R);
113113
}
114114

115-
DbgInfoIntrinsic *
116-
DbgRecord::createDebugIntrinsic(Module *M, Instruction *InsertBefore) const {
117-
switch (RecordKind) {
118-
case ValueKind:
119-
return cast<DPValue>(this)->createDebugIntrinsic(M, InsertBefore);
120-
case LabelKind:
121-
return cast<DPLabel>(this)->createDebugIntrinsic(M, InsertBefore);
122-
};
123-
llvm_unreachable("unsupported DbgRecord kind");
124-
}
125-
126115
DPValue *DPValue::createDPValue(Value *Location, DILocalVariable *DV,
127116
DIExpression *Expr, const DILocation *DI) {
128117
return new DPValue(ValueAsMetadata::get(Location), DV, Expr, DI,
@@ -388,20 +377,6 @@ DPValue::createDebugIntrinsic(Module *M, Instruction *InsertBefore) const {
388377
return DVI;
389378
}
390379

391-
DbgLabelInst *DPLabel::createDebugIntrinsic(Module *M,
392-
Instruction *InsertBefore) const {
393-
auto *LabelFn = Intrinsic::getDeclaration(M, Intrinsic::dbg_label);
394-
Value *Args[] = {
395-
MetadataAsValue::get(getDebugLoc()->getContext(), getLabel())};
396-
DbgLabelInst *DbgLabel = cast<DbgLabelInst>(
397-
CallInst::Create(LabelFn->getFunctionType(), LabelFn, Args));
398-
DbgLabel->setTailCall();
399-
DbgLabel->setDebugLoc(getDebugLoc());
400-
if (InsertBefore)
401-
DbgLabel->insertBefore(InsertBefore);
402-
return DbgLabel;
403-
}
404-
405380
Value *DPValue::getAddress() const {
406381
auto *MD = getRawAddress();
407382
if (auto *V = dyn_cast<ValueAsMetadata>(MD))

0 commit comments

Comments
 (0)