SSA in the presence of procedure calls

"Edsko de Vries" <devriese@cs.tcd.ie>
28 Sep 2006 22:51:51 -0400

          From comp.compilers

Related articles
SSA in the presence of procedure calls devriese@cs.tcd.ie (Edsko de Vries) (2006-09-28)
Re: SSA in the presence of procedure calls dnovillo@redhat.com (Diego Novillo) (2006-09-30)
Re: SSA in the presence of procedure calls dannyb@google.com (Daniel Berlin) (2006-09-30)
| List of all articles for this month |

From: "Edsko de Vries" <devriese@cs.tcd.ie>
Newsgroups: comp.compilers
Date: 28 Sep 2006 22:51:51 -0400
Organization: http://groups.google.com
Keywords: SSA, analysis, question
Posted-Date: 28 Sep 2006 22:51:50 EDT

Hi,


I have been trying to find some references about this problem, but so
far have found none. If anyone can provide me with any pointers (papers
or books), I'd appreciate it.


The problem is trying to convert a program to SSA form, in the presence
of procedure calls. Consider the following example:


int* global_a;


void f()
{
        *global_a = 2;
}


void g()
{
        int a, b;
        global_a = &a;
        a = 1;
        f();
        b = a;
}


How do I translate g() into SSA form? The problem is, of course, the
last assignment - what subscript do we give to a? Do we need to insert
a phi-function after the call to f (since without interprocedural
analysis we have no way of knowing whether f does or does not modify
a)? Let me emphasize that I'm not looking for an interprocedural SSA: a
"simple" intraprocedural SSA is okay, but I need to be able to deal
with function calls.


To my surprise, gcc simply generated


a.0 = 1;
f();
b.0 = a.0;


But to my mind, this is simply wrong, because this would imply that the
value of b after the call to f must be equal to the value of a before
the call to f, which is not true (of course, gcc does eventually
generate correct code) - it seems to violate the most basic condition
of SSA that every variable must have a uniquely identified assignment.


Thanks,


Edsko



Post a followup to this message

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