Hello,
For the following test case, reg.c
#include <stdio.h>
int getinput()
{
static int u=10;
return u++;
}
int main()
{
int a,b,c,d,e,f,g;
a=getinput();
b=getinput();
c=getinput();
d=getinput();
e=getinput();
f=getinput();
g=getinput();
printf(“%d %d %d %d %d %d %d\n”,a,b,c,d,e,f,g);
a=b=c=d=e=f=g=0;
return 0;
}
1. $clang reg.c -Xclang -disable-O0-optnone -S -emit-llvm -o reg.ll && opt -mem2reg -S reg.ll -o reg.ll && llc --regalloc=greedy reg.ll -o reg.s
2. $clang reg.c -Xclang -disable-llvm-passes -S -emit-llvm -o reg.ll && opt -mem2reg -S reg.ll -o reg.ll && llc --regalloc=greedy reg.ll -o reg.s
3. $clang reg.c -S -emit-llvm -o reg.ll && opt -mem2reg -S reg.ll -o reg.ll && llc --regalloc=greedy reg.ll -o reg.s
Only 1. gives the spill code but it deletes the dead stores., 2 and 3 give only allocas. Why so??
How -mem2reg works and what it depends on?
How to generate the spill code with dead stores?
Thank you.
Regards,
Priyanka