[rfc][patch] Refactoring how we handle symbols for the end of sections

Rafael EspĂ­ndola rafael.espindola at gmail.com
Mon Mar 16 17:02:51 PDT 2015


> Sounds like a nice cleanup to me, although I don't know this code
> well enough to confirm.
>
> (Off-topic, but related: a few of us were looking at some heap profiles
> of clang -flto -g a week or so ago, and temp symbols, etc., are
> responsible for most of the memory allocated in the backend.  At least
> on Darwin, most of the symbols seem to be unnecessary and/or unused.
>
> For example, I've attached a POC patch by Fred (ref_addr.patch).
> Previously, this code:
>
>   - created two symbol refs,
>   - created Plus and Diff exprs,
>   - created a temp symbol for the label of the offset, and
>   - at least on Darwin, wrote out the computed offset, leaking all five
>     (unnecessary) objects on the `BumpPtrAllocator` in `MCContext`.
>
> The patch just writes out the offset directly.  This is correct on
> Darwin (is `doesDwarfUseRelocationsAcrossSections()` the right check for
> that?), and maybe other platforms could benefit from something similar.
> Looked like a pretty significant reduction in memory usage on smaller
> LTO builds; need to repro more carefully to give stats on memory
> savings.
>
> Anyone looking at memory problems with -flto -g should probably be
> looking here and at similar places... I'll circle back myself as soon as
> I can.)

That is interesting. I have been amused for some time that we give
names to temporary symbols when producing a .o. We also tend to create
more labels than we need.

Ideally we would not assign names when creating temporary labels.
Their are temporary and in MC can be identified by just the MCSymbol.
When printing assembly the MCAsmStreamer is the one that should be
responsible for inventing names for them.

Cheers,
Rafael



More information about the llvm-commits mailing list