Straight-line single assignment in C--

Edward Z. Yang ezyang at MIT.EDU
Sat Jan 21 05:44:02 CET 2012


Hello all,

I was wondering if the following style of register assignment ever
shows up in C-- code generated by GHC:

    a = R1
    I32[a] = 1
    a = R2
    I32[a] = 2

That is to say, there are two disjoint live ranges of a: we could rename
all instances of a in the first and second lines to something different
without affecting the semantics (although maybe affecting register allocation
and stack spilling.)

    asdf = R1
    I32[asdf] = 1
    a = R2
    I32[a] = 2

But C-- is not in SSA form, and even when no loops are involved it seems
that some naughty code generator could reuse a variable.  This is
pretty inconvenient, because I want to record this information

    a = R1 // used only once
    I32[a] = 1
    a = R2 // used only once
    I32[a] = 2

in a map:

    a -> used only once

But since the register names go all the same place this may end in tears.

If multiple assignment is rare enough in straight line code, I might
be able to take the conservative approach and just say

    a -> used multiple times

Which I don't think will cause any problems in the inlining step later.
But I don't have a good sense for this.

Edward



More information about the Glasgow-haskell-users mailing list