This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C++: Letting compiler know asm block can call function that can throw?


On Mon, 2 Apr 2012, Michael Matz wrote:
> On Mon, 2 Apr 2012, Jakub Jelinek wrote:
>
> > > 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
>
> Yikes!  That's indeed the case.  I'll want to retract what I said, concede
> with Honza that we're lucky and add that we're lucky mostly because
> register variables are not regarded as gimple registers, hence all stores
> to such variables are regarded as VDEFs.  So there will be VDEF/VUSE
> chains between initializer and syscall, which prevents most code motion
> into that chain.  That itself doesn't e.g. prevent the load/store
> disambiguator from disambiguating two such decls, even if they refer to
> the same hardreg.  So we really are merely lucky, with enough effort we
> probably could create a "miscompiling" testcase.

Lucky perhaps, but documented lucky: this is documented (grep
sysint extend.texi) to work, to avoid having talented gcc
hackers saying "oh, that worked?  You have to _stop doing that_;
you've just been lucky in previous versions" rather that "oops,
looks like I broke that; I'll fix it post-haste".

(There's *one* test-case in gcc.target/cris/asmreg-1.c; this
could certainly do with more coverage.)

brgds, H-P


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]