[llvm-commits] Fix internalize in the case where no symbols are needed

Rafael EspĂ­ndola rafael.espindola at gmail.com
Thu Oct 25 19:56:39 PDT 2012


There is what I think is a logical bug in the internalize pass. If no
symbols are needed, the pass returns false and fails to internalize
anything.

This bug is unfortunately visible at the C api level. If
lto_codegen_add_must_preserve_symbol is never called, all symbol are
preserved instead of none. In the gold plugin we used to avoid the bug
by just dropping modules where no symbol was needed, but unfortunately
that is not correct in the presence of static constructors. This is
the case for example in opt plugins: they don't need to export any
symbols, they just need to register with opt via a static constructor.

The attached patch fixed the bug at the origin (i.e., the internalize
pass). If we must remain bug by bug compatible with the existing C
api, I can instead add a lto_codegen_preserve_no_symbols. The
semantics would be

* lto_codegen_preserve_no_symbols and
lto_codegen_add_must_preserve_symbol must not both be called.
* If lto_codegen_add_must_preserve_symbol is called at least once, we
preserve the symbols passed on those calls.
* if none of those functions is ever called, we preserve every symbol.
* if only lto_codegen_preserve_no_symbols is called we internalize every symbol.

Cheers,
Rafael
-------------- next part --------------
A non-text attachment was scrubbed...
Name: t.patch
Type: application/octet-stream
Size: 2904 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20121025/d198caab/attachment.obj>


More information about the llvm-commits mailing list