<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Dec 27, 2013 at 8:01 PM, Chandler Carruth <span dir="ltr"><<a href="mailto:chandlerc@google.com" target="_blank">chandlerc@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="im">On Fri, Dec 27, 2013 at 7:46 PM, Nico Weber <span dir="ltr"><<a href="mailto:thakis@chromium.org" target="_blank">thakis@chromium.org</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>r151033 and r151037 marked a few dump() methods as LLVM_ATTRIBUTE_USED, and over time this inspired marking several other dump() methods to be marked as such too (see e.g. 178400, 182186, 159790, 173548).</div>


<div><br></div><div>I understand that having the dump() methods available in the debugger is useful, but these annotations prevent the dump() methods from being dead-stripped, and they end up keeping lots of code alive. For example, clang-format depends on ASTDumper, TypePrinter, StmtVisitor and related stuff solely for these dump methods.</div>


<div><br></div><div>Since binaries now get dead-stripped, this leads to measurable bloat: clang-format goes from 1.7 MB to 1.2 MB if I remove the LLVM_ATTRIBUTE_USEDs on the 17 dump methods in include/clang – an almost 30% reduction.</div>


<div><br></div><div>Does it make sense to only mark dump methods as LLVM_ATTRIBUTE_USED if !NDEBUG?</div></div></blockquote><div><br></div></div><div>I think what makes sense is to not have these methods in !NDEBUG. This is the way dump methods are being written in LLVM these days:</div>

<div><br></div><div>#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)<br></div><div>  void some_helper_function_only_used_by_dump() const;</div><div>  void LLVM_ATTRIBUTE_NOINLINE LLVM_ATTRIBUTE_USED dump() const;</div><div>

#endif</div><div><br></div><div>At least, this is how SROA.cpp does it, and I think it has been suggested to do it consistently in this way.</div><div><br></div><div>My preference would be to:</div><div><br></div><div>a) Make this pattern easier to reproduce where needed.</div>
</blockquote><div> </div></div>Oh, and a concrete suggestion of what I think would be easier:</div><div class="gmail_extra"><br></div><div class="gmail_extra"><div>#if LLVM_ENABLE_DUMP<br></div><div>  void some_helper_function_only_used_by_dump() const;</div>
<div>  void LLVM_DUMP_METHOD dump() const;</div><div>#endif</div><div><br></div><div>I've no better name for "LLVM_DUMP_METHOD" though, it's a terrible name. Anything you come up with will likely be better. =]</div>
</div></div>