• Russ Cox's avatar
    cmd/gc: correct liveness for fat variables · 7a7c0ffb
    Russ Cox authored
    The VARDEF placement must be before the initialization
    but after any final use. If you have something like s = ... using s ...
    the rhs must be evaluated, then the VARDEF, then the lhs
    assigned.
    
    There is a large comment in pgen.c on gvardef explaining
    this in more detail.
    
    This CL also includes Ian's suggestions from earlier CLs,
    namely commenting the use of mode in link.h and fixing
    the precedence of the ~r check in dcl.c.
    
    This CL enables the check that if liveness analysis decides
    a variable is live on entry to the function, that variable must
    be a function parameter (not a result, and not a local variable).
    If this check fails, it indicates a bug in the liveness analysis or
    in the generated code being analyzed.
    
    The race detector generates invalid code for append(x, y...).
    The code declares a temporary t and then uses cap(t) before
    initializing t. The new liveness check catches this bug and
    stops the compiler from writing out the buggy code.
    Consequently, thi...
    7a7c0ffb
cgen.c 28.1 KB