This is an archive of the discontinued LLVM Phabricator instance.

Add --plugin-opt=emit-llvm option.
ClosedPublic

Authored by ruiu on Dec 14 2018, 1:33 PM.

Details

Summary

--plugin-opt=emit-llvm is an option for LTO. It makes the linker to
combine all bitcode files and write the result to an output file without
doing codegen. Gold LTO plugin has this option.

This option is being used for some post-link code analysis tools that
have to see a whole program but don't need to see them in the native
machine code.

Diff Detail

Repository
rL LLVM

Event Timeline

ruiu created this revision.Dec 14 2018, 1:33 PM
pcc accepted this revision.Dec 14 2018, 1:42 PM

LGTM

This revision is now accepted and ready to land.Dec 14 2018, 1:42 PM
tejohnson accepted this revision.Dec 14 2018, 1:46 PM

Noting below one difference compared to gold-plugin behavior, which I think is ok, so LGTM.

lld/ELF/LTO.cpp
106 ↗(On Diff #178274)

In gold-plugin, emit-llvm and save-temps are mutually-exclusive (last one wins) at the plugin level. With this, you get kindof a hybrid if both are specified: addSaveTemps code will essentially install a bunch of hooks including PostInternalizeModuleHook, but from what I can tell looking at the addSaveTemps code, it will recognize that PostInternalizeModuleHook is already set and ensure the original hook is invoked first. This means that you would get some of the save-temps output, but then at the post-internalization point you'll get this hook to write the bitcode to the output file and then stop. In some ways this seems nicer to me though. Not objecting, just noting the difference.

This revision was automatically updated to reflect the committed changes.