Skip to content

Commit d2000b4

Browse files
committed
Revert "[DebugInfo] Add new instruction and DIExpression operator for variadic debug values"
This reverts commit d07f106.
1 parent d07f106 commit d2000b4

24 files changed

+147
-476
lines changed

llvm/docs/LangRef.rst

-8
Original file line numberDiff line numberDiff line change
@@ -5311,14 +5311,6 @@ The current supported opcode vocabulary is limited:
53115311
``AsmPrinter`` pass when a call site parameter value
53125312
(``DW_AT_call_site_parameter_value``) is represented as entry value
53135313
of the parameter.
5314-
- ``DW_OP_LLVM_arg, N`` is used in debug intrinsics that refer to more than one
5315-
value, such as one that calculates the sum of two registers. This is always
5316-
used in combination with an ordered list of values, such that
5317-
``DW_OP_LLVM_arg, N`` refers to the ``N``th element in that list. For
5318-
example, ``!DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_minus,
5319-
DW_OP_stack_value)`` used with the list ``(%reg1, %reg2)`` would evaluate to
5320-
``%reg1 - reg2``. This list of values should be provided by the containing
5321-
intrinsic/instruction.
53225314
- ``DW_OP_breg`` (or ``DW_OP_bregx``) represents a content on the provided
53235315
signed offset of the specified register. The opcode is only generated by the
53245316
``AsmPrinter`` pass to describe call site parameter value which requires an

llvm/docs/SourceLevelDebugging.rst

+2-20
Original file line numberDiff line numberDiff line change
@@ -576,15 +576,13 @@ the equivalent location is used.
576576

577577
After MIR locations are assigned to each variable, machine pseudo-instructions
578578
corresponding to each ``llvm.dbg.value`` and ``llvm.dbg.addr`` intrinsic are
579-
inserted. There are two forms of this type of instruction.
580-
581-
The first form, ``DBG_VALUE``, appears thus:
579+
inserted. These ``DBG_VALUE`` instructions appear thus:
582580

583581
.. code-block:: text
584582
585583
DBG_VALUE %1, $noreg, !123, !DIExpression()
586584
587-
And has the following operands:
585+
And have the following operands:
588586
* The first operand can record the variable location as a register,
589587
a frame index, an immediate, or the base address register if the original
590588
debug intrinsic referred to memory. ``$noreg`` indicates the variable
@@ -596,22 +594,6 @@ And has the following operands:
596594
* Operand 3 is the Variable field of the original debug intrinsic.
597595
* Operand 4 is the Expression field of the original debug intrinsic.
598596

599-
The second form, ``DBG_VALUE_LIST``, appears thus:
600-
601-
.. code-block:: text
602-
603-
DBG_VALUE_LIST !123, !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus), %1, %2
604-
605-
And has the following operands:
606-
* The first operand is the Variable field of the original debug intrinsic.
607-
* The second operand is the Expression field of the original debug intrinsic.
608-
* Any number of operands, from the 3rd onwards, record a sequence of variable
609-
location operands, which may take any of the same values as the first
610-
operand of the ``DBG_VALUE`` instruction above. These variable location
611-
operands are inserted into the final DWARF Expression in positions indicated
612-
by the DW_OP_LLVM_arg operator in the DIExpression, as described in
613-
:ref:`DIExpression<_DIExpression>`.
614-
615597
The position at which the DBG_VALUEs are inserted should correspond to the
616598
positions of their matching ``llvm.dbg.value`` intrinsics in the IR block. As
617599
with optimization, LLVM aims to preserve the order in which variable

llvm/include/llvm/BinaryFormat/Dwarf.h

-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ enum LocationAtom {
144144
DW_OP_LLVM_tag_offset = 0x1002, ///< Only used in LLVM metadata.
145145
DW_OP_LLVM_entry_value = 0x1003, ///< Only used in LLVM metadata.
146146
DW_OP_LLVM_implicit_pointer = 0x1004, ///< Only used in LLVM metadata.
147-
DW_OP_LLVM_arg = 0x1005, ///< Only used in LLVM metadata.
148147
};
149148

