This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: C++: Letting compiler know asm block can call function that can throw?
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Michael Matz <matz at suse dot de>
- Cc: Jan Hubicka <hubicka at ucw dot cz>, Richard Guenther <richard dot guenther at gmail dot com>, Richard Henderson <rth at redhat dot com>, Stephan Bergmann <sbergman at redhat dot com>, gcc at gcc dot gnu dot org
- Date: Mon, 2 Apr 2012 16:16:48 +0200
- Subject: Re: C++: Letting compiler know asm block can call function that can throw?
- References: <4F7409B9.2010407@redhat.com> <4F748A47.4070306@redhat.com> <20120329171639.GD18490@atrey.karlin.mff.cuni.cz> <4F74AB1F.2020607@redhat.com> <CAFiYyc3Z00jGmQFVjotK4bF7_Br6uUkP=2ka=rs_UAtXGnqHtw@mail.gmail.com> <20120330122106.GE8468@kam.mff.cuni.cz> <CAFiYyc2ryHLbzXP_67ngHnB7NGOGkBkjnFO8b8DBYdMAxcmZUQ@mail.gmail.com> <20120330154537.GB1340@kam.mff.cuni.cz> <Pine.LNX.4.64.1204021603570.25409@wotan.suse.de>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Mon, Apr 02, 2012 at 04:07:59PM +0200, Michael Matz wrote:
> On Fri, 30 Mar 2012, Jan Hubicka wrote:
>
> > > Motion across hardreg sets/uses are not restricted. And I would not expect
> > > an optimizing compiler to do that (it's your own fault to use hardregs in
> > > complex C code).
> >
> > Well, the syscall sequence is an example of somehting that should be
> > inlined into arbitrary code w/o potential risk of ICEs.
>
> The syscall sequence doesn't consist of multiple independend instructions,
> but rather is one asm with the right constraints. So gcc has no chance to
> move something between the register setup (which only is explicit after
> reload) and the syscall instruction. If syscall sequences were
> implemented like this:
>
> inline int syscall1(int number, long arg1) {
> register int ax __asm__("eax");
> register long di __asm__("rdi");
> ax = number;
> di = arg1;
> __asm__ volatile ("syscall");
> }
>
> _then_ we would probably get miscompilations here and there.
That is actually what is used on most targets, including x86_64 (i?86 is an
exception here, because it has single hard register constraints for most of
the interesting registers).
Jakub