Bug 56539 - [4.6 Regression] ICE: verify_ssa failed: caused by -foptimize-sibling-calls
Summary: [4.6 Regression] ICE: verify_ssa failed: caused by -foptimize-sibling-calls
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.6.3
: P3 normal
Target Milestone: 4.6.4
Assignee: Jakub Jelinek
URL:
Keywords: ice-on-valid-code, wrong-code
Depends on:
Blocks:
 
Reported: 2013-03-05 16:23 UTC by Jonathan Wakely
Modified: 2013-04-03 18:21 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 4.4.3, 4.7.3, 4.8.0
Known to fail: 4.5.2, 4.6.3, 4.7.2
Last reconfirmed: 2013-03-05 00:00:00


Attachments
gcc48-pr56539.patch (569 bytes, patch)
2013-03-06 14:14 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Wakely 2013-03-05 16:23:00 UTC
short string2int( const char * buf, unsigned len )
{
    return (len > 1) ? ( buf[len-1] - '0' ) + (short)10 * string2int(buf, len-1) : ( *buf - '0' );
}

#include <assert.h>

int main()
{
    assert( string2int("13", 2) == 13);
    return 0;
}


At -O2 this program fails the assertion with 4.6 and 4.7

A 4.8 build with --enable-checking gets an ICE in verify_ssa

$ ~/gcc/4.8/bin/gcc t.c -O2
t.c: In function 'string2int':
t.c:12:1: error: definition in block 3 follows the use
 }
 ^
for SSA_NAME: _15 in statement:
acc_tmp_17 = (short int) _15;
t.c:12:1: internal compiler error: verify_ssa failed
0xa57004 verify_ssa(bool)
        ../../gcc-4.8/gcc/tree-ssa.c:1049
0x83ea9e execute_function_todo
        ../../gcc-4.8/gcc/passes.c:1967
0x83f56c execute_todo
        ../../gcc-4.8/gcc/passes.c:1999
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.


Using -fno-optimize-sibling-calls makes the bug go away for all versions.
Comment 1 Jonathan Wakely 2013-03-05 16:24:59 UTC
4.4.3 is OK, 4.5.2 fails the asertion
Comment 2 Jonathan Wakely 2013-03-05 16:27:50 UTC
N.B. -O3 is needed to trigger the bug with 4.5.2
Comment 3 Marek Polacek 2013-03-05 16:34:13 UTC
Confirmed.
Comment 4 Vincent 2013-03-05 21:14:04 UTC
bash-4.1$ x86_64-w64-mingw32-gcc -O2 t.c
t.c: In function 'main':
t.c:9:5: internal compiler error: Segmentation fault
 int main()
     ^
0x71fa65 crash_signal
        ../../gcc-4_8-trunk/gcc/toplev.c:332
0x748617 ssa_default_def(function*, tree_node*)
        ../../gcc-4_8-trunk/gcc/tree-dfa.c:310
0x748688 get_or_create_ssa_default_def(function*, tree_node*)
        ../../gcc-4_8-trunk/gcc/tree-dfa.c:362
0x760f7c get_reaching_def
        ../../gcc-4_8-trunk/gcc/tree-into-ssa.c:1155
0x76364b maybe_replace_use
        ../../gcc-4_8-trunk/gcc/tree-into-ssa.c:1772
0x76364b rewrite_update_stmt
        ../../gcc-4_8-trunk/gcc/tree-into-ssa.c:1955
0x76364b rewrite_update_enter_block
        ../../gcc-4_8-trunk/gcc/tree-into-ssa.c:2124
0xab5380 walk_dominator_tree(dom_walk_data*, basic_block_def*)
        ../../gcc-4_8-trunk/gcc/domwalk.c:187
0x761183 rewrite_blocks
        ../../gcc-4_8-trunk/gcc/tree-into-ssa.c:2204
0x7669bc update_ssa(unsigned int)
        ../../gcc-4_8-trunk/gcc/tree-into-ssa.c:3283
0xb371a4 tree_unroll_loops_completely(bool, bool)
        ../../gcc-4_8-trunk/gcc/tree-ssa-loop-ivcanon.c:1175
0x7d4c92 tree_complete_unroll_inner
        ../../gcc-4_8-trunk/gcc/tree-ssa-loop.c:511
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.

gcc version 4.8.0 20130305 (experimental) [gcc-4_8-trunk revision 196448]
Comment 5 Jakub Jelinek 2013-03-06 07:23:21 UTC
I'd say this started with http://gcc.gnu.org/viewcvs?view=revision&revision=151935
Comment 6 Jakub Jelinek 2013-03-06 14:14:24 UTC
Created attachment 29596 [details]
gcc48-pr56539.patch

Untested fix.
Comment 7 Jonathan Wakely 2013-03-06 15:08:29 UTC
The patch fixes the problem for both 4.7 and 4.8, using the testcase above and the original C++ one it was reduced from.
Comment 8 Vincent 2013-03-06 21:20:29 UTC
Jakub,
The patch also fixed this problem testcase on cross compiler (x86_64-w64-mingw32).
Comment 9 Jakub Jelinek 2013-03-06 23:26:48 UTC
Author: jakub
Date: Wed Mar  6 23:26:42 2013
New Revision: 196511

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=196511
Log:
	PR tree-optimization/56539
	* tree-tailcall.c (adjust_return_value_with_ops): Use GSI_SAME_STMT
	instead of GSI_CONTINUE_LINKING as last argument to
	force_gimple_operand_gsi.

	* gcc.c-torture/compile/pr56539.c: New test.

Added:
    trunk/gcc/testsuite/gcc.c-torture/compile/pr56539.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-tailcall.c
Comment 10 Jakub Jelinek 2013-03-06 23:33:03 UTC
Fixed on the trunk so far.
Comment 11 Jakub Jelinek 2013-04-03 08:26:20 UTC
Author: jakub
Date: Wed Apr  3 08:22:12 2013
New Revision: 197392

URL: http://gcc.gnu.org/viewcvs?rev=197392&root=gcc&view=rev
Log:
	Backported from mainline
	2013-03-06  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/56539
	* tree-tailcall.c (adjust_return_value_with_ops): Use GSI_SAME_STMT
	instead of GSI_CONTINUE_LINKING as last argument to
	force_gimple_operand_gsi.  Adjust function comment.

	* gcc.c-torture/compile/pr56539.c: New test.

Added:
    branches/gcc-4_7-branch/gcc/testsuite/gcc.c-torture/compile/pr56539.c
Modified:
    branches/gcc-4_7-branch/gcc/ChangeLog
    branches/gcc-4_7-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_7-branch/gcc/tree-tailcall.c
Comment 12 Jakub Jelinek 2013-04-03 08:26:48 UTC
Fixed for 4.7.3+ too.
Comment 13 Jakub Jelinek 2013-04-03 18:21:37 UTC
Author: jakub
Date: Wed Apr  3 18:05:09 2013
New Revision: 197451

URL: http://gcc.gnu.org/viewcvs?rev=197451&root=gcc&view=rev
Log:
	Backported from mainline
	2013-03-06  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/56539
	* tree-tailcall.c (adjust_return_value_with_ops): Use GSI_SAME_STMT
	instead of GSI_CONTINUE_LINKING as last argument to
	force_gimple_operand_gsi.  Adjust function comment.

	* gcc.c-torture/compile/pr56539.c: New test.

Added:
    branches/gcc-4_6-branch/gcc/testsuite/gcc.c-torture/compile/pr56539.c
Modified:
    branches/gcc-4_6-branch/gcc/ChangeLog
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_6-branch/gcc/tree-tailcall.c