@@ -420,11 +420,11 @@ class MachineInstr
420
420
// / instruction is indirect; will be an invalid register if this value is
421
421
// / not indirect, and an immediate with value 0 otherwise.
422
422
const MachineOperand &getDebugOffset () const {
423
- assert (isNonListDebugValue () && " not a DBG_VALUE" );
423
+ assert (isDebugValue () && " not a DBG_VALUE" );
424
424
return getOperand (1 );
425
425
}
426
426
MachineOperand &getDebugOffset () {
427
- assert (isNonListDebugValue () && " not a DBG_VALUE" );
427
+ assert (isDebugValue () && " not a DBG_VALUE" );
428
428
return getOperand (1 );
429
429
}
430
430
@@ -439,7 +439,6 @@ class MachineInstr
439
439
440
440
// / Return the operand for the complex address expression referenced by
441
441
// / this DBG_VALUE instruction.
442
- const MachineOperand &getDebugExpressionOp () const ;
443
442
MachineOperand &getDebugExpressionOp ();
444
443
445
444
// / Return the complex address expression referenced by
@@ -502,43 +501,26 @@ class MachineInstr
502
501
return *(debug_operands ().begin () + Index);
503
502
}
504
503
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;
511
512
}
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;
538
519
}
539
520
540
521
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." );
542
524
return std::distance (adl_begin (debug_operands ()), Op);
543
525
}
544
526
@@ -618,16 +600,12 @@ class MachineInstr
618
600
// / location for this DBG_VALUE instruction.
619
601
iterator_range<mop_iterator> debug_operands () {
620
602
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 );
624
604
}
625
605
// / \copydoc debug_operands()
626
606
iterator_range<const_mop_iterator> debug_operands () const {
627
607
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 );
631
609
}
632
610
// / Returns a range over all explicit operands that are register definitions.
633
611
// / Implicit definition are not included!
@@ -1186,15 +1164,7 @@ class MachineInstr
1186
1164
// True if the instruction represents a position in the function.
1187
1165
bool isPosition () const { return isLabel () || isCFIInstruction (); }
1188
1166
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; }
1198
1168
bool isDebugLabel () const { return getOpcode () == TargetOpcode::DBG_LABEL; }
1199
1169
bool isDebugRef () const { return getOpcode () == TargetOpcode::DBG_INSTR_REF; }
1200
1170
bool isDebugInstr () const {
@@ -1204,14 +1174,12 @@ class MachineInstr
1204
1174
return isDebugInstr () || isPseudoProbe ();
1205
1175
}
1206
1176
1207
- bool isDebugOffsetImm () const {
1208
- return isNonListDebugValue () && getDebugOffset ().isImm ();
1209
- }
1177
+ bool isDebugOffsetImm () const { return getDebugOffset ().isImm (); }
1210
1178
1211
1179
// / A DBG_VALUE is indirect iff the location operand is a register and
1212
1180
// / the offset operand is an immediate.
1213
1181
bool isIndirectDebugValue () const {
1214
- return isDebugOffsetImm () && getDebugOperand (0 ).isReg ();
1182
+ return isDebugValue () && getDebugOperand (0 ).isReg () && isDebugOffsetImm ();
1215
1183
}
1216
1184
1217
1185
// / A DBG_VALUE is an entry value iff its debug expression contains the
@@ -1221,13 +1189,8 @@ class MachineInstr
1221
1189
// / Return true if the instruction is a debug value which describes a part of
1222
1190
// / a variable as unavailable.
1223
1191
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 ();
1231
1194
}
1232
1195
1233
1196
bool isPHI () const {
@@ -1302,7 +1265,6 @@ class MachineInstr
1302
1265
case TargetOpcode::EH_LABEL:
1303
1266
case TargetOpcode::GC_LABEL:
1304
1267
case TargetOpcode::DBG_VALUE:
1305
- case TargetOpcode::DBG_VALUE_LIST:
1306
1268
case TargetOpcode::DBG_INSTR_REF:
1307
1269
case TargetOpcode::DBG_LABEL:
1308
1270
case TargetOpcode::LIFETIME_START:
0 commit comments