mem2reg

I have a question. In the handout, it says that out pass
should enable mem2reg to put as many scalar fields of
structures in virtual registers as possible. Does that just
mean that we should try to replace as many structures as
possible to scalars? or it means something else special to
enable mem2reg to do that? If that's the case, how to enable
mem2reg to do that?

Thanks,
xiaodong

I have a question. In the handout, it says that out pass
should enable mem2reg to put as many scalar fields of
structures in virtual registers as possible. Does that just
mean that we should try to replace as many structures as
possible to scalars? or it means something else special to

Yup, that's all you have to do. mem2reg will convert allocas of scalar
values into registers directly for you (doing an SSA construction phase).
Thus, all you have to do is transform as many things into 'alloca int' or
'alloca float' (etc) as possible.

-Chris

http://llvm.cs.uiuc.edu/
http://www.nondot.org/~sabre/Projects/