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

2012-04-16 Thread Hans-Peter Nilsson
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

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

2012-04-02 Thread Michael Matz
Hi, 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

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

2012-04-02 Thread Jakub Jelinek
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,

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

2012-04-02 Thread Michael Matz
Hi, 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.

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

2012-03-30 Thread Richard Guenther
On Thu, Mar 29, 2012 at 8:34 PM, Richard Henderson r...@redhat.com wrote: On 03/29/2012 01:16 PM, Jan Hubicka wrote: Of course, there's still the problem of getting the unwind data correct at the point of the asm.  I commented about that in the PR you filed. I think i386 still has the problem

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

2012-03-30 Thread Richard Guenther
On Thu, Mar 29, 2012 at 3:59 PM, Michael Matz m...@suse.de wrote: Hi, On Thu, 29 Mar 2012, Stephan Bergmann wrote: Anyway, would it be worthwhile filing an RFE for an asm annotation telling the compiler that it contains code that can throw? I suppose yes.

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

2012-03-30 Thread Jan Hubicka
On Thu, Mar 29, 2012 at 8:34 PM, Richard Henderson r...@redhat.com wrote: On 03/29/2012 01:16 PM, Jan Hubicka wrote: Of course, there's still the problem of getting the unwind data correct at the point of the asm.  I commented about that in the PR you filed. I think i386 still has the

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

2012-03-30 Thread Richard Guenther
2012/3/30 Jan Hubicka hubi...@ucw.cz: On Thu, Mar 29, 2012 at 8:34 PM, Richard Henderson r...@redhat.com wrote: On 03/29/2012 01:16 PM, Jan Hubicka wrote: Of course, there's still the problem of getting the unwind data correct at the point of the asm.  I commented about that in the PR

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

2012-03-30 Thread Jan Hubicka
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.

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

2012-03-29 Thread Stephan Bergmann
Hi all, In LibreOffice's ever-beloved low-level code to synthesize calls to C++ virtual functions, I'm having the following problem (on Linux x86_64). The function callVirtualMethod at

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

2012-03-29 Thread Jakub Jelinek
On Thu, Mar 29, 2012 at 09:05:29AM +0200, Stephan Bergmann wrote: In LibreOffice's ever-beloved low-level code to synthesize calls to C++ virtual functions, I'm having the following problem (on Linux x86_64). The function callVirtualMethod at

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

2012-03-29 Thread Stephan Bergmann
On 03/29/2012 09:44 AM, Jakub Jelinek wrote: On Thu, Mar 29, 2012 at 09:05:29AM +0200, Stephan Bergmann wrote: In LibreOffice's ever-beloved low-level code to synthesize calls to C++ virtual functions, I'm having the following problem (on Linux x86_64). The function callVirtualMethod

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

2012-03-29 Thread Richard Guenther
On Thu, Mar 29, 2012 at 10:47 AM, Stephan Bergmann sberg...@redhat.com wrote: On 03/29/2012 09:44 AM, Jakub Jelinek wrote: On Thu, Mar 29, 2012 at 09:05:29AM +0200, Stephan Bergmann wrote: In LibreOffice's ever-beloved low-level code to synthesize calls to C++ virtual functions, I'm having

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

2012-03-29 Thread Stephan Bergmann
On 03/29/2012 11:16 AM, Richard Guenther wrote: On Thu, Mar 29, 2012 at 10:47 AM, Stephan Bergmannsberg...@redhat.com wrote: So an explicit -fnon-call-exceptions on the command line seems to indeed help. Unfortunately, moving that into a #pragma GCC optimize (non-call-exceptions) at the

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

2012-03-29 Thread Michael Matz
Hi, On Thu, 29 Mar 2012, Stephan Bergmann wrote: Anyway, would it be worthwhile filing an RFE for an asm annotation telling the compiler that it contains code that can throw? I suppose yes. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52770 RFE: Letting compiler know asm block can

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

2012-03-29 Thread Andrew Haley
On 03/29/2012 02:59 PM, Michael Matz wrote: Actually, with -fnon-call-exceptions volatile asms are already supposed to be throwing. It's just that this got lost with tree-ssa. With the patch and -fnon-call-exceptions a simple __asm__ volatile (...) is regarded as possibly throwing.

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

2012-03-29 Thread Stephan Bergmann
On 03/29/2012 04:12 PM, Andrew Haley wrote: On 03/29/2012 02:59 PM, Michael Matz wrote: Actually, with -fnon-call-exceptions volatile asms are already supposed to be throwing. It's just that this got lost with tree-ssa. With the patch and -fnon-call-exceptions a simple __asm__ volatile (...)

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

2012-03-29 Thread Michael Matz
Hi, On Thu, 29 Mar 2012, Andrew Haley wrote: On 03/29/2012 02:59 PM, Michael Matz wrote: Actually, with -fnon-call-exceptions volatile asms are already supposed to be throwing. It's just that this got lost with tree-ssa. With the patch and -fnon-call-exceptions a simple __asm__

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

2012-03-29 Thread Richard Henderson
On 03/29/2012 03:05 AM, Stephan Bergmann wrote: Hi all, In LibreOffice's ever-beloved low-level code to synthesize calls to C++ virtual functions, I'm having the following problem (on Linux x86_64). The function callVirtualMethod at

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

2012-03-29 Thread Jan Hubicka
On 03/29/2012 03:05 AM, Stephan Bergmann wrote: Hi all, In LibreOffice's ever-beloved low-level code to synthesize calls to C++ virtual functions, I'm having the following problem (on Linux x86_64). The function callVirtualMethod at

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

2012-03-29 Thread Richard Henderson
On 03/29/2012 01:16 PM, Jan Hubicka wrote: Of course, there's still the problem of getting the unwind data correct at the point of the asm. I commented about that in the PR you filed. I think i386 still has the problem that it is small register class target and if you set rdi/rax and

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

2012-03-29 Thread Eric Botcazou
non-call-exceptions is a relatively big hammer. It marks _all_ non-trivial instructions as throwing. The all goes against the relatively here, and relatively is more correct. Not all non-trivial instructions are marked as throwing, e.g. loads and stores from/to the stack aren't. -- Eric