Bug 21460 - sjlj_emit_function_enter adds rtl to wrong block
Summary: sjlj_emit_function_enter adds rtl to wrong block
Status: CLOSED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.0.2
Assignee: Alan Modra
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: ice-on-valid-code, patch
Depends on:
Blocks:
 
Reported: 2005-05-09 04:54 UTC by Andrija Antonijevic
Modified: 2021-02-16 17:26 UTC (History)
3 users (show)

See Also:
Host: powerpc-unknown-linux
Target: powerpc-unknown-linux
Build: powerpc-unknown-linux
Known to work:
Known to fail: 4.0.2, 4.1.0
Last reconfirmed: 2005-09-01 06:27:10


Attachments
The isolated snippet causing the problem (243 bytes, text/plain)
2005-05-09 04:57 UTC, Andrija Antonijevic
Details
cfg dump (3.05 KB, text/plain)
2005-09-01 14:25 UTC, Alan Modra
Details
testcase that fails on mainline (314 bytes, text/plain)
2005-09-02 04:39 UTC, Alan Modra
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andrija Antonijevic 2005-05-09 04:54:29 UTC
When compiling a C++ file, gcc 4.0.0 and 4.0.1 20050507 prerelease report an 
internal compiler error:

> /gcc-test/bin/g++ ice.cpp -O2
ice.cpp: In constructor 'SomeException::SomeException(const char*, ...)':
ice.cpp:21: internal compiler error: in calc_dfs_tree, at dominance.c:376
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

> /gcc-test/bin/g++ -v
Using built-in specs.
Target: powerpc-linux
Configured with: ../gcc-4.0-20050507/configure --enable-languages=c,c++ --
prefix=/gcc-test --with-gnu-as --with-gnu-ld --with-system-zlib --without-
included-gettext --enable-threads=posix --enable-haifa --enable-sjlj-exceptions 
powerpc-linux
Thread model: posix
gcc version 4.0.1 20050507 (prerelease)

When not using -O2 or when using -O2 -msoft-float, the ICE isn't reported. This 
points to

  /* Save FP registers if needed.  */
  if (DEFAULT_ABI == ABI_V4
      && TARGET_HARD_FLOAT && TARGET_FPRS
      && ! no_rtl
      && next_cum.fregno <= FP_ARG_V4_MAX_REG)

branch in gcc/config/rs6000/rs6000.c whose contents causes the problem (directly 
or indirectly).

I have managed to create a minimal testcase for the problem and will attach it 
to this report.
Comment 1 Andrija Antonijevic 2005-05-09 04:57:07 UTC
Created attachment 8843 [details]
The isolated snippet causing the problem

I'm including the .cpp file and not the .i file since it doesn't need to be
preprocessed.
Comment 2 Alan Modra 2005-09-01 06:27:09 UTC
Confirmed with --enable-sjlj-exceptions build.
Comment 3 Alan Modra 2005-09-01 14:25:48 UTC
Created attachment 9640 [details]
cfg dump
Comment 4 Alan Modra 2005-09-02 04:39:08 UTC
Created attachment 9643 [details]
testcase that fails on mainline

mainline powerpc-linux --enable-sjlj-exceptions gives
$ ./g++ -B./ -O0 -S /src/tmp/pr21460.cc -Wall
/src/tmp/pr21460.cc: In constructor 'SomeException::SomeException(const char*,
...)':
/src/tmp/pr21460.cc:31: error: too many outgoing branch edges from bb 0
/src/tmp/pr21460.cc:31: error: in basic block 0:
/src/tmp/pr21460.cc:31: error: flow control insn inside a basic block
(jump_insn 10 9 103 0 (set (pc)
	(if_then_else (ne (reg:CC 69 1)
		(const_int 0 [0x0]))
	    (label_ref 19)
	    (pc))) -1 (nil)
    (nil))
/src/tmp/pr21460.cc:31: internal compiler error: in rtl_verify_flow_info_1, at
cfgrtl.c:2135

The branch is the one generated by rs6000.c:setup_incoming_varargs.
Comment 5 Alan Modra 2005-09-02 05:10:39 UTC
Huh, the problem is that sjlj exception code is tacked on to the end of basic
block 0, instead of the end of the prologue.
Comment 6 GCC Commits 2005-09-06 04:54:11 UTC
Subject: Bug 21460

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	amodra@gcc.gnu.org	2005-09-06 04:53:54

Modified files:
	gcc            : ChangeLog except.c 

Log message:
	PR middle-end/21460
	* except.c (sjlj_emit_function_enter): Find the function begin
	note even when it's not in first basic block.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.9898&r2=2.9899
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/except.c.diff?cvsroot=gcc&r1=1.315&r2=1.316

Comment 7 GCC Commits 2005-09-06 08:09:58 UTC
Subject: Bug 21460

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	amodra@gcc.gnu.org	2005-09-06 08:09:44

Modified files:
	gcc            : ChangeLog except.c 

Log message:
	PR middle-end/21460
	* except.c (sjlj_emit_function_enter): Find the function begin
	note even when it's not in first basic block.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=2.7592.2.412&r2=2.7592.2.413
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/except.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.298&r2=1.298.2.1

Comment 8 Alan Modra 2005-09-06 08:28:29 UTC
Fixed
Comment 9 Andrija Antonijevic 2005-10-13 23:07:30 UTC
The problem is indeed fixed in 4.0.2, thank you.
Comment 10 seurer 2021-02-16 17:26:22 UTC
This was fixed long ago.  Closing.