Bug 28776 - [4.2 Regression] dwarf2out.c:2160: ICE: in build_polynomial_chrec, at tree-chrec.h:108
Summary: [4.2 Regression] dwarf2out.c:2160: ICE: in build_polynomial_chrec, at tree-ch...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.2.0
: P1 blocker
Target Milestone: 4.2.0
Assignee: Not yet assigned to anyone
URL:
Keywords: build, ice-on-valid-code
: 28780 28815 28856 (view as bug list)
Depends on:
Blocks: 28780 28815
  Show dependency treegraph
 
Reported: 2006-08-18 19:19 UTC by lucier
Modified: 2006-08-26 12:21 UTC (History)
9 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-08-19 07:08:38


Attachments
preprocessed source for dwarf2out.c (159.98 KB, application/x-gzip)
2006-08-18 21:34 UTC, lucier
Details

Note You need to log in before you can comment on or make changes to this bug.
Description lucier 2006-08-18 19:19:45 UTC
configure and build:

/bin/rm -rf *; ../configure --prefix=/pkgs/gcc-mainline --with-gmp=/opt/local/ --with-mpfr=/opt/local/ ; make -j 4 bootstrap >& build.log && (make -k -j 8 check RUNTESTFLAGS="--target_board 'unix{-mcpu=970/-m64}'"  >& check.log ; make mail-report-with-warnings.log)

with updated Xcode:

[descartes:gcc/mainline/objdir64] lucier% gcc -v
Using built-in specs.
Target: powerpc-apple-darwin8
Configured with: /private/var/tmp/gcc/gcc-5363.obj~28/src/configure --disable-checking -enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.0/ --with-gxx-include-dir=/include/c++/4.0.0 --with-slibdir=/usr/lib --build=powerpc-apple-darwin8 --host=powerpc-apple-darwin8 --target=powerpc-apple-darwin8
Thread model: posix
gcc version 4.0.1 (Apple Computer, Inc. build 5363)

fails with the stage2 build with

/Users/lucier/programs/gcc/mainline/objdir64/./prev-gcc/xgcc -B/Users/lucier/programs/gcc/mainline/objdir64/./prev-gcc/ -B/pkgs/gcc-mainline/powerpc-apple-darwin8.7.0/bin/ -c   -g -O2 -mdynamic-no-pic -DIN_GCC   -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Wold-style-definition -Wmissing-format-attribute -Werror -fno-common   -DHAVE_CONFIG_H -I. -I. -I../../gcc -I../../gcc/. -I../../gcc/../include -I./../intl -I../../gcc/../libcpp/include -I/opt/local//include -I/opt/local//include -I../../gcc/../libdecnumber -I../libdecnumber    ../../gcc/dwarf2out.c -o dwarf2out.o
../../gcc/dwarf2out.c: In function 'output_call_frame_info':
../../gcc/dwarf2out.c:2160: internal compiler error: in build_polynomial_chrec, at tree-chrec.h:108
Comment 1 Andrew Pinski 2006-08-18 21:26:50 UTC
Can you attach the preprocessed source?
Comment 3 lucier 2006-08-18 21:34:03 UTC
Created attachment 12094 [details]
preprocessed source for dwarf2out.c
Comment 4 Andrew Pinski 2006-08-19 05:59:15 UTC
I can reproduce the ICE on i686-linux-gnu with a native compiler with the preprocessed source.
Comment 5 Andrew Pinski 2006-08-19 06:02:24 UTC
Reducing.
Comment 6 Andrew Pinski 2006-08-19 07:08:38 UTC
Reduced testcase:
typedef struct dw_fde_struct
{
  int decl;
} *dw_fde_ref;
dw_fde_ref fde_table;
unsigned fde_table_in_use;
void output_call_frame_info (void)
{
  unsigned int i;
  dw_fde_ref fde;
  for (i = 0; i < fde_table_in_use; i++)
    {
      fde = &fde_table[i];
      tree_contains_struct_check_failed (fde_table[i].decl);
    }
}
------------------
And this did not ICE in 20060815.
Comment 7 Andrew Pinski 2006-08-20 05:12:19 UTC
*** Bug 28780 has been marked as a duplicate of this bug. ***
Comment 8 Andrew Pinski 2006-08-20 05:15:42 UTC
PR 28780 have a couple more testcases of the same problem.
Comment 9 Richard Biener 2006-08-20 16:44:10 UTC
Caused by

 2006-04-02  Sebastian Pop  <pop@cri.ensmp.fr>

...
+       * tree-chrec.h (build_polynomial_chrec): Insert an assert to check
+       the types of the operands.
...

for the testcase in comment #6 we have the two types

 type <pointer_type 0xa7cebf18 dw_fde_ref
        type <record_type 0xa7cebe04 dw_fde_struct sizes-gimplified type_0 SI
            size <integer_cst 0xa7c5f3f0 constant invariant 32>
            unit size <integer_cst 0xa7c5f180 constant invariant 4>
            align 32 symtab 0 alias set 4 fields <field_decl 0xa7cebe60 decl> context <translation_unit_decl 0xa7c77f08 D.1540>
            pointer_to_this <pointer_type 0xa7cebebc> chain <type_decl 0xa7c77dd0 D.1520>>
        sizes-gimplified public unsigned SI size <integer_cst 0xa7c5f3f0 32> unit size <integer_cst 0xa7c5f180 4>
        align 32 symtab 0 alias set -1>

and

 <pointer_type 0xa7cebebc
    type <record_type 0xa7cebe04 dw_fde_struct sizes-gimplified type_0 SI
        size <integer_cst 0xa7c5f3f0 constant invariant 32>
        unit size <integer_cst 0xa7c5f180 constant invariant 4>
        align 32 symtab 0 alias set 4
        fields <field_decl 0xa7cebe60 decl type <integer_type 0xa7c71284 int>
            SI file t.i line 3 size <integer_cst 0xa7c5f3f0 32> unit size <integer_cst 0xa7c5f180 4>
            align 32 offset_align 128
            offset <integer_cst 0xa7c5f198 constant invariant 0>
            bit offset <integer_cst 0xa7c5f978 constant invariant 0> context <record_type 0xa7cebe04 dw_fde_struct>> context <translation_unit_decl 0xa7c77f08 D.1540>
        pointer_to_this <pointer_type 0xa7cebebc> chain <type_decl 0xa7c77dd0 D.1520>>
    sizes-gimplified public unsigned SI size <integer_cst 0xa7c5f3f0 32> unit size <integer_cst 0xa7c5f180 4>
    align 32 symtab 0 alias set 2>

note the identical TREE_TYPE (type).  And note that we have a NOP_EXPR
wrapping the correct type.

We arrive there by fold_used_pointer, which is simplifying casts but not
re-folding the arguments to the plus/minus in

      if (code == PLUS_EXPR)
        expr = chrec_fold_plus (TREE_TYPE (expr), new0, new1);
      else
        expr = chrec_fold_minus (TREE_TYPE (expr), new0, new1);

The following fixes it:

Index: tree-scalar-evolution.c
===================================================================
*** tree-scalar-evolution.c     (revision 116257)
--- tree-scalar-evolution.c     (working copy)
*************** fold_used_pointer (tree expr)
*** 1847,1852 ****
--- 1847,1854 ----
        if (new0 == op0 && new1 == op1)
        return expr;

+       new0 = chrec_convert (TREE_TYPE (expr), new0, NULL_TREE);
+       new1 = chrec_convert (TREE_TYPE (expr), new1, NULL_TREE);
        if (code == PLUS_EXPR)
        expr = chrec_fold_plus (TREE_TYPE (expr), new0, new1);
        else
Comment 10 Andrew Pinski 2006-08-20 16:48:56 UTC
No this was caused by:
2006-08-16  Zdenek Dvorak <dvorakz@suse.cz>
        * tree-scalar-evolution.c (fold_used_pointer_cast, pointer_offset_p,
        fold_used_pointer, pointer_used_p): New functions.

as fold_used_pointer is new.
Comment 11 Zdenek Dvorak 2006-08-22 08:05:40 UTC
Subject: Re:  [4.2 Regression] dwarf2out.c:2160: ICE: 
     in build_polynomial_chrec, at tree-chrec.h:108

The fix seems OK to me, could you please test and submit it?

> The following fixes it:
>
> Index: tree-scalar-evolution.c
> ===================================================================
> *** tree-scalar-evolution.c     (revision 116257)
> --- tree-scalar-evolution.c     (working copy)
> *************** fold_used_pointer (tree expr)
> *** 1847,1852 ****
> --- 1847,1854 ----
>         if (new0 == op0 && new1 == op1)
>         return expr;
>
> +       new0 = chrec_convert (TREE_TYPE (expr), new0, NULL_TREE);
> +       new1 = chrec_convert (TREE_TYPE (expr), new1, NULL_TREE);
>         if (code == PLUS_EXPR)
>         expr = chrec_fold_plus (TREE_TYPE (expr), new0, new1);
>         else
>
>


Comment 12 patchapp@dberlin.org 2006-08-22 11:45:25 UTC
Subject: Bug number PR28776

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2006-08/msg00779.html
Comment 13 Richard Biener 2006-08-22 16:26:30 UTC
Fixed.
Comment 14 Richard Biener 2006-08-22 16:27:01 UTC
Subject: Bug 28776

Author: rguenth
Date: Tue Aug 22 16:26:32 2006
New Revision: 116326

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116326
Log:
2006-08-22  Richard Guenther  <rguenther@suse.de>

	PR middle-end/28776
	* tree-scalar-evolution.c (fold_used_pointer): Add at_stmt
	parameter.  Convert arguments to arithmetic expression to the
	chrecs type.
	(analyze_scalar_evolution_1): Adjust caller.

	* gcc.c-torture/compile/pr28776-1.c: New testcase.
	* gcc.c-torture/compile/pr28776-2.c: Likewise.

Added:
    trunk/gcc/testsuite/gcc.c-torture/compile/pr28776-1.c
    trunk/gcc/testsuite/gcc.c-torture/compile/pr28776-2.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-scalar-evolution.c

Comment 15 Andrew Pinski 2006-08-24 10:39:42 UTC
*** Bug 28815 has been marked as a duplicate of this bug. ***
Comment 16 Richard Biener 2006-08-26 12:15:08 UTC
*** Bug 28856 has been marked as a duplicate of this bug. ***