public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug other/64711] New: Unconsistency with -fnon-call-exceptions when used along inline and ipa optimizations
@ 2015-01-21 15:06 jbellon at bsc dot es
  2015-01-21 15:15 ` [Bug other/64711] " jbellon at bsc dot es
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: jbellon at bsc dot es @ 2015-01-21 15:06 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64711

            Bug ID: 64711
           Summary: Unconsistency with -fnon-call-exceptions when used
                    along inline and ipa optimizations
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: other
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jbellon at bsc dot es

Created attachment 34517
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34517&action=edit
Test program source code

Behavior of -fnon-call-exceptions mechanism (throwing an exception inside a
signal handler) is not consistent if optimization options change, that is, the
result of a given program can be different.

In order to make a comparison, I ran a test program several times, each with
different optimizations enabled. The test consists on copying a buffer (r/w
protected) content to another (will trigger a SIGSEGV signal). The program uses
two additional functions that make a call to another as shown below:
   main --> foo --> copy --> std::copy (raises SIGSEGV) --> handler

Each of the function calls are surounded by a try/catch block.

1) Compilation either with -O0 or without any flags (just
-fnon-call-exceptions):
 Exception is caught at the "copy" function (the one which calls
 std::copy). This is the expected behavior.

2) Compilation using -O1 -O2 or -O3 flag directly:
Exception is not being caught.

3) If both -fno-inline and -fno-ipa-pure-const are included before -OX, then
the program behaves as in (1): 
CXXFLAGS=-fnon-call-exceptions -fno-inline -fno-ipa-pure-const -O1

4) Compilation using both -finline -fipa-pure-const, but without any other
optimization:
Exception is caught in "foo" function.

5) Compilation using -fipa-pure-const only
Same as (3).

6) Compilation using -finline only
Same as (1).

7) Compilation using -fipa-pure-const -finline -finline-functions
Same as (3).

8) Compilation using -fno-inline -O1
Same as (2).

9) Compilation using -fno-ipa-pure-const -O1
Same as (3).

It seems that catch blocks are being optimized out or that, because of the
inlining, the generated code is not able to find any catch blocks inside its
scope.

The test program is attached. Compile command used is:
    g++ -fnon-call-exceptions [-fno-ipa-pure-const -fno-inline] -O{0,1,2,3}
file.cpp -o exec
or
   g++ -fnon-call-exceptions -fipa-pure-const -finline file.cpp -o exec

--------------------------
System info
GCC version:
   g++ (SUSE Linux) 4.8.1 20130909 [gcc-4_8-branch revision 202388]
Also reproduced with (default flags) public SVN versions:
   g++ (GCC) 4.8.1
   g++ (GCC) 5.0.0 20150109 (experimental)
Linux version (openSUSE 13.1)
Linux 3.11.10-25-desktop #1 SMP PREEMPT Wed Dec 17 17:57:03 UTC 2014 (8210f77)
x86_64 GNU/Linux


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-11-13  7:47 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-21 15:06 [Bug other/64711] New: Unconsistency with -fnon-call-exceptions when used along inline and ipa optimizations jbellon at bsc dot es
2015-01-21 15:15 ` [Bug other/64711] " jbellon at bsc dot es
2020-11-11 18:05 ` [Bug middle-end/64711] Unconsistency with -fnon-call-exceptions when used along inline and ipa optimizations and memmov laszlo.2.nemeth@continental-corporation.com
2020-11-12  7:11 ` rguenth at gcc dot gnu.org
2020-11-12  8:57 ` ebotcazou at gcc dot gnu.org
2020-11-12 13:25 ` rguenther at suse dot de
2020-11-12 14:43 ` ebotcazou at gcc dot gnu.org
2020-11-13  7:47 ` rguenther at suse dot de

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).