This is the required plumbing needed to run the LTO passes.
Now the global constructor is (correctly) stripped away from the produced shared library.
Details
Diff Detail
Event Timeline
| 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. | |
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" | |
| 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. | |
instead of bool Optimized do const char *Suffix or StringRef Suffix or something.