debug_hooks->end_prologue problem

Jim Wilson wilson@specifix.com
Tue Feb 28 00:45:00 GMT 2006


Douglas B Rupp wrote:
> The HP debugger on IA64 VMS defines a new Dwarf2 attribute that computes the
> offset of the end of the prologue from the beginning of the function. To
> implement this an end prologue label must be emitted and some related info
> saved in dwarf2out.c. 
> 
> However I've noted that calling debug_hooks->end_prologue as it is now
> results in a label at the beginning of the prologue, not the end. I've
> attached the obvious fix below, but I fear it might mess up sdbout.c. Should
> I create a new hook or investigate the impact on sdbout and try to fix it?

Belatedly looking at this, you seem to be confused over the purpose of 
the NOTE_INSN_FUNCTION_BEG note.  It does not mark the beginning of the 
function.  That is the first RTL insn.  Instead, it marks the beginning 
of the function body.

If you compile without optimization, then this is the same as the 
prologue end.  If you compile with optimization, then the function body 
and the prologue overlap.  Now the question is, do you really want to 
mark the beginning of the function body (which may be before the 
prologue end), or the end of the prologue (which may be after the 
function body beginning).  Either way, it is likely that someone may not 
be happy.  However, in general, the former (function body beginning) is 
more useful to end users, as otherwise they won't be able to debug all 
of the code in the function body.  So the current code in final.c looks 
correct.

Othogonal to this, there is the problem of what to do with these notes 
when instruction scheduling is enabled.  It looks like the current code 
just always moves notes to the beginning of the basic block containing 
them.  That means effectively that the function beginning is always 
before the prologue.  However, the prologue end note also ends up before 
the prologue in the same place.  So using that one doesn't help.  The 
only solution is a more general one.  In the scheduler, before 
scheduling, you need to mark all instructions that originally came from 
the prologue.  After scheduling, you go back through, find the first 
non-prologue instruction, and insert the NOTE_INSN_FUNCTION_BEG note 
before it.  You find the last prologue instruction, and insert the 
NOTE_INSN_PROLOGUE_END note after it.  You would also have to do the 
same (reversed) for the epilogue.  It isn't clear if this extra work is 
worthwhile.
-- 
Jim Wilson, GNU Tools Support, http://www.specifix.com



More information about the Gcc mailing list