[llvm-dev] UD and DU chains for LLVM IR before running mem2reg

David Chisnall via llvm-dev llvm-dev at lists.llvm.org
Fri May 26 01:48:46 PDT 2017


On 25 May 2017, at 17:32, Jajoo, Malhar <malhar.jajoo14 at imperial.ac.uk> wrote:
> 
> 
> Hi David,
> 
> Thanks for your reply , I am aware of those issues.
> ( my issue is quite complex - monomorphization for iN types at runtime ) 

This shouldn’t preclude performing SSA construction.

> However, I have a simpler question -
> 
> Do the "alloca" instructions need to be at the top always ?
> and do they need to be in reverse order ( reverse order of parameters and then reverse order of variable declarations ?)

No, with two caveats:

 - mem2reg / SROA will only work reliably with allocas in the entry block

 - Alloca instructions will allocate stack space whenever they are reached: if you accidentally put one in a loop then you can end up increasing your stack size considerably (if you actually dynamic allocations dependent on control flow, you are advised to look at the stack save and restore intrinsics).

David


More information about the llvm-dev mailing list