This is an archive of the discontinued LLVM Phabricator instance.

[ThinLTO] Move ThinLTOCodeGenerator implementation to target the new LTO API.
Needs ReviewPublic

Authored by mehdi_amini on Aug 22 2016, 9:38 AM.

Details

Reviewers
tejohnson
Summary

Since the new LTO API does not expose the individual steps in a
convenient manner, it implies changing a bit how llvm-lto works
and there was some churns with the tests.

Diff Detail

Event Timeline

mehdi_amini retitled this revision from to [ThinLTO] Move ThinLTOCodeGenerator implementation to target the new LTO API..
mehdi_amini updated this object.
mehdi_amini added a reviewer: tejohnson.
mehdi_amini added a subscriber: llvm-commits.
mehdi_amini updated this revision to Diff 70354.Sep 5 2016, 8:32 PM

Update after running the test-suite

tejohnson edited edge metadata.Sep 16 2016, 10:37 AM

Sorry for the delay.

I didn't go through the test changes in any detail - what is the main reason the new API caused changes to the way llvm-lto worked and the resulting test behavior?

include/llvm/LTO/legacy/ThinLTOCodeGenerator.h
208

Document callback here and in the other changed interfaces, and remove description of Index being updated since it is no longer passed.

lib/LTO/ThinLTOCodeGenerator.cpp
214

Comment needs update here and for other changed interfaces.

357

This variable never used.

363

I'm a little confused about what this interface is used for - why are we asserting if there is any stream requested?

418

s/only gets global symbol/only get global symbols/

425

early continue instead?

434

Maybe combine with earlier duplicated flag checks into a variable like IsWeak

444

I believe this loop nest can be merged with the above (since the first copy always selected as prevailing)

I didn't go through the test changes in any detail - what is the main reason the new API caused changes to the way llvm-lto worked and the resulting test behavior?

Mainly: the new LTO API does not allow to test the individual phases of the ThinLTO process without using "-save-temps". So you can't also run a later phase without running the earlier ones, which some tests were doing.

mehdi_amini added inline comments.Sep 16 2016, 11:00 AM
lib/LTO/ThinLTOCodeGenerator.cpp
363

I'll make it more clear. The ThinLTO code generator is not supposed to have any non-ThinLTO file at this point.
In the libLTO C API, the LTO and ThinLTO path are not unified at this time.

pcc added a subscriber: pcc.Sep 16 2016, 11:05 AM

I suppose a higher level question is whether you want to reimplement the entire ThinLTOCodeGenerator or just the libLTO interface?

lib/LTO/ThinLTOCodeGenerator.cpp
361

*Output

363

I think this is because this output callback is being used in cases where a hook is aborting the pipeline early by returning false (see e.g. ThinLTOCodeGenerator::promote) so we would never expect to reach here. It would probably be clearer if this was spelt out explicitly.

In D23778#545093, @pcc wrote:

I suppose a higher level question is whether you want to reimplement the entire ThinLTOCodeGenerator or just the libLTO interface?

Interestingly, I see it the opposite way: I'm trying for now to reimplement only the ThinLTOCodegenerator and not the full libLTO interface :)