[PATCH] D35338: Add the -fdestroy-globals flag

Ian Tessier via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 18 18:41:06 PDT 2017

itessier added a comment.

In https://reviews.llvm.org/D35338#809146, @vsk wrote:

> This is interesting. Do you have any results/metrics to share (e.g some any binary size reduction for projects you've looked at)?

I only tested this with Project Loon's avionics firmware which freed up ~1.2% of ROM space. A small amount, but for us every bit counts.

I did look at creating a templated wrapper class instead which uses placement-new to construct the wrapped type in a private char buffer. This results in the same effect as this patch (no dtor references are emitted). The only issue is the code is a big uglier to read, and we might forgot to use the wrapper (though a static checker could be added for this case). I figured it'd be best to add compiler support so other C++ based firmware projects can benefit as well.


More information about the cfe-commits mailing list