<div dir="ltr">Looks like the only thing you do is turn them off? Can you explain why you're adding something just to turn them off?<br><br>-eric<br></div><br><div class="gmail_quote">On Wed, May 20, 2015 at 12:58 PM Pete Cooper <<a href="mailto:peter_cooper@apple.com">peter_cooper@apple.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: pete<br>
Date: Wed May 20 14:50:03 2015<br>
New Revision: 237827<br>
<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D237827-26view-3Drev&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=OgUQFKlCFX_DI0E8wfagm5uCWdZ0kq2pj5JAbw67Ly0&s=MK2SQa0tNX-l9h6tE229LMd5xUtXGcZWT0DOg3QKptc&e=" target="_blank">http://llvm.org/viewvc/llvm-project?rev=237827&view=rev</a><br>
Log:<br>
Add bool to DebugLocDwarfExpression to control emitting comments.<br>
<br>
DebugLocDwarfExpression::EmitOp was creating temporary strings by concatenating Twine's.<br>
<br>
When emitting to object files, these comments are thrown away.<br>
<br>
This commit adds a boolean to the constructor of the DwarfExpression to control whether it will actually emit<br>
any comments.  This prevents it from even generating the temporary comments which would have been thrown away anyway.<br>
<br>
Modified:<br>
    llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp<br>
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp<br>
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfExpression.h<br>
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp<br>
<br>
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_lib_CodeGen_AsmPrinter_AsmPrinterDwarf.cpp-3Frev-3D237827-26r1-3D237826-26r2-3D237827-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=OgUQFKlCFX_DI0E8wfagm5uCWdZ0kq2pj5JAbw67Ly0&s=xJD0esZa3rqRnE3D3nJbDZcW55y0rfniCrBl5mu-7W8&e=" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp?rev=237827&r1=237826&r2=237827&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp Wed May 20 14:50:03 2015<br>
@@ -185,7 +185,8 @@ void AsmPrinter::emitSectionOffset(const<br>
 void AsmPrinter::EmitDwarfRegOp(ByteStreamer &Streamer,<br>
                                 const MachineLocation &MLoc) const {<br>
   DebugLocDwarfExpression Expr(*MF->getSubtarget().getRegisterInfo(),<br>
-                               getDwarfDebug()->getDwarfVersion(), Streamer);<br>
+                               getDwarfDebug()->getDwarfVersion(),<br>
+                               OutStreamer->hasRawTextSupport(), Streamer);<br>
   const MCRegisterInfo *MRI = MMI->getContext().getRegisterInfo();<br>
   int Reg = MRI->getDwarfRegNum(MLoc.getReg(), false);<br>
   if (Reg < 0) {<br>
<br>
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_lib_CodeGen_AsmPrinter_DwarfDebug.cpp-3Frev-3D237827-26r1-3D237826-26r2-3D237827-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=OgUQFKlCFX_DI0E8wfagm5uCWdZ0kq2pj5JAbw67Ly0&s=z98s6kZJAogBpm3Bn8__KC0m5ZgNhDZugxHIIDCRECQ&e=" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=237827&r1=237826&r2=237827&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed May 20 14:50:03 2015<br>
@@ -108,6 +108,8 @@ static const char *const DWARFGroupName<br>
 static const char *const DbgTimerName = "DWARF Debug Writer";<br>
<br>
 void DebugLocDwarfExpression::EmitOp(uint8_t Op, const char *Comment) {<br>
+  if (!PrintComments)<br>
+    return BS.EmitInt8(Op, Twine());<br>
   BS.EmitInt8(<br>
       Op, Comment ? Twine(Comment) + " " + dwarf::OperationEncodingString(Op)<br>
                   : dwarf::OperationEncodingString(Op));<br>
@@ -1477,6 +1479,7 @@ static void emitDebugLocValue(const AsmP<br>
                               unsigned PieceOffsetInBits) {<br>
   DebugLocDwarfExpression DwarfExpr(*AP.MF->getSubtarget().getRegisterInfo(),<br>
                                     AP.getDwarfDebug()->getDwarfVersion(),<br>
+                                    AP.OutStreamer->hasRawTextSupport(),<br>
                                     Streamer);<br>
   // Regular entry.<br>
   if (Value.isInt()) {<br>
@@ -1530,6 +1533,7 @@ void DebugLocEntry::finalize(const AsmPr<br>
         // The DWARF spec seriously mandates pieces with no locations for gaps.<br>
         DebugLocDwarfExpression Expr(*AP.MF->getSubtarget().getRegisterInfo(),<br>
                                      AP.getDwarfDebug()->getDwarfVersion(),<br>
+                                     AP.OutStreamer->hasRawTextSupport(),<br>
                                      Streamer);<br>
         Expr.AddOpPiece(PieceOffset-Offset, 0);<br>
         Offset += PieceOffset-Offset;<br>
<br>
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfExpression.h<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_lib_CodeGen_AsmPrinter_DwarfExpression.h-3Frev-3D237827-26r1-3D237826-26r2-3D237827-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=OgUQFKlCFX_DI0E8wfagm5uCWdZ0kq2pj5JAbw67Ly0&s=escOjUu515O9dfoVU7s4IWf777nr4dirR-xrUzQorok&e=" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfExpression.h?rev=237827&r1=237826&r2=237827&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfExpression.h (original)<br>
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfExpression.h Wed May 20 14:50:03 2015<br>
@@ -34,10 +34,15 @@ protected:<br>
   const TargetRegisterInfo &TRI;<br>
   unsigned DwarfVersion;<br>
<br>
+  /// \brief Set to true if we want comments to be emitted.  This is usually<br>
+  /// only the case when the AsmPrinter is emitting to a text stream with<br>
+  /// comments enabled.<br>
+  bool PrintComments;<br>
+<br>
 public:<br>
   DwarfExpression(const TargetRegisterInfo &TRI,<br>
-                  unsigned DwarfVersion)<br>
-    : TRI(TRI), DwarfVersion(DwarfVersion) {}<br>
+                  unsigned DwarfVersion, bool PrintComments)<br>
+    : TRI(TRI), DwarfVersion(DwarfVersion), PrintComments(PrintComments) {}<br>
   virtual ~DwarfExpression() {}<br>
<br>
   /// Output a dwarf operand and an optional assembler comment.<br>
@@ -109,8 +114,9 @@ class DebugLocDwarfExpression : public D<br>
<br>
 public:<br>
   DebugLocDwarfExpression(const TargetRegisterInfo &TRI,<br>
-                          unsigned DwarfVersion, ByteStreamer &BS)<br>
-    : DwarfExpression(TRI, DwarfVersion), BS(BS) {}<br>
+                          unsigned DwarfVersion, bool PrintComments,<br>
+                          ByteStreamer &BS)<br>
+    : DwarfExpression(TRI, DwarfVersion, PrintComments), BS(BS) {}<br>
<br>
   void EmitOp(uint8_t Op, const char *Comment = nullptr) override;<br>
   void EmitSigned(int64_t Value) override;<br>
<br>
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_lib_CodeGen_AsmPrinter_DwarfUnit.cpp-3Frev-3D237827-26r1-3D237826-26r2-3D237827-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=OgUQFKlCFX_DI0E8wfagm5uCWdZ0kq2pj5JAbw67Ly0&s=aaNlFQmPl2piBhK9pVKp1sksIDxJP_VTVrp-2F7Apog&e=" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp?rev=237827&r1=237826&r2=237827&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp Wed May 20 14:50:03 2015<br>
@@ -47,7 +47,7 @@ GenerateDwarfTypeUnits("generate-type-un<br>
 DIEDwarfExpression::DIEDwarfExpression(const AsmPrinter &AP, DwarfUnit &DU,<br>
                                        DIELoc &DIE)<br>
     : DwarfExpression(*AP.MF->getSubtarget().getRegisterInfo(),<br>
-                      AP.getDwarfDebug()->getDwarfVersion()),<br>
+                      AP.getDwarfDebug()->getDwarfVersion(), false),<br>
       AP(AP), DU(DU), DIE(DIE) {}<br>
<br>
 void DIEDwarfExpression::EmitOp(uint8_t Op, const char* Comment) {<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>