150149
enum TypeKind : uint8_t {

llvm/include/llvm/CodeGen/MachineInstr.h

+25-63
Original file line numberDiff line numberDiff line change
@@ -420,11 +420,11 @@ class MachineInstr
420420
/// instruction is indirect; will be an invalid register if this value is
421421
/// not indirect, and an immediate with value 0 otherwise.
422422
const MachineOperand &getDebugOffset() const {
423-
assert(isNonListDebugValue() && "not a DBG_VALUE");
423+
assert(isDebugValue() && "not a DBG_VALUE");
424424
return getOperand(1);
425425
}
426426
MachineOperand &getDebugOffset() {
427-
assert(isNonListDebugValue() && "not a DBG_VALUE");
427+
assert(isDebugValue() && "not a DBG_VALUE");
428428
return getOperand(1);
429429
}
430430

@@ -439,7 +439,6 @@ class MachineInstr
439439

440440
/// Return the operand for the complex address expression referenced by
441441
/// this DBG_VALUE instruction.
442-
const MachineOperand &getDebugExpressionOp() const;
443442
MachineOperand &getDebugExpressionOp();
444443

445444
/// Return the complex address expression referenced by
@@ -502,43 +501,26 @@ class MachineInstr
502501
return *(debug_operands().begin() + Index);
503502
}
504503

