[LLVMdev] Stack-based vs. register-based variables and other optimizations
rmann at latencyzero.com
Sat Jan 19 21:03:37 PST 2013
Implementing my little language I'm using clang and the CPP back-end as a guide for a lot of things. One thing I see is that clang always uses Alloca and stores parameters on the stack.
Are there LLVM passes that figure this out and put things in registers, skipping the stack allocations and loads/stores?
Similarly, if I use Alloca to make room for a pointer on the stack, store a value in it, later load that value and pass it as an argument in a call, can LLVM choose to optimize that stack allocation away and use a register?
I'm mostly talking about x86 here.
On the other hand, if I just stuck the result of one function call in as an argument to another function call, or tried to use a parameter value directly (assuming appropriate casts), will LLVM create intermediate stack-based space if required?
I'm very unfamiliar with calling conventions on x86 (as compared to PowerPC or ARM), so I'm hoping I don't have to worry about that stuff much.
More information about the llvm-dev