This is an archive of the discontinued LLVM Phabricator instance.

Add an internalization step to the ThinLTOCodeGenerator
ClosedPublic

Authored by mehdi_amini on Apr 14 2016, 2:32 AM.

Details

Summary

keeping as much as possible internal/private is
known to help the optimizer. Let's try to benefit from
this in ThinLTO.
Note: this is early work, but is enough to build clang (and
all the LLVM tools). I still need to write some lit-tests...

Diff Detail

Event Timeline

mehdi_amini retitled this revision from to Add an internalization step to the ThinLTOCodeGenerator.
mehdi_amini updated this object.
mehdi_amini added a reviewer: tejohnson.
mehdi_amini added a subscriber: llvm-commits.
tejohnson added inline comments.Apr 21 2016, 6:23 AM
lib/LTO/ThinLTOCodeGenerator.cpp
318

It seems there is already some support in libLTO for detecting these, see the call to LTOModule::addAsmGlobalSymbolUndef(). Can that be leveraged here? What is the difference between what is being detected by these two cases?

If it needs to use the IRObject method, can that functionality be refactored into a method in libObject that is callable from here? It seems like it could return the AsmSymbols vector and you could just iterate that here looking for a Key that is BasicSymbolRef::SF_Undefined in the returned pair, and is !TheModule.getNamedValue(Key). Using a refactored common routine would make it easier to do similar optimizations in the gold and lld cases as well.

387

Missing comment

395

I guess the assumption is that there is nothing to export if there is nothing to preserve? Should there be an assertion here that ExportList is empty?

415

doxygen style /// comment (here and with other added functions)

429

Why not add these to the PreservedGV set?

616

Should this be a FIXME?

mehdi_amini marked 5 inline comments as done.

Address comments

lib/LTO/ThinLTOCodeGenerator.cpp
395

No this is completely independent: if the client didn't supply anything to preserve, we don't internalize at all. Changed the comment.

415

I think it is relevant only for public API. These are static function so they won't show up in doxygen: http://llvm.org/doxygen/ThinLTOCodeGenerator_8cpp.html

429

PreservedGV drives the internalizer, this is possibly driving other places in LLVM I think, like GlobalDCE for example.

616

added

mehdi_amini marked an inline comment as done.Apr 21 2016, 10:13 PM
tejohnson accepted this revision.Apr 22 2016, 9:18 AM
tejohnson edited edge metadata.
This revision is now accepted and ready to land.Apr 22 2016, 9:18 AM