Christophe de Dinechin
2011-Jan-06 10:43 UTC
[LLVMdev] Marking a function prototype as being "persistent"
Hello and happy new year, I'm using LLVM to JIT-compile the XL programming language. I've recently added a whole-program optimization phase that gives excellent results, but I noticed that the StripDeadPrototypesPass was removing all references to my runtime support functions. Apparently, this depends on the oddly-named UnitAtATime parameter. Set it to false. Try again. Suggestion: what about a comment explaining what "UnitAtATime" means :-) Even then, my runtime function prorotypes are still being stripped away by the GlobalDCE added by createStandardLTOPasses. So my question is: what is the correct, officially recommended way to reference runtime functions so that global DCE won't get rid of them? Or am I supposed to re-create the corresponding Function instances for every translation? Thank you in advance for enlightening me Christophe
Duncan Sands
2011-Jan-06 17:06 UTC
[LLVMdev] Marking a function prototype as being "persistent"
Hi Christophe,> I'm using LLVM to JIT-compile the XL programming language. I've recently added a whole-program optimization phase that gives excellent results, but I noticed that the StripDeadPrototypesPass was removing all references to my runtime support functions.why is that a problem?> Apparently, this depends on the oddly-named UnitAtATime parameter. Set it to false. Try again. Suggestion: what about a comment explaining what "UnitAtATime" means :-)If UnitAtATime is false this means that you are optimizing functions as you are generating them, rather than first generating all functions and other globals and only then optimizing. It's basically a historical anachronism coming from the way GCC used to work.> 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.> So my question is: what is the correct, officially recommended way to reference runtime functions so that global DCE won't get rid of them? Or am I supposed to re-create the corresponding Function instances for every translation?There's some kind of disconnect here, so you need to explain more :) Ciao, Duncan.
Reid Kleckner
2011-Jan-06 17:24 UTC
[LLVMdev] Marking a function prototype as being "persistent"
On Thu, Jan 6, 2011 at 10:06 AM, Duncan Sands <baldrick at free.fr> wrote:>> So my question is: what is the correct, officially recommended way to reference runtime functions so that global DCE won't get rid of them? Or am I supposed to re-create the corresponding Function instances for every translation? > > There's some kind of disconnect here, so you need to explain more :)Presumably since he's using the JIT he's generating more code later that uses the runtime functions, which he wants to be marked as available. The disconnect is wanting to apply whole-program/LTO type optimizations before you have the whole program. I think the answer is to not use the standard LTO passes and to create your own versions that are careful not to do things like delete types and prototypes that you might need later. Reid
Reasonably Related Threads
- [LLVMdev] Marking a function prototype as being "persistent"
- [LLVMdev] Marking a function prototype as being "persistent"
- [LLVMdev] Marking a function prototype as being "persistent"
- [LLVMdev] Marking a function prototype as being "persistent"
- [LLVMdev] Marking a function prototype as being "persistent"