505-
/// Returns whether this debug value has at least one debug operand with the
506-
/// register \p Reg.
507-
bool hasDebugOperandForReg(Register Reg) const {
508-
return any_of(debug_operands(), [Reg](const MachineOperand &Op) {
509-
return Op.isReg() && Op.getReg() == Reg;
510-
});
504+
/// Returns a pointer to the operand corresponding to a debug use of Reg, or
505+
/// nullptr if Reg is not used in any debug operand.
506+
const MachineOperand *getDebugOperandForReg(Register Reg) const {
507+
const MachineOperand *RegOp =
508+
find_if(debug_operands(), [Reg](const MachineOperand &Op) {
509+
return Op.isReg() && Op.getReg() == Reg;
510+
});
511+
return RegOp == adl_end(debug_operands()) ? nullptr : RegOp;
511512
}
512-
513-
/// Returns a range of all of the operands that correspond to a debug use of
514-
/// \p Reg.
515-
template <typename Operand, typename Instruction>
516-
static iterator_range<
517-
filter_iterator<Operand *, std::function<bool(Operand &Op)>>>
518-
getDebugOperandsForReg(Instruction *MI, Register Reg) {
519-
std::function<bool(Operand & Op)> OpUsesReg(
520-
[Reg](Operand &Op) { return Op.isReg() && Op.getReg() == Reg; });
521-
return make_filter_range(MI->debug_operands(), OpUsesReg);
522-
}
523-
iterator_range<filter_iterator<const MachineOperand *,
524-
std::function<bool(const MachineOperand &Op)>>>
525-
getDebugOperandsForReg(Register Reg) const {
526-
return MachineInstr::getDebugOperandsForReg<const MachineOperand,
527-
const MachineInstr>(this, Reg);
528-
}
529-
iterator_range<filter_iterator<MachineOperand *,
530-
std::function<bool(MachineOperand &Op)>>>
531-
getDebugOperandsForReg(Register Reg) {
532-
return MachineInstr::getDebugOperandsForReg<MachineOperand, MachineInstr>(
533-
this, Reg);
534-
}
535-
536-
bool isDebugOperand(const MachineOperand *Op) const {
537-
return Op >= adl_begin(debug_operands()) && Op <= adl_end(debug_operands());
513+
MachineOperand *getDebugOperandForReg(Register Reg) {
514+
MachineOperand *RegOp =
515+
find_if(debug_operands(), [Reg](const MachineOperand &Op) {
516+
return Op.isReg() && Op.getReg() == Reg;
517+
});
518+
return RegOp == adl_end(debug_operands()) ? nullptr : RegOp;
538519
}
539520

540521
unsigned getDebugOperandIndex(const MachineOperand *Op) const {
541-
assert(isDebugOperand(Op) && "Expected a debug operand.");
522+
assert(Op >= adl_begin(debug_operands()) &&
523+
Op <= adl_end(debug_operands()) && "Expected a debug operand.");
542524
return std::distance(adl_begin(debug_operands()), Op);
543525
}
544526

@@ -618,16 +600,12 @@ class MachineInstr
618600
/// location for this DBG_VALUE instruction.
619601
iterator_range<mop_iterator> debug_operands() {
620602
assert(isDebugValue() && "Must be a debug value instruction.");
621-
return isDebugValueList()
622-
? make_range(operands_begin() + 2, operands_end())
623-
: make_range(operands_begin(), operands_begin() + 1);
603+
return make_range(operands_begin(), operands_begin() + 1);
624604
}
625605
/// \copydoc debug_operands()
626606
iterator_range<const_mop_iterator> debug_operands() const {
627607
assert(isDebugValue() && "Must be a debug value instruction.");
628-
return isDebugValueList()
629-
? make_range(operands_begin() + 2, operands_end())
630-
: make_range(operands_begin(), operands_begin() + 1);
608+
return make_range(operands_begin(), operands_begin() + 1);
631609
}
632610
/// Returns a range over all explicit operands that are register definitions.
633611
/// Implicit definition are not included!
@@ -1186,15 +1164,7 @@ class MachineInstr
11861164
// True if the instruction represents a position in the function.
11871165
bool isPosition() const { return isLabel() || isCFIInstruction(); }
11881166

1189-
bool isNonListDebugValue() const {
1190-
return getOpcode() == TargetOpcode::DBG_VALUE;
1191-
}
1192-
bool isDebugValueList() const {
1193-
return getOpcode() == TargetOpcode::DBG_VALUE_LIST;
1194-
}
1195-
bool isDebugValue() const {
1196-
return isNonListDebugValue() || isDebugValueList();
1197-
}
1167+
bool isDebugValue() const { return getOpcode() == TargetOpcode::DBG_VALUE; }
11981168
bool isDebugLabel() const { return getOpcode() == TargetOpcode::DBG_LABEL; }
11991169
bool isDebugRef() const { return getOpcode() == TargetOpcode::DBG_INSTR_REF; }
12001170
bool isDebugInstr() const {
@@ -1204,14 +1174,12 @@ class MachineInstr
12041174
return isDebugInstr() || isPseudoProbe();
12051175
}
12061176

1207-
bool isDebugOffsetImm() const {
1208-
return isNonListDebugValue() && getDebugOffset().isImm();
1209-
}
1177+
bool isDebugOffsetImm() const { return getDebugOffset().isImm(); }
12101178

12111179
/// A DBG_VALUE is indirect iff the location operand is a register and
12121180
/// the offset operand is an immediate.
12131181
bool isIndirectDebugValue() const {
1214-
return isDebugOffsetImm() && getDebugOperand(0).isReg();
1182+
return isDebugValue() && getDebugOperand(0).isReg() && isDebugOffsetImm();
12151183
}
12161184

12171185
/// A DBG_VALUE is an entry value iff its debug expression contains the
@@ -1221,13 +1189,8 @@ class MachineInstr
12211189
/// Return true if the instruction is a debug value which describes a part of
12221190
/// a variable as unavailable.
12231191
bool isUndefDebugValue() const {
1224-
if (!isDebugValue())
1225-
return false;
1226-
// If any $noreg locations are given, this DV is undef.
1227-
for (const MachineOperand &Op : debug_operands())
1228-
if (Op.isReg() && !Op.getReg().isValid())
1229-
return true;
1230-
return false;
1192+
return isDebugValue() && getDebugOperand(0).isReg() &&
1193+
!getDebugOperand(0).getReg().isValid();
12311194
}
12321195

12331196
bool isPHI() const {
@@ -1302,7 +1265,6 @@ class MachineInstr
13021265
case TargetOpcode::EH_LABEL:
13031266
case TargetOpcode::GC_LABEL:
13041267
case TargetOpcode::DBG_VALUE:
1305-
case TargetOpcode::DBG_VALUE_LIST:
13061268
case TargetOpcode::DBG_INSTR_REF:
13071269
case TargetOpcode::DBG_LABEL:
13081270
case TargetOpcode::LIFETIME_START:

llvm/include/llvm/CodeGen/MachineInstrBuilder.h

+3-19
Original file line numberDiff line numberDiff line change
@@ -451,16 +451,9 @@ MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL,
451451
/// for a MachineOperand.
452452
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL,
453453
const MCInstrDesc &MCID, bool IsIndirect,
454-
const MachineOperand &MO, const MDNode *Variable,
454+
MachineOperand &MO, const MDNode *Variable,
455455
const MDNode *Expr);
456456

457-
/// This version of the builder builds a DBG_VALUE or DBG_VALUE_LIST intrinsic
458-
/// for a MachineOperand.
459-
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL,
460-
const MCInstrDesc &MCID, bool IsIndirect,
461-
ArrayRef<MachineOperand> MOs,
462-
const MDNode *Variable, const MDNode *Expr);
463-
464457
/// This version of the builder builds a DBG_VALUE intrinsic
465458
/// for either a value in a register or a register-indirect
466459
/// address and inserts it at position I.
@@ -478,23 +471,14 @@ MachineInstrBuilder BuildMI(MachineBasicBlock &BB,
478471
MachineOperand &MO, const MDNode *Variable,
479472
const MDNode *Expr);
480473

481-
/// This version of the builder builds a DBG_VALUE or DBG_VALUE_LIST intrinsic
482-
/// for a machine operand and inserts it at position I.
483-
MachineInstrBuilder BuildMI(MachineBasicBlock &BB,
484-
MachineBasicBlock::iterator I, const DebugLoc &DL,
485-
const MCInstrDesc &MCID, bool IsIndirect,
486-
ArrayRef<MachineOperand> MOs,
487-
const MDNode *Variable, const MDNode *Expr);
488-
489474
/// Clone a DBG_VALUE whose value has been spilled to FrameIndex.
490475
MachineInstr *buildDbgValueForSpill(MachineBasicBlock &BB,
491476
MachineBasicBlock::iterator I,
492-
const MachineInstr &Orig, int FrameIndex,
493-
Register SpillReg);
477+
const MachineInstr &Orig, int FrameIndex);
494478

495479
/// Update a DBG_VALUE whose value has been spilled to FrameIndex. Useful when
496480
/// modifying an instruction in place while iterating over a basic block.
497-
void updateDbgValueForSpill(MachineInstr &Orig, int FrameIndex, Register Reg);
481+
void updateDbgValueForSpill(MachineInstr &Orig, int FrameIndex);
498482

499483
inline unsigned getDefRegState(bool B) {
500484
return B ? RegState::Define : 0;

llvm/include/llvm/IR/DebugInfoMetadata.h

-8
Original file line numberDiff line numberDiff line change
@@ -2775,14 +2775,6 @@ class DIExpression : public MDNode {
27752775
static DIExpression *appendToStack(const DIExpression *Expr,
27762776
ArrayRef<uint64_t> Ops);
27772777

2778-
/// Create a copy of \p Expr by appending the given list of \p Ops to each
2779-
/// instance of the operand `DW_OP_LLVM_arg, \p ArgNo`. This is used to
2780-
/// modify a specific location used by \p Expr, such as when salvaging that
2781-
/// location.
2782-
static DIExpression *appendOpsToArg(const DIExpression *Expr,
2783-
ArrayRef<uint64_t> Ops, unsigned ArgNo,
2784-
bool StackValue = false);
2785-
27862778
/// Create a DIExpression to describe one part of an aggregate variable that
27872779
/// is fragmented across multiple Values. The DW_OP_LLVM_fragment operation
27882780
/// will be appended to the elements of \c Expr. If \c Expr already contains

llvm/include/llvm/Support/TargetOpcodes.def

-4
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,6 @@ HANDLE_TARGET_OPCODE(SUBREG_TO_REG)
7777
/// DBG_VALUE - a mapping of the llvm.dbg.value intrinsic
7878
HANDLE_TARGET_OPCODE(DBG_VALUE)
7979

80-
/// DBG_VALUE - a mapping of the llvm.dbg.value intrinsic with a variadic
81-
/// list of locations
82-
HANDLE_TARGET_OPCODE(DBG_VALUE_LIST)
83-
8480
/// DBG_INSTR_REF - A mapping of llvm.dbg.value referring to the instruction
8581
/// that defines the value, rather than a virtual register.
8682
HANDLE_TARGET_OPCODE(DBG_INSTR_REF)

llvm/include/llvm/Target/Target.td

-6
Original file line numberDiff line numberDiff line change
@@ -1107,12 +1107,6 @@ def DBG_VALUE : StandardPseudoInstruction {
11071107
let AsmString = "DBG_VALUE";
11081108
let hasSideEffects = false;
11091109
}
1110-
def DBG_VALUE_LIST : StandardPseudoInstruction {
1111-
let OutOperandList = (outs);
1112-
let InOperandList = (ins variable_ops);
1113-
let AsmString = "DBG_VALUE_LIST";
1114-
let hasSideEffects = 0;
1115-
}
11161110
def DBG_INSTR_REF : StandardPseudoInstruction {
11171111
let OutOperandList = (outs);
11181112
let InOperandList = (ins variable_ops);

llvm/lib/BinaryFormat/Dwarf.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,6 @@ StringRef llvm::dwarf::OperationEncodingString(unsigned Encoding) {
153153
return "DW_OP_LLVM_entry_value";
154154
case DW_OP_LLVM_implicit_pointer:
155155
return "DW_OP_LLVM_implicit_pointer";
156-
case DW_OP_LLVM_arg:
157-
return "DW_OP_LLVM_arg";
158156
}
159157
}
160158

@@ -168,7 +166,6 @@ unsigned llvm::dwarf::getOperationEncoding(StringRef OperationEncodingString) {
168166
.Case("DW_OP_LLVM_tag_offset", DW_OP_LLVM_tag_offset)
169167
.Case("DW_OP_LLVM_entry_value", DW_OP_LLVM_entry_value)
170168
.Case("DW_OP_LLVM_implicit_pointer", DW_OP_LLVM_implicit_pointer)
171-
.Case("DW_OP_LLVM_arg", DW_OP_LLVM_arg)
172169
.Default(0);
173170
}
174171

llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,7 @@ static void emitKill(const MachineInstr *MI, AsmPrinter &AP) {
905905
/// means the target will need to handle MI in EmitInstruction.
906906
static bool emitDebugValueComment(const MachineInstr *MI, AsmPrinter &AP) {
907907
// This code handles only the 4-operand target-independent form.
908-
if (MI->isNonListDebugValue() && MI->getNumOperands() != 4)
908+
if (MI->getNumOperands() != 4)
909909
return false;
910910

911911
SmallString<128> Str;
@@ -1228,7 +1228,6 @@ void AsmPrinter::emitFunctionBody() {
12281228
emitInlineAsm(&MI);
12291229
break;
12301230
case TargetOpcode::DBG_VALUE:
1231-
case TargetOpcode::DBG_VALUE_LIST:
12321231
if (isVerbose()) {
12331232
if (!emitDebugValueComment(&MI, *this))
12341233
emitInstruction(&MI);

llvm/lib/CodeGen/InlineSpiller.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,7 @@ void InlineSpiller::spillAroundUses(Register Reg) {
10481048
// Modify DBG_VALUE now that the value is in a spill slot.
10491049
MachineBasicBlock *MBB = MI->getParent();
10501050
LLVM_DEBUG(dbgs() << "Modifying debug info due to spill:\t" << *MI);
1051-
buildDbgValueForSpill(*MBB, MI, *MI, StackSlot, Reg);
1051+
buildDbgValueForSpill(*MBB, MI, *MI, StackSlot);
10521052
MBB->erase(MI);
10531053
continue;
10541054
}

llvm/lib/CodeGen/LiveRangeShrink.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ bool LiveRangeShrink::runOnMachineFunction(MachineFunction &MF) {
235235
MachineBasicBlock::iterator EndIter = std::next(MI.getIterator());
236236
if (MI.getOperand(0).isReg())
237237
for (; EndIter != MBB.end() && EndIter->isDebugValue() &&
238-
EndIter->hasDebugOperandForReg(MI.getOperand(0).getReg());
238+
EndIter->getDebugOperandForReg(MI.getOperand(0).getReg());
239239
++EndIter, ++Next)
240240
IOM[&*EndIter] = NewOrder;
241241
MBB.splice(I, &MBB, MI.getIterator(), EndIter);

llvm/lib/CodeGen/MIRParser/MIParser.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -987,9 +987,7 @@ bool MIParser::parse(MachineInstr *&MI) {
987987
Optional<unsigned> TiedDefIdx;
988988
if (parseMachineOperandAndTargetFlags(OpCode, Operands.size(), MO, TiedDefIdx))
989989
return true;
990-
if ((OpCode == TargetOpcode::DBG_VALUE ||
991-
OpCode == TargetOpcode::DBG_VALUE_LIST) &&
992-
MO.isReg())
990+
if (OpCode == TargetOpcode::DBG_VALUE && MO.isReg())
993991
MO.setIsDebug();
994992
Operands.push_back(
995993
ParsedMachineOperand(MO, Loc, Token.location(), TiedDefIdx));

0 commit comments

Comments
 (0)