Skip to content

Commit d4c50f7

Browse files
committed
Remove need for assert by sinking SubOp handling
1 parent 782cde1 commit d4c50f7

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

llvm/lib/DebugInfo/DWARF/DWARFExpressionPrinter.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,10 @@ static bool printOp(const DWARFExpression::Operation *Op, raw_ostream &OS,
5656
assert(!Name.empty() && "DW_OP has no name!");
5757
OS << Name;
5858

59-
std::optional<unsigned> SubOpcode = Op->getSubCode();
60-
if (SubOpcode) {
61-
StringRef SubName = SubOperationEncodingString(Op->getCode(), *SubOpcode);
62-
assert(!SubName.empty() && "DW_OP SubOp has no name!");
63-
OS << ' ' << SubName;
64-
}
65-
6659
if ((Op->getCode() >= DW_OP_breg0 && Op->getCode() <= DW_OP_breg31) ||
6760
(Op->getCode() >= DW_OP_reg0 && Op->getCode() <= DW_OP_reg31) ||
6861
Op->getCode() == DW_OP_bregx || Op->getCode() == DW_OP_regx ||
69-
Op->getCode() == DW_OP_regval_type ||
70-
(SubOpcode && (*SubOpcode == DW_OP_LLVM_call_frame_entry_reg ||
71-
*SubOpcode == DW_OP_LLVM_aspace_bregx)))
62+
Op->getCode() == DW_OP_regval_type)
7263
if (prettyPrintRegisterOp(U, OS, DumpOpts, Op->getCode(),
7364
Op->getRawOperands()))
7465
return true;
@@ -79,8 +70,16 @@ static bool printOp(const DWARFExpression::Operation *Op, raw_ostream &OS,
7970
unsigned Signed = Size & DWARFExpression::Operation::SignBit;
8071

8172
if (Size == DWARFExpression::Operation::SizeSubOpLEB) {
82-
assert(Operand == 0);
83-
assert(SubOpcode);
73+
assert(Operand == 0 && "DW_OP SubOp must be the first operand");
74+
unsigned SubOpcode = Op->getRawOperand(Operand);
75+
StringRef SubName = SubOperationEncodingString(Op->getCode(), SubOpcode);
76+
assert(!SubName.empty() && "DW_OP SubOp has no name!");
77+
OS << ' ' << SubName;
78+
if (SubOpcode == DW_OP_LLVM_call_frame_entry_reg ||
79+
SubOpcode == DW_OP_LLVM_aspace_bregx)
80+
if (prettyPrintRegisterOp(U, OS, DumpOpts, Op->getCode(),
81+
Op->getRawOperands()))
82+
return true;
8483
} else if (Size == DWARFExpression::Operation::BaseTypeRef && U) {
8584
// For DW_OP_convert the operand may be 0 to indicate that conversion to
8685
// the generic type should be done. The same holds for DW_OP_reinterpret,

0 commit comments

Comments
 (0)