SSA construction and aliased variables

Sergey Solyanik <sergey@solyanik.com>
17 Jan 1998 00:03:36 -0500

          From comp.compilers

Related articles
SSA construction and aliased variables sergey@solyanik.com (Sergey Solyanik) (1998-01-17)
Re: SSA construction and aliased variables kistler@ics.uci.edu (Thomas Kistler) (1998-01-17)
Re: SSA construction and aliased variables felix@mamba.pond.sub.org (1998-02-08)
| List of all articles for this month |
From: Sergey Solyanik <sergey@solyanik.com>
Newsgroups: comp.compilers
Date: 17 Jan 1998 00:03:36 -0500
Organization: Bentley Systems, Inc.
Keywords: analysis, question

Ladies/Gentlemen,


I have a question of how SSA form should treat aliased variables and
globals. I was unable to find any mention of the problem in all works
on SSA that I've read.


Scenarion:
If we have global p in the following code


if (a)
        {
        p = 1;
        }
else
        {
        p = 2;
        }
...


naive translation will do the following:


if (a)
        {
        p1 = 1;
        }
else
        {
        p2 = 2;
        }


p3 = psi(p1, p2);


and it will be fine. When we translate back from SSA,
we move assignments to p3:


if (a)
        {
        p1 = 1;
        p3 = p1;
        }
else
        {
        p2 = 2;
        p3 = p1;
        }


and feed it to register allocator.


However, if the code is


if (a)
        {
        p = 1;
        }
else
        {
        p = 2;


        function_call();
        }


the result from translation back from SSA in the form


if (a)
        {
        p1 = 1;
        p3 = p1;
        }
else
        {
        p2 = 2;
        p3 = p1;
        function_call ();
        }


is incorrect because function_call may change p.


Trivial solution that comes to mind right away is to treat assignments
of globals and aliased variables in low-level intermediate code as a
deref, i. e. not consider global or aliased tags as SSA-able resources
at all


load reg, global


then has out reg (variable), and in deref function of global (not SSA
variable). And just let PRE or value numbering deal with it as an
expression, and account for side effects of aliasing and function
calls.


Is there more intelligent way of dealing with this?


Any insights/references deeply appreciated.


Regards --


Sergey Solyanik
Software Developer
Bentley Systems, Inc


Sergey.Solyanik@bentley.com
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.