Page MenuHomePhabricator

[LTO] Call the optimizer before invoking codegen
ClosedPublic

Authored by davide on Mar 16 2016, 6:08 PM.

Details

Summary

This is the required plumbing needed to run the LTO passes.
Now the global constructor is (correctly) stripped away from the produced shared library.

Diff Detail

Event Timeline

davide updated this revision to Diff 50900.Mar 16 2016, 6:08 PM
davide retitled this revision from to [LTO] Call the optimizer before invoking codegen.
davide updated this object.
davide added a reviewer: rafael.
davide added subscribers: llvm-commits, mehdi_amini, silvas.
silvas added inline comments.Mar 16 2016, 6:38 PM
ELF/SymbolTable.cpp
114

instead of bool Optimized do const char *Suffix or StringRef Suffix or something.

142

Can you mention the relation to the code in gold-plugin.cpp? Something like "For now, we follow what gold-plugin.cpp does" maybe?

test/ELF/lto/ctors.ll
17

This kind of defeats the original purpose of this test. Can you put a volatile asm in @ctor (so it is kept) and also some piece of trivially dead code. We can do -save-temps and check that the optimized output does not have the trivially dead code without having to remove the original check.

davide updated this revision to Diff 50965.Mar 17 2016, 12:40 PM

Addressed Sean's comments.

  • The original test was augmented with an asm inline statement so that the global constructor doesn't get reclaimed.
  • I added another test to ensure the optimizer strips the unused global constructor (similarly to what I did before in my previous patch).

This is just sanity checking, we may want to test other stuff in the future.
Rafael, Sean, you OK with this?

LGTM with a nit.

test/ELF/lto/ltopasses-basic.ll
14

I would describe the situation more like: "@ctor doesn't do anything and so the optimizer should kill it, leaving no ctors"

rafael added inline comments.Mar 17 2016, 3:15 PM
ELF/SymbolTable.cpp
144

I think we should keep doing what gold does.

What I would have a FIXME for is refactoring this to avoid code duplication.

145

You don't need this.

146

Start variables with an upper case letter.

147

This line is too long. Please run git-clang-format.

test/ELF/lto/ltopasses-basic.ll
3

Please use -save-temps.

That way you test it and it is a more direct check aynway.

15

I agree with silvas' wording.

davide updated this revision to Diff 50983.Mar 17 2016, 3:54 PM

Update after Rafael's comments.

rafael accepted this revision.Mar 17 2016, 3:59 PM
rafael edited edge metadata.

LGTM with a nit.

ELF/SymbolTable.cpp
156

Why do you need *&?

This revision is now accepted and ready to land.Mar 17 2016, 3:59 PM
This revision was automatically updated to reflect the committed changes.