summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter
diff options
context:
space:
mode:
authorPete Cooper <peter_cooper@apple.com>2015-05-20 19:50:03 +0000
committerPete Cooper <peter_cooper@apple.com>2015-05-20 19:50:03 +0000
commit35522001faa829308aa9aec5601c1a1ab5fb290c (patch)
tree8a67a99e404a9090c37e90a3c3a0927cc80c925c /llvm/lib/CodeGen/AsmPrinter
parente8fb3a220a91db6fd5e9214375540f7ea0bb3a67 (diff)
downloadbcm5719-llvm-35522001faa829308aa9aec5601c1a1ab5fb290c.tar.gz
bcm5719-llvm-35522001faa829308aa9aec5601c1a1ab5fb290c.zip
Add bool to DebugLocDwarfExpression to control emitting comments.
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. llvm-svn: 237827
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp3
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp4
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h14
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp2
4 files changed, 17 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
index 6f48767c1df..61e74260454 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
@@ -185,7 +185,8 @@ void AsmPrinter::emitSectionOffset(const MCSymbol *Label) const {
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) {
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 8c792ed53a6..7b051d4c577 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -108,6 +108,8 @@ static const char *const DWARFGroupName = "DWARF Emission";
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));
@@ -1477,6 +1479,7 @@ static void emitDebugLocValue(const AsmPrinter &AP, const DIBasicType *BT,
unsigned PieceOffsetInBits) {
DebugLocDwarfExpression DwarfExpr(*AP.MF->getSubtarget().getRegisterInfo(),
AP.getDwarfDebug()->getDwarfVersion(),
+ AP.OutStreamer->hasRawTextSupport(),
Streamer);
// Regular entry.
if (Value.isInt()) {
@@ -1530,6 +1533,7 @@ void DebugLocEntry::finalize(const AsmPrinter &AP, DebugLocStream &Locs,
// 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;
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h
index 78ec937a6b6..15e29164d2f 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h
@@ -34,10 +34,15 @@ protected:
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,
- 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.
@@ -109,8 +114,9 @@ class DebugLocDwarfExpression : public DwarfExpression {
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;
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
index ee233f710f2..9d523dd3541 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -47,7 +47,7 @@ GenerateDwarfTypeUnits("generate-type-units", cl::Hidden,
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) {
OpenPOWER on IntegriCloud