Skip to content

Commit 4dc5309

Browse files
Address comments
1 parent 7b5d5e2 commit 4dc5309

File tree

3 files changed

+39
-40
lines changed

3 files changed

+39
-40
lines changed

llvm/include/llvm/DebugInfo/DWARF/DWARFCFIPrinter.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ namespace dwarf {
2424
class CFIPrinter {
2525
public:
2626
static void print(const CFIProgram &P, raw_ostream &OS,
27-
DIDumpOptions DumpOpts, unsigned IndentLevel,
27+
DIDumpOptions &DumpOpts, unsigned IndentLevel,
2828
std::optional<uint64_t> Address);
2929

30-
static void printOperand(raw_ostream &OS, DIDumpOptions DumpOpts,
30+
static void printOperand(raw_ostream &OS, DIDumpOptions &DumpOpts,
3131
const CFIProgram &P,
3232
const CFIProgram::Instruction &Instr,
3333
unsigned OperandIdx, uint64_t Operand,

llvm/include/llvm/DebugInfo/DWARF/DWARFCFIProgram.h

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ class CFIProgram {
3737
public:
3838
static constexpr size_t MaxOperands = 3;
3939
typedef SmallVector<uint64_t, MaxOperands> Operands;
40-
friend CFIPrinter;
4140

4241
/// An instruction consists of a DWARF CFI opcode and an optional sequence of
4342
/// operands. If it refers to an expression, then this expression has its own
@@ -89,6 +88,32 @@ class CFIProgram {
8988
/// Get a DWARF CFI call frame string for the given DW_CFA opcode.
9089
LLVM_ABI StringRef callFrameString(unsigned Opcode) const;
9190

91+
/// Types of operands to CFI instructions
92+
/// In DWARF, this type is implicitly tied to a CFI instruction opcode and
93+
/// thus this type doesn't need to be explicitly written to the file (this is
94+
/// not a DWARF encoding). The relationship of instrs to operand types can
95+
/// be obtained from getOperandTypes() and is only used to simplify
96+
/// instruction printing and error messages.
97+
enum OperandType {
98+
OT_Unset,
99+
OT_None,
100+
OT_Address,
101+
OT_Offset,
102+
OT_FactoredCodeOffset,
103+
OT_SignedFactDataOffset,
104+
OT_UnsignedFactDataOffset,
105+
OT_Register,
106+
OT_AddressSpace,
107+
OT_Expression
108+
};
109+
110+
/// Get the OperandType as a "const char *".
111+
static const char *operandTypeString(OperandType OT);
112+
113+
/// Retrieve the array describing the types of operands according to the enum
114+
/// above. This is indexed by opcode.
115+
static ArrayRef<OperandType[MaxOperands]> getOperandTypes();
116+
92117
private:
93118
std::vector<Instruction> Instructions;
94119
const uint64_t CodeAlignmentFactor;
@@ -121,32 +146,6 @@ class CFIProgram {
121146
Instructions.back().Ops.push_back(Operand2);
122147
Instructions.back().Ops.push_back(Operand3);
123148
}
124-
125-
/// Types of operands to CFI instructions
126-
/// In DWARF, this type is implicitly tied to a CFI instruction opcode and
127-
/// thus this type doesn't need to be explicitly written to the file (this is
128-
/// not a DWARF encoding). The relationship of instrs to operand types can
129-
/// be obtained from getOperandTypes() and is only used to simplify
130-
/// instruction printing.
131-
enum OperandType {
132-
OT_Unset,
133-
OT_None,
134-
OT_Address,
135-
OT_Offset,
136-
OT_FactoredCodeOffset,
137-
OT_SignedFactDataOffset,
138-
OT_UnsignedFactDataOffset,
139-
OT_Register,
140-
OT_AddressSpace,
141-
OT_Expression
142-
};
143-
144-
/// Get the OperandType as a "const char *".
145-
static const char *operandTypeString(OperandType OT);
146-
147-
/// Retrieve the array describing the types of operands according to the enum
148-
/// above. This is indexed by opcode.
149-
static ArrayRef<OperandType[MaxOperands]> getOperandTypes();
150149
};
151150

152151
} // end namespace dwarf

llvm/lib/DebugInfo/DWARF/DWARFCFIPrinter.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ using namespace llvm;
2525
using namespace dwarf;
2626

2727
void CFIPrinter::print(const CFIProgram &P, raw_ostream &OS,
28-
DIDumpOptions DumpOpts, unsigned IndentLevel,
28+
DIDumpOptions &DumpOpts, unsigned IndentLevel,
2929
std::optional<uint64_t> Address) {
3030
for (const auto &Instr : P) {
3131
uint8_t Opcode = Instr.Opcode;
@@ -37,7 +37,7 @@ void CFIPrinter::print(const CFIProgram &P, raw_ostream &OS,
3737
}
3838
}
3939

40-
static void printRegister(raw_ostream &OS, DIDumpOptions DumpOpts,
40+
static void printRegister(raw_ostream &OS, DIDumpOptions &DumpOpts,
4141
unsigned RegNum) {
4242
if (DumpOpts.GetNameForDWARFReg) {
4343
auto RegName = DumpOpts.GetNameForDWARFReg(RegNum, DumpOpts.IsEH);
@@ -50,7 +50,7 @@ static void printRegister(raw_ostream &OS, DIDumpOptions DumpOpts,
5050
}
5151

5252
/// Print \p Opcode's operand number \p OperandIdx which has value \p Operand.
53-
void CFIPrinter::printOperand(raw_ostream &OS, DIDumpOptions DumpOpts,
53+
void CFIPrinter::printOperand(raw_ostream &OS, DIDumpOptions &DumpOpts,
5454
const CFIProgram &P,
5555
const CFIProgram::Instruction &Instr,
5656
unsigned OperandIdx, uint64_t Operand,
@@ -82,24 +82,24 @@ void CFIPrinter::printOperand(raw_ostream &OS, DIDumpOptions DumpOpts,
8282
OS << format(" %+" PRId64, int64_t(Operand));
8383
break;
8484
case CFIProgram::OT_FactoredCodeOffset: // Always Unsigned
85-
if (P.CodeAlignmentFactor)
86-
OS << format(" %" PRId64, Operand * P.CodeAlignmentFactor);
85+
if (P.codeAlign())
86+
OS << format(" %" PRId64, Operand * P.codeAlign());
8787
else
8888
OS << format(" %" PRId64 "*code_alignment_factor", Operand);
89-
if (Address && P.CodeAlignmentFactor) {
90-
*Address += Operand * P.CodeAlignmentFactor;
89+
if (Address && P.codeAlign()) {
90+
*Address += Operand * P.codeAlign();
9191
OS << format(" to 0x%" PRIx64, *Address);
9292
}
9393
break;
9494
case CFIProgram::OT_SignedFactDataOffset:
95-
if (P.DataAlignmentFactor)
96-
OS << format(" %" PRId64, int64_t(Operand) * P.DataAlignmentFactor);
95+
if (P.dataAlign())
96+
OS << format(" %" PRId64, int64_t(Operand) * P.dataAlign());
9797
else
9898
OS << format(" %" PRId64 "*data_alignment_factor", int64_t(Operand));
9999
break;
100100
case CFIProgram::OT_UnsignedFactDataOffset:
101-
if (P.DataAlignmentFactor)
102-
OS << format(" %" PRId64, Operand * P.DataAlignmentFactor);
101+
if (P.dataAlign())
102+
OS << format(" %" PRId64, Operand * P.dataAlign());
103103
else
104104
OS << format(" %" PRId64 "*data_alignment_factor", Operand);
105105
break;

0 commit comments

Comments
 (0)