This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: patch for broken thunk on sparc
- From: Eric Botcazou <ebotcazou at libertysurf dot fr>
- To: Alexey Starovoytov <alexey dot starovoytov at sun dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Fri, 7 Apr 2006 12:58:53 +0200
- Subject: Re: patch for broken thunk on sparc
- References: <Pine.GSO.4.31.0604041247530.18801-100000@boojum>
> on sparc the thunk (support for C++ multiple inheritance)
> is created incorrectly if flag_pic or -mcmodel=*medany -m64 are present.
>
> The problem is in code (for -m32):
> sub %sp, 8, %sp
> st %o7, [%sp]
> st %l7, [%sp+4]
> which incorrectly uses window save space.
> If OS needs to save window after that sequence the restored registers
> will contain some junk.
Thanks for catching that! This part of sparc_output_mi_thunk really is
over-engineered and I should probably have refrained from writing it in the
first place. But let's make it correct now that it is there.
> For some reason -O and above optimize that thunk sequence away, so users
> at least have sort of workaround.
Because flag_delayed_branch is true. The whole stuff is aimed to emit a thunk
(i.e. essentially a sibling call) without using delay slots...
> Would be nice to patch all 4.x branches.
Indeed, I'll install the fix everywhere.
> Here is the proposed patch:
>
> * config/sparc/sparc.c (emit_and_preserve): Use
> correct slot offset to preserve registers
I think you'll be clobbering the previous frame. We probably need to build a
dummy frame of SPARC_STACK_ALIGN (FIRST_PARM_OFFSET(0) + 2*UNITS_PER_WORD)
bytes. And I also think that the offset can simply be STACK_POINTER_OFFSET.
--
Eric Botcazou