[llvm-dev] How to get llvm SSA IR?

Tim Northover via llvm-dev llvm-dev at lists.llvm.org
Wed Mar 20 03:40:27 PDT 2019


Hi Panqaq,

On Wed, 20 Mar 2019 at 10:02, Qiuhong Pan via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> I want to distinguish varitable p in p = q;p = n, like p0 = q;p1 = n. How can I get the SSA IR that variables defined multiple times in the original representation will be split into separate instances?

LLVM doesn't try to model memory in any kind of SSA form, so I don't
think it even has the representation for what you're asking unless it
can see through the memory accesses to p entirely. But &p has escaped
via the first call to get2 so LLVM has very little flexibility to do
that (get2 could have saved &p somewhere and later calls could access
it, and the data stored there).

What IR would you expect to see for this example if LLVM was doing
what you wanted?

> Also, when I use -mem2reg to get IR, they would do some optimization, such as remove some unnecessary stack allocation. Can I get SSA IR without other optimization?

As far as I know there's nothing more minimal than mem2reg for this
purpose, but on the other hand removing stack allocations is exactly
what mem2reg is designed for so I'm not really sure what you're after.

Cheers.

Tim.


More information about the llvm-dev mailing list