This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
dwarf2 eh for alpha
- To: egcs-patches at cygnus dot com
- Subject: dwarf2 eh for alpha
- From: Richard Henderson <rth at cygnus dot com>
- Date: Wed, 2 Sep 1998 00:41:07 -0700
- Reply-To: Richard Henderson <rth at cygnus dot com>
Prompted by initial work by HJ Lu, and resurrecting some bits
I worked on last year, here is my take on dwarf2 eh for alpha.
A good deal of it is fairly straightforward, but there are a
couple of bits that warrent explanation.
* rtl.h (enum reg_note): Add REG_FRAME_RELATED_EXPR.
* rtl.c (reg_note_name): Update.
* dwarf2out.c (dwarf2out_frame_debug): Use it.
The problem being addressed here is that there is one Alpha
prologue case in which we emit a loop to probe the stack. There
is no hope of the dwarf2 bits divining what is going on, so I
arrange for this new note to tell it what is going on. If the
note exists, that expression is used instead of the insn pattern.
* toplev.c (rest_of_compilation): Invoke MD_AFTER_RTL_GENERATION.
* alpha.h (MD_AFTER_RTL_GENERATION): New.
* alpha.c (alpha_init_expanders): Reset RA as a fixed register.
(alpha_return_addr): Return a return_address_pointer mem.
(alpha_after_rtl_generation): New.
(alpha_replace_rap): New.
(alpha_ra_ever_killed): If RA is fixed, it isn't "killed" by the
definition intended here.
This is probably the bit to most raise eyebrows.
Once upon a time I came up with a __builtin_return_address(0)
implementation for Alpha that would work in all situations, and
produce optimal code to boot.
With this design, the actual return address wound up in a pseudo,
which was fine for __builtin_return_address, but for the exception
stuff, __builtin_set_eh_return_addr wants write access to the
return register/location, which my pseudo does not allow, which
means that I must come up with something else.
My scheme is as follows: During initial RTL generation, I assume that
the return address will wind up on the stack, and use the eliminable
return_address_pointer_rtx for this. Standard stuff.
But, not wanting to give up my good performance under leaf node
conditions, I do something else, namely, after RTL generation is
complete, and before the first optimization pass runs, if the
function does not otherwise clobber the return address, I go
through and replace all of the memory references I emitted earlier
with the actual hard-reg. I also make this register fixed, so I
don't get into trouble with register allocation.
For this reason I invented MD_AFTER_RTL_GENERATION, to let me go
through and look at such things. Ideally, I would combine this
hook with FINALIZE_PIC, which is run at the same place, but is only
invoked if -fpic.
Anyway, while I did not actually split up the patch, I did arrange
the changelog into mostly independant pieces that could be committed
individually.
Comments?
r~
* rtl.h (enum reg_note): Add REG_FRAME_RELATED_EXPR.
* rtl.c (reg_note_name): Update.
* alpha.c (FRP, set_frame_related_p): New.
(alpha_expand_prologue): Use FRP to mark sequences.
(alpha_expand_epilogue): Mark sequences that should be FRP.
* dwarf2out.c (dwarf2out_frame_debug): Use it.
* libgcc2.c (put_return_addr): New argument for the column to store in.
(__throw): Recognize retaddr saved in reg saved on stack.
* rtl.h (reg_mentioned_between_p): New prototype.
(return_address_pointer_rtx): Declare.
* rtlanal.c (reg_mentioned_between_p): New function.
* alpha.h (FIRST_PSEUDO_REGISTER): Increment.
(RETURN_ADDRESS_POINTER_REGNUM): New.
(FIXED_REGISTERS, CALL_USED_REGISTERS): Account for it.
(REGISTER_NAMES, REG_ALLOC_ORDER): Likewise.
(ELIMINABLE_REGS, INITIAL_ELIMINATION_OFFSET): Likewise.
(REGNO_OK_FOR_BASE_P): Allow it.
* alpha.md (exception_receiver): New.
* alpha/crtbegin.asm: Invoke __{de}register_frame_info appropriately.
* alpha/crtend.asm: End the .eh_frame section.
* alpha/elf.h (DWARF2_DEBUGGING_INFO): Define.
(ASM_SPEC): Handle -gdwarf*. Work around gas ehopt bug.
(ASM_FILE_START): Don't give .file when emitting dwarf2.
* toplev.c (rest_of_compilation): Invoke MD_AFTER_RTL_GENERATION.
* alpha.h (MD_AFTER_RTL_GENERATION): New.
* alpha.c (alpha_init_expanders): Reset RA as a fixed register.
(alpha_return_addr): Return a return_address_pointer mem.
(alpha_after_rtl_generation): New.
(alpha_replace_rap): New.
(alpha_ra_ever_killed): If RA is fixed, it isn't "killed" by the
definition intended here.
>From H.J Lu:
* dwarf2out.c (dwarf2out_frame_debug): Handle frame store
into (mem (reg)).
* expr.c (expand_builtin) [BUILT_IN_FP]: Return the hard fp.
* alpha.h (INCOMING_RETURN_ADDR_RTX): New.
d-axp-eh-1.gz