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

Duncan Sands baldrick at free.fr
Fri Oct 26 01:27:40 PDT 2012


Hi Rafael,

On 26/10/12 04:56, Rafael EspĂ­ndola wrote:
> 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.

while this patch looks OK to me, what do you think about removing the special
role of "main"?  Is there any reason why users of this pass (eg the "opt" tool)
can't just pass in "main" if they don't want "main" to be internalized?

Ciao, Duncan.




More information about the llvm-commits mailing list