Eliminate SSA Virtual registers

Hi,

is there a opt pass that replaces the SSA virtual registers to stack-variables? I want to eliminate the SSA virtual register from my IR. Kindly suggest

BR/Nizam

Try the register to memory demotion pass. opt -reg2mem

- Ben

Hi Ben,

That did help. I continue to notice the virtual register in the program. I use LLVM 3.4. The program i am looking at is a very simple one. Listed below

int global_var;
int *global_ptr;

int32_t main(int32_t argc, char ** argv){
int p = 10;
int k = 20;
int *pp;
char *c_pp;

pp = &k;
global_ptr = pp;
pp = &p;
global_ptr = &global_var;
return 0;
}

BR/Nizam

Here it is: http://llvm.org/docs/Passes.html#reg2mem-demote-all-values-to-stack-slots

I mean to say didnt help. :slight_smile:

The reg2mem pass only eliminates phi nodes, using the stack to pass values between basic blocks.

LLVM models a register based CPU, not a stack based one. All calculations are assumed to be performed in registers with the arguments and results loaded and stored from the stack.

What other constraints are you hoping to enforce on your flavour of IR?