c-gimplify.c:gimplify_decl_stmt

Daniel Berlin dberlin@dberlin.org
Sun Jun 6 19:27:00 GMT 2004


On Jun 6, 2004, at 3:13 PM, Eric Christopher wrote:

> On Sun, 2004-06-06 at 12:07, Richard Kenner wrote:
>>> The comments in front of the funciton reference variables inside the
>>> function, which is wrong.
>>
>>     I don't know that this is "wrong" as long as it's useful. 
>> Describing the
>>     algorithm or high level stuff that's needed to understand the 
>> function.
>>
>> No, it's confusing.
>>
>> Comments *before* the function are supposed to explain the 
>> *specification*
>> of the function, which means what a *caller* of the function needs to 
>> know.
>>
>
> I disagree. There's nothing at all wrong with describing the function
> itself and what it does and how it works. I've just taken a look at the
> comment and it does appear to be split along specification and
> description boundaries. Seems very useful to me. I've often wanted this
> for other functions. Also, it seems a good way to keep functions small
> and to the point - otherwise we get fold (). :)
>

I agree completely with you.
For example, I have the following above compute_antic in gvn-pre:

/* Compute the ANTIC set for BLOCK.

ANTIC_OUT[BLOCK] = intersection of ANTIC_IN[b] for each b in 
succ(BLOCK), if
succs(BLOCK) > 1
ANTIC_OUT[BLOCK] = phi_translate (ANTIC_IN[succ(BLOCK)]) if
succs(BLOCK) == 1

ANTIC_IN[BLOCK] = clean(ANTIC_OUT[BLOCK] U EXP_GEN[BLOCK] -
TMP_GEN[BLOCK])

*/
static void
compute_antic (basic_block BLOCK)

Under richard's view, it appears this would simply be something like

/* Compute the ANTIC set for BLOCK
    BLOCK is the basic block to compute the ANTIC set for.
    Returns nothing.  */


This tells you absolutely nothing interesting about the function.
Keeping the exact details about how the algorithm works doesn't belong 
somewhere like the top of the file, it belongs near the code that 
performs it.

Of course, in this case (before someone complains you need a general 
description of the algorithm workings), i have a general overview of 
the algorithm at the top of the file that includes :

    Next, we generate the ANTIC sets.  ANTIC is a backwards dataflow
    problem.  These sets represent the anticipatable expressions.  An
    expression is anticipatable in a given block if it could be
    generated in that block.  This means that if we had to perform an
    insertion in that block, of the value of that expression, we could.
    Calculating the ANTIC sets requires phi translation of expressions,
    because the flow goes backwards through phis.  We must iterate to a
    fixpoint of the ANTIC sets, because we have a kill set.
    Even in SSA form, values are not live over the entire function,
    only from their definition point onwards.  So we have to remove
    values from the ANTIC set once we go past the definition point of
    the leaders that make them up.  compute_antic performs all of this 
computation.


Note it doesn't exactly say *how* we compute ANTIC, that's the stuff 
right above compute_antic.



More information about the Gcc mailing list