Bug 33920 - [4.3 Regression] Segfault in combine_blocks/tree-if-conv.c
Summary: [4.3 Regression] Segfault in combine_blocks/tree-if-conv.c
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: 4.3.0
Assignee: Uroš Bizjak
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2007-10-27 14:16 UTC by Martin Michlmayr
Modified: 2007-10-28 17:41 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.2.2
Known to fail:
Last reconfirmed: 2007-10-27 17:20:30


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Michlmayr 2007-10-27 14:16:04 UTC
With current trunk:

(sid)tbm@coconut0:~$ /usr/lib/gcc-snapshot/bin/gcc -c -O3 gclcvs-tinfo.c
gclcvs-tinfo.c: In function 'init_code':
gclcvs-tinfo.c:19: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
Comment 1 Martin Michlmayr 2007-10-27 14:16:28 UTC
/* Testcase by Martin Michlmayr <tbm@cyrius.com> */

typedef union lispunion *object;
struct character
{
  long e;
};
extern struct symbol Cnil_body;
extern struct symbol Ct_body;
struct vector
{
  object *v_self;
};
union lispunion
{
  struct vector v;
};
void init_code ()
{
  object V659;
  object _x, _y;
  object V643;
  long V648;
  unsigned char V653;
  object V651;
  object V654;
  object V658;

T1240:
  if (V648 >= (long)V651)
    goto T1243;
  V653 = ((char *) V654->v.v_self)[V648];
  V659 = (object) V654 + V653;
T1261:
  V658 =
    (object)
     V659 ? (object) & Ct_body : (object) & Cnil_body;
  if (V658 == (object) & Cnil_body)
    goto T1249;
  goto T1224;
T1249:
 V648 = (long) V648 + 1;
  goto T1240;
T1243:
  V643 = (object) & Cnil_body;
T1224:
  _y = V643;
  number_plus (_x, _y);
}
Comment 2 Martin Michlmayr 2007-10-27 14:16:40 UTC
Program received signal SIGSEGV, Segmentation fault.
0x4000000000705cb1 in combine_blocks (loop=0x20000000004214a0)
    at gcc/tree-if-conv.c:727
727       if (TREE_CODE (tmp_cond) == TRUTH_NOT_EXPR)
(gdb) where
#0  0x4000000000705cb1 in combine_blocks (loop=0x20000000004214a0)
    at gcc/tree-if-conv.c:727
#1  0x4000000000708ad0 in tree_if_conversion (loop=0x20000000004214a0, for_vectorizer=224 '▒')
    at gcc/tree-if-conv.c:200
#2  0x4000000000709fe0 in main_tree_if_conversion () at gcc/tree-if-conv.c:1136
#3  0x4000000000533090 in execute_one_pass (pass=0x6000000000034088)
    at gcc/passes.c:1118
#4  0x40000000005335d0 in execute_pass_list (pass=0x6000000000034088)
    at gcc/passes.c:1171
#5  0x4000000000533620 in execute_pass_list (pass=0x6000000000034af0)
    at gcc/passes.c:1172
#6  0x4000000000533620 in execute_pass_list (pass=0x60000000000341f0)
    at gcc/passes.c:1172
#7  0x4000000000743c90 in tree_rest_of_compilation (fndecl=0x20000000004fac00)
    at gcc/tree-optimize.c:404
#8  0x4000000000a92550 in cgraph_expand_function (node=0x20000000004fae00)
    at gcc/cgraphunit.c:1060
#9  0x4000000000a96f90 in cgraph_optimize () at gcc/cgraphunit.c:1123
#10 0x40000000000306c0 in c_write_global_declarations () at gcc/c-decl.c:8077
#11 0x4000000000666590 in toplev_main (argc=<value optimized out>, argv=<value optimized out>)
    at gcc/toplev.c:1055
#12 0x4000000000146fc0 in main (argc=3, argv=0x60000fffffffb9f8)
    at gcc/main.c:35
(gdb)
Comment 3 Martin Michlmayr 2007-10-27 16:05:31 UTC
20070916 is ok, 20071020 shows the segfault.
Comment 4 Uroš Bizjak 2007-10-27 17:20:30 UTC
(In reply to comment #3)
> 20070916 is ok, 20071020 shows the segfault.

Patch in testing:

Index: tree-if-conv.c
===================================================================
--- tree-if-conv.c      (revision 129683)
+++ tree-if-conv.c      (working copy)
@@ -724,7 +724,8 @@ find_phi_replacement_condition (struct l
 
   /* Select condition that is not TRUTH_NOT_EXPR.  */
   tmp_cond = (first_edge->src)->aux;
-  if (TREE_CODE (tmp_cond) == TRUTH_NOT_EXPR)
+  if (tmp_cond != NULL_TREE
+      && TREE_CODE (tmp_cond) == TRUTH_NOT_EXPR)
     {
       edge tmp_edge;
 
Comment 5 Uroš Bizjak 2007-10-27 21:35:07 UTC
Patch at http://gcc.gnu.org/ml/gcc-patches/2007-10/msg01649.html
Comment 6 uros 2007-10-28 14:58:07 UTC
Subject: Bug 33920

Author: uros
Date: Sun Oct 28 14:57:50 2007
New Revision: 129696

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129696
Log:
        PR tree-optimization/33920
        * tree-if-conv.c (tree_if_conversion): Force predicate of single
        successor bb to true when predecessor bb has NULL predicate.
        (find_phi_replacement_condition): Assert that tmp_cond is non-null.

testsuite/ChangeLog:

        PR tree-optimization/33920
        * gcc.dg/tree-ssa/pr33290.c: New test.


Added:
    trunk/gcc/testsuite/gcc.dg/tree-ssa/pr33920.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-if-conv.c

Comment 7 Uroš Bizjak 2007-10-28 17:41:18 UTC
Fixed.