[LLVMdev] Marking a function prototype as being "persistent"

Christophe de Dinechin christophe at taodyne.com
Thu Jan 6 21:21:31 PST 2011


Hi Duncan,

On 7 janv. 2011, at 01:00, Duncan Sands wrote:

> LTO is for doing optimizations that are only valid when the module contains
> everything that is needed to build the final executable.  So adding a flag to
> say "not everything is there after all" makes no sense to me.

And indeed, everything is there when I call LTO. The flag is not "not everything is there after all", but "don't damage your inputs".

> 
>>>> Even then, my runtime function prorotypes are still being stripped away by the GlobalDCE added by createStandardLTOPasses.
>>> 
>>> Sure, and why not?  Unused prototypes are not used for anything, they won't
>>> turn up in the generated code for example.
>> 
>> They are not used this time. But why can't I generate additional code in the same module after having run LTO?
> 
> Because by definition LTO is for when everything is there!

And again, everything is there. I just want to be able to reuse the same inputs later for incremental recompilation.

>  Why don't you create your own sequence of passes that does what you want rather than calling createStandardLTOPasses?

As I wrote in an earlier reply, been there, done that. That forces me to maintain a quasi-clone of standard passes.

>  One of the nice features of LLVM is that you can run any passes you choose in any order you like.

Having standard LTO passes get in the way of incremental recompilation is not a feature.

>  That said, probably the reason you are getting improved optimization is due to running the "internalize" pass. If so be warned that it is not safe to run internalize unless all functions and their bodies are present in the module.

All functions and bodies are present, so that's not the issue. The issue is that some inputs of LTO are destroyed as a side effect of running it.

> If you run internalize, optimize, and then later add a few more functions to the module all kinds of nasty subtle things can go wrong, not just those you saw with GlobalDCE.

Do you mean I should assume for example that the Functions I generated are also irreversibly damaged? If so, what passes do I need to avoid if I want to preserve the ability to do incremental recompilation?


Thanks for your help
Christophe



More information about the llvm-dev mailing list