DebugLocDwarfExpression::EmitOp was creating temporary strings by concatenating Twine's.
When emitting to object files, these comments are thrown away.
This commit adds a boolean to the constructor of the DwarfExpression to control whether it will actually emit
any comments. This prevents it from even generating the temporary comments which would have been thrown away anyway.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237827
91177308-0d34-0410-b5e6-
96231b3b80d8
void AsmPrinter::EmitDwarfRegOp(ByteStreamer &Streamer,
const MachineLocation &MLoc) const {
DebugLocDwarfExpression Expr(*MF->getSubtarget().getRegisterInfo(),
void AsmPrinter::EmitDwarfRegOp(ByteStreamer &Streamer,
const MachineLocation &MLoc) const {
DebugLocDwarfExpression Expr(*MF->getSubtarget().getRegisterInfo(),
- getDwarfDebug()->getDwarfVersion(), Streamer);
+ getDwarfDebug()->getDwarfVersion(),
+ OutStreamer->hasRawTextSupport(), Streamer);
const MCRegisterInfo *MRI = MMI->getContext().getRegisterInfo();
int Reg = MRI->getDwarfRegNum(MLoc.getReg(), false);
if (Reg < 0) {
const MCRegisterInfo *MRI = MMI->getContext().getRegisterInfo();
int Reg = MRI->getDwarfRegNum(MLoc.getReg(), false);
if (Reg < 0) {
static const char *const DbgTimerName = "DWARF Debug Writer";
void DebugLocDwarfExpression::EmitOp(uint8_t Op, const char *Comment) {
static const char *const DbgTimerName = "DWARF Debug Writer";
void DebugLocDwarfExpression::EmitOp(uint8_t Op, const char *Comment) {
+ if (!PrintComments)
+ return BS.EmitInt8(Op, Twine());
BS.EmitInt8(
Op, Comment ? Twine(Comment) + " " + dwarf::OperationEncodingString(Op)
: dwarf::OperationEncodingString(Op));
BS.EmitInt8(
Op, Comment ? Twine(Comment) + " " + dwarf::OperationEncodingString(Op)
: dwarf::OperationEncodingString(Op));
unsigned PieceOffsetInBits) {
DebugLocDwarfExpression DwarfExpr(*AP.MF->getSubtarget().getRegisterInfo(),
AP.getDwarfDebug()->getDwarfVersion(),
unsigned PieceOffsetInBits) {
DebugLocDwarfExpression DwarfExpr(*AP.MF->getSubtarget().getRegisterInfo(),
AP.getDwarfDebug()->getDwarfVersion(),
+ AP.OutStreamer->hasRawTextSupport(),
Streamer);
// Regular entry.
if (Value.isInt()) {
Streamer);
// Regular entry.
if (Value.isInt()) {
// The DWARF spec seriously mandates pieces with no locations for gaps.
DebugLocDwarfExpression Expr(*AP.MF->getSubtarget().getRegisterInfo(),
AP.getDwarfDebug()->getDwarfVersion(),
// The DWARF spec seriously mandates pieces with no locations for gaps.
DebugLocDwarfExpression Expr(*AP.MF->getSubtarget().getRegisterInfo(),
AP.getDwarfDebug()->getDwarfVersion(),
+ AP.OutStreamer->hasRawTextSupport(),
Streamer);
Expr.AddOpPiece(PieceOffset-Offset, 0);
Offset += PieceOffset-Offset;
Streamer);
Expr.AddOpPiece(PieceOffset-Offset, 0);
Offset += PieceOffset-Offset;
const TargetRegisterInfo &TRI;
unsigned DwarfVersion;
const TargetRegisterInfo &TRI;
unsigned DwarfVersion;
+ /// \brief Set to true if we want comments to be emitted. This is usually
+ /// only the case when the AsmPrinter is emitting to a text stream with
+ /// comments enabled.
+ bool PrintComments;
+
public:
DwarfExpression(const TargetRegisterInfo &TRI,
public:
DwarfExpression(const TargetRegisterInfo &TRI,
- unsigned DwarfVersion)
- : TRI(TRI), DwarfVersion(DwarfVersion) {}
+ unsigned DwarfVersion, bool PrintComments)
+ : TRI(TRI), DwarfVersion(DwarfVersion), PrintComments(PrintComments) {}
virtual ~DwarfExpression() {}
/// Output a dwarf operand and an optional assembler comment.
virtual ~DwarfExpression() {}
/// Output a dwarf operand and an optional assembler comment.
public:
DebugLocDwarfExpression(const TargetRegisterInfo &TRI,
public:
DebugLocDwarfExpression(const TargetRegisterInfo &TRI,
- unsigned DwarfVersion, ByteStreamer &BS)
- : DwarfExpression(TRI, DwarfVersion), BS(BS) {}
+ unsigned DwarfVersion, bool PrintComments,
+ ByteStreamer &BS)
+ : DwarfExpression(TRI, DwarfVersion, PrintComments), BS(BS) {}
void EmitOp(uint8_t Op, const char *Comment = nullptr) override;
void EmitSigned(int64_t Value) override;
void EmitOp(uint8_t Op, const char *Comment = nullptr) override;
void EmitSigned(int64_t Value) override;
DIEDwarfExpression::DIEDwarfExpression(const AsmPrinter &AP, DwarfUnit &DU,
DIELoc &DIE)
: DwarfExpression(*AP.MF->getSubtarget().getRegisterInfo(),
DIEDwarfExpression::DIEDwarfExpression(const AsmPrinter &AP, DwarfUnit &DU,
DIELoc &DIE)
: DwarfExpression(*AP.MF->getSubtarget().getRegisterInfo(),
- AP.getDwarfDebug()->getDwarfVersion()),
+ AP.getDwarfDebug()->getDwarfVersion(), false),
AP(AP), DU(DU), DIE(DIE) {}
void DIEDwarfExpression::EmitOp(uint8_t Op, const char* Comment) {
AP(AP), DU(DU), DIE(DIE) {}
void DIEDwarfExpression::EmitOp(uint8_t Op, const char* Comment) {