[cfe-dev] Should dump methods be LLVM_ATTRIBUTE_USED only in debug builds?

dblaikie at gmail.com dblaikie at gmail.com
Sat Dec 28 11:12:03 PST 2013

I'd say an llvm macro of LLVM_ATTTRIBUTE_DEBUG_USED - if that's still too
long probably abbreviate attribute to attr.

On Friday, December 27, 2013 4:48:59 PM, Nico Weber <thakis at chromium.org>

> Hi,
> 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).
> 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.
> 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.
> Does it make sense to only mark dump methods as LLVM_ATTRIBUTE_USED if
> !NDEBUG? (If so, I'm thankful for naming suggestions for this new macro
> – LLVM_ATTRIBUTE_USED_IN_DEBUG comes to mind, but is too long. Also, should
> this be an LLVM macro or a clang macro?)
> Thanks,
> Nico
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20131228/5e837546/attachment.html>

More information about the cfe-dev mailing list