Bug 26096 - [4.2 Regression] Ada bootstrap fails in g-alleve.adb
Summary: [4.2 Regression] Ada bootstrap fails in g-alleve.adb
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: ada (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: 4.2.0
Assignee: Eric Botcazou
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-04 01:00 UTC by Ulrich Weigand
Modified: 2006-02-15 10:02 UTC (History)
2 users (show)

See Also:
Host:
Target: s390x-*-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-02-04 08:44:29


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ulrich Weigand 2006-02-04 01:00:41 UTC
On s390x (64-bit only), Ada bootstrap fails with

+===========================GNAT BUG DETECTED==============================+
| 4.2.0 20060131 (experimental) (s390x-ibm-linux-gnu) GCC error:           |
| in simplify_subreg, at simplify-rtx.c:4339                               |
| Error detected at g-alleve.adb:1977:14                                   |
| Please submit a bug report; see http://gcc.gnu.org/bugs.html.            |
| Use a subject line meaningful to you and us to track the bug.            |
| Include the entire contents of this bug box in the report.               |
| Include the exact gcc or gnatmake command that you entered.              |
| Also include sources listed below in gnatchop format                     |
| (concatenated together with no headers between files).                   |
+==========================================================================+

The source code in question is

   function abs_v16qi (A : LL_VSC) return LL_VSC is
      VA : constant VSC_View := To_View (A);
   begin
      return To_Vector ((Values =>
                           LL_VSC_Operations.abs_vxi (VA.Values)));
   end abs_v16qi;

and the ICE occurs at

#0  internal_error (gmsgid=0x807dbcd4 "in %s, at %s:%d") at ../../gcc-head/gcc/diagnostic.c:587
#1  0x00000000803b12ee in fancy_abort (file=Variable "file" is not available.
) at ../../gcc-head/gcc/diagnostic.c:642
#2  0x00000000805146ee in simplify_subreg (outermode=BLKmode, op=0x20000417b28, innermode=DImode, byte=2155723988)
    at ../../gcc-head/gcc/simplify-rtx.c:4339
#3  0x0000000080514c1e in simplify_gen_subreg (outermode=BLKmode, op=0x20000417b28, innermode=DImode, byte=8)
    at ../../gcc-head/gcc/simplify-rtx.c:4606
#4  0x0000000080564ea2 in gen_lowpart_general (mode=BLKmode, x=0x20000417b28) at ../../gcc-head/gcc/rtlhooks.c:43
#5  0x0000000080409650 in convert_move (to=0x200004177e0, from=Variable "from" is not available.
) at ../../gcc-head/gcc/expr.c:640
#6  0x000000008040c73e in store_expr (exp=0x2000061dc60, target=0x200004177e0, call_param_p=0)
    at ../../gcc-head/gcc/expr.c:4337
#7  0x000000008040df32 in expand_assignment (to=0x20001a69f20, from=0x80) at ../../gcc-head/gcc/expr.c:4142
#8  0x00000000803fe844 in expand_expr_real_1 (exp=Variable "exp" is not available.
) at ../../gcc-head/gcc/expr.c:8443
#9  0x00000000804067d8 in expand_expr_real (exp=0x2000044f630, target=0x200001b2400, tmode=VOIDmode,
    modifier=EXPAND_NORMAL, alt_rtl=Variable "alt_rtl" is not available.
) at ../../gcc-head/gcc/expr.c:6545
#10 0x000000008051bb62 in expand_expr_stmt (exp=0x2000044f630) at expr.h:493
#11 0x00000000805669b8 in expand_gimple_basic_block (bb=0x20001ab0900, dump_file=Variable "dump_file" is not available.
) at ../../gcc-head/gcc/cfgexpand.c:1365
#12 0x0000000080568386 in tree_expand_cfg () at ../../gcc-head/gcc/cfgexpand.c:1624
#13 0x000000008056308e in execute_one_pass (pass=0x808ec280) at ../../gcc-head/gcc/passes.c:853
#14 0x00000000805631be in execute_pass_list (pass=0x808ec280) at ../../gcc-head/gcc/passes.c:885
#15 0x00000000802dc4ee in tree_rest_of_compilation (fndecl=0x20000248100) at ../../gcc-head/gcc/tree-optimize.c:412
#16 0x000000008001f8cc in gnat_expand_body (gnu_decl=0x20000248100) at ../../gcc-head/gcc/ada/misc.c:649
#17 0x00000000805b1c3e in cgraph_expand_function (node=0x20001a27450) at ../../gcc-head/gcc/cgraphunit.c:1101
#18 0x00000000805b3300 in cgraph_assemble_pending_functions () at ../../gcc-head/gcc/cgraphunit.c:354
#19 0x00000000805b2c0c in cgraph_finalize_function (decl=0x20000248100, nested=0 '\0')
    at ../../gcc-head/gcc/cgraphunit.c:480
#20 0x000000008003f176 in gnat_to_gnu (gnat_node=Variable "gnat_node" is not available.
) at ../../gcc-head/gcc/ada/trans.c:1485
#21 0x0000000080046996 in process_decls (gnat_decls=Variable "gnat_decls" is not available.
) at ../../gcc-head/gcc/ada/trans.c:5101
#22 0x000000008003e0fc in gnat_to_gnu (gnat_node=Variable "gnat_node" is not available.
) at ../../gcc-head/gcc/ada/trans.c:3763
#23 0x0000000080046e30 in Compilation_Unit_to_gnu (gnat_node=1643) at ../../gcc-head/gcc/ada/trans.c:2457
#24 0x0000000080048a74 in gigi (gnat_root=1643, max_gnat_node=Variable "max_gnat_node" is not available.
) at ../../gcc-head/gcc/ada/trans.c:241
#25 0x00000000802d13a0 in back_end.call_back_end (mode=back_end__generate_object)
    at ../../gcc-head/gcc/ada/back_end.adb:125
#26 0x00000000802d1b72 in _ada_gnat1drv () at ../../gcc-head/gcc/ada/gnat1drv.adb:620
#27 0x0000000080020396 in gnat_parse_file (set_yydebug=Variable "set_yydebug" is not available.
) at ../../gcc-head/gcc/ada/misc.c:242
#28 0x000000008052baa4 in toplev_main (argc=Variable "argc" is not available.
) at ../../gcc-head/gcc/toplev.c:998
#29 0x000002000004716a in __libc_start_main () from /lib64/tls/libc.so.6
#30 0x0000000080003992 in _start ()


It looks like the problem is caused by attempting to store a TImode
source into a BLKmode target:

(gdb) call debug_tree (to)
 <var_decl 0x20001a69f20 gnat__altivec__low_level_vectors__abs_v16qi__va___ALIGN
    type <record_type 0x20001a69c60 gnat__altivec__vector_views__vsc_view____ALIGN sizes-gimplified BLK
        size <integer_cst 0x200001c6060 constant invariant 256>
        unit size <integer_cst 0x200001ae3c0 constant invariant 32>
        align 64 symtab 0 alias set 0
        fields <field_decl 0x200005dec38 F type <record_type 0x20001a69420 gnat__altivec__vector_views__vsc_view>
            decl_5 TI file g-alleve.adb line 1975
            size <integer_cst 0x200001aedb0 constant invariant visited 128>
            unit size <integer_cst 0x200001aede0 constant invariant visited 16>
            align 128 offset_align 8
            offset <bit_and_expr 0x2000061bc18 type <integer_type 0x200001ba000 long int>

                arg 0 <negate_expr 0x200003dd7c0 type <integer_type 0x200001ba000 long int>

                    arg 0 <nop_expr 0x200003dd780 type <integer_type 0x200001ba000 long int>

                        arg 0 <addr_expr 0x200003dd6c0 type <pointer_type 0x20001a69e70>
                            arg 0 <placeholder_expr 0x20001a05700>>>>
                arg 1 <integer_cst 0x200001aeb40 constant invariant 15>>
            bit offset <integer_cst 0x200001c6120 constant invariant visited 0> context <record_type 0x20001a69c60 gnat__altivec__vector_views__vsc_view____ALIGN>>
        Ada size <max_expr 0x2000061bea0 type <integer_type 0x200001ba0b0 bit_size_type>

            arg 0 <plus_expr 0x2000061be58 type <integer_type 0x200001ba0b0 bit_size_type>

                arg 0 <mult_expr 0x2000061be10 type <integer_type 0x200001ba0b0 bit_size_type>

                    arg 0 <bit_and_expr 0x2000061bc60 type <integer_type 0x200001ba0b0 bit_size_type>

                        arg 0 <nop_expr 0x200003dd840 type <integer_type 0x200001ba0b0 bit_size_type>
                            arg 0 <negate_expr 0x200003dd7c0>>
                        arg 1 <integer_cst 0x200001ae570 constant invariant visited 15>>
                    arg 1 <integer_cst 0x200001ae4e0 constant invariant 8>> arg 1 <integer_cst 0x200001aedb0 128>> arg 1 <integer_cst 0x200001c6120 0>>
        pointer_to_this <pointer_type 0x20001a69e70> chain <type_decl 0x20001a7f820 D.7885>>
    addressable used BLK file g-alleve.adb line 1975 size <integer_cst 0x200001c6060 256> unit size <integer_cst 0x200001ae3c0 32>
    align 64 context <function_decl 0x20000248100 gnat__altivec__low_level_vectors__abs_v16qi>
    (mem/s/c:BLK (plus:DI (reg/f:DI 39 virtual-stack-vars)
        (const_int -104 [0xffffffffffffff98])) [0 gnat__altivec__low_level_vectors__abs_v16qi__va___ALIGN+0 S32 A64]) chain <var_decl 0x2000061d0b0 va>>



(gdb) call debug_tree (exp)
 <var_decl 0x2000061dc60 D.7902
    type <record_type 0x20001a69420 gnat__altivec__vector_views__vsc_view sizes-gimplified visited TI
        size <integer_cst 0x200001aedb0 constant invariant visited 128>
        unit size <integer_cst 0x200001aede0 constant invariant visited 16>
        align 128 symtab 0 alias set -1
        fields <field_decl 0x200005de7e8 values type <record_type 0x20001a69630 gnat__altivec__vector_views__varray_signed_char___PAD>
            TI file g-alvevi.ads line 68 size <integer_cst 0x200001aedb0 128> unit size <integer_cst 0x200001aede0 16>
            align 128 offset_align 64
            offset <integer_cst 0x200001ae420 constant invariant visited 0>
            bit offset <integer_cst 0x200001c6120 constant invariant visited 0> context <record_type 0x20001a69420 gnat__altivec__vector_views__vsc_view>> Ada size <integer_cst 0x200001aedb0 128>
        pointer_to_this <pointer_type 0x20001a69a50> reference_to_this <reference_type 0x20001a699a0> chain <type_decl 0x20000455270 D.7877>>
    used ignored TI file g-alleve.adb line 1975 size <integer_cst 0x200001aedb0 128> unit size <integer_cst 0x200001aede0 16>
    align 128 context <function_decl 0x20000248100 gnat__altivec__low_level_vectors__abs_v16qi>
    (reg:TI 70 [ D.7902 ]) chain <var_decl 0x2000061dd10 gnat__altivec__low_level_vectors__abs_v16qi__va___ALIGN.523>>

Is this supposed to work this way?
Comment 1 Eric Botcazou 2006-02-04 08:38:33 UTC
Confirmed with a cross.
Comment 2 Eric Botcazou 2006-02-04 08:44:29 UTC
> Is this supposed to work this way?

No, of course, the tree is broken from the very beginning.  The problem shows up only on s390x because it features a low BIGGEST_ALIGNMENT for a 64-bit target.

Could you try the following fix?

Index: decl.c
===================================================================
--- decl.c      (revision 110584)
+++ decl.c      (working copy)
@@ -1058,7 +1058,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entit

            gnu_new_var
              = create_var_decl (create_concat_name (gnat_entity, "ALIGN"),
-                                NULL_TREE, gnu_new_type, gnu_expr, false,
+                                NULL_TREE, gnu_new_type, NULL_TREE, false,
                                 false, false, false, NULL, gnat_entity);

            if (gnu_expr)
Comment 3 Ulrich Weigand 2006-02-04 19:11:20 UTC
(In reply to comment #2)
> Could you try the following fix?

Yes, this fixes the problem.  Bootstrap and regression test passes
on s390x-ibm-linux (and s390-ibm-linux) with this fix.

The following test case failures remain:
s390-ibm-linux:
FAIL:   c32001e
FAIL:   c64105b
FAIL:   c95086b
FAIL:   ce3107b
FAIL:   ce3810b

s390x-ibm-linux:
FAIL:   c32001e
FAIL:   c64105b
FAIL:   c95086b
FAIL:   cdd2a01
FAIL:   cdd2a02
Comment 4 Eric Botcazou 2006-02-04 19:42:05 UTC
> Yes, this fixes the problem.  Bootstrap and regression test passes
> on s390x-ibm-linux (and s390-ibm-linux) with this fix.

Great.  I've successfully tested it on x86_64-suse-linux.

> The following test case failures remain:
> s390-ibm-linux:
> FAIL:   c32001e
> FAIL:   c64105b
> FAIL:   c95086b
> FAIL:   ce3107b
> FAIL:   ce3810b
> 
> s390x-ibm-linux:
> FAIL:   c32001e
> FAIL:   c64105b
> FAIL:   c95086b
> FAIL:   cdd2a01
> FAIL:   cdd2a02

Thanks.  ce3107b is new to me but all the others are fully understood.
Comment 5 Ulrich Weigand 2006-02-04 20:16:59 UTC
(In reply to comment #4)

> Thanks.  ce3107b is new to me but all the others are fully understood.

It looks like ce3107b is one of those spurious failures I'm getting from
time to time -- I've never quite understood what's going on here, but it
looks like a test suite issue:


==== CE3107A PASSED ============================.
PASS:   ce3107a
splitting /home/uweigand/fsf/gcc-head-build/gcc/testsuite/ada/acats/tests/ce/ce3107b.ada into:
   ce3107b.adb
BUILD
FAIL:   ce3107b
splitting /home/uweigand/fsf/gcc-head-build/gcc/testsuite/ada/acats/tests/ce/ce3108a.ada into:
   ce3108a.adb
BUILD ce3108a.adb
gnatmake --GCC="/home/uweigand/fsf/gcc-head-build/gcc/xgcc -B/home/uweigand/fsf/gcc-head-build/gcc/" -gnatws -O2 -I/home/uweigand/fsf/gcc-head-build/gcc/testsuite/ada/acats/support ce3108a.adb -largs --GCC="/home/uweigand/fsf/gcc-head-build/gcc/xgcc -B/home/uweigand/fsf/gcc-head-build/gcc/"
Comment 6 Eric Botcazou 2006-02-04 20:27:41 UTC
> It looks like ce3107b is one of those spurious failures I'm getting from
> time to time -- I've never quite understood what's going on here, but it
> looks like a test suite issue:

Indeed, I run into that from time to time too.
Comment 7 Laurent GUERBY 2006-02-04 20:34:20 UTC
I dont't remember having seen this one (ce3107b) fail. I see some random test failing with run not finding the exe after gnatmake exits successfully, I've always assumed this was a timing problem within the Linux kernel.
Comment 8 Ulrich Weigand 2006-02-08 21:44:05 UTC
The spurious failures are always in different test cases for me as well ...

In fact, I now did a re-test and only see the four well-understood failures:
FAIL:   c32001e
FAIL:   c64105b
FAIL:   c95086b
FAIL:   ce3810b

Will you be committing the patch, or is this not the proper fix?
Comment 9 Eric Botcazou 2006-02-08 22:05:00 UTC
> In fact, I now did a re-test and only see the four well-understood failures:
> FAIL:   c32001e
> FAIL:   c64105b
> FAIL:   c95086b
> FAIL:   ce3810b

The first 3 are so well-understood as to be fixed on my machine. :-)  We are working on the 4th.

> Will you be committing the patch, or is this not the proper fix?

It's the fix.  Sorry for the delay in applying it, we've been a bit busy lately.
Comment 10 Ulrich Weigand 2006-02-08 22:36:13 UTC
(In reply to comment #9)
> The first 3 are so well-understood as to be fixed on my machine. :-)  We are
> working on the 4th.

Excellent!

> > Will you be committing the patch, or is this not the proper fix?
> 
> It's the fix.  Sorry for the delay in applying it, we've been a bit busy
> lately.

No problem -- thanks a lot for providing the fix so quickly!
Comment 11 Arnaud Charlet 2006-02-15 09:31:48 UTC
Subject: Bug 26096

Author: charlet
Date: Wed Feb 15 09:31:40 2006
New Revision: 111030

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=111030
Log:
2006-02-13  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>
	    Olivier Hainque  <hainque@adacore.com>
	    Eric Botcazou  <ebotcazou@adacore.com>

	* ada-tree.h: (TYPE_UNCHECKED_UNION_P): Deleted.
	
	* gigi.h (value_factor_p): Add prototype and description, now public.

	* decl.c (gnat_to_gnu_field): Don't attempt BLKmode to integral type
	promotion for field with rep clause if the associated size was proven
	to be in error.
	Expand comments describing attempts to use a packable type.
	(gnat_to_gnu_entity) <E_Signed_Integer_Subtype,
	E_Floating_Point_Subtype>: Inherit alias set of what we are making a
	subtype of to ensure conflicts amongst all subtypes in a hierarchy,
	necessary since these are not different types and pointers may
	actually designate any subtype in this hierarchy.
	(gnat_to_gnu_entity, case E_Record_Type): Always make fields for
	discriminants but put them into record only if not Unchecked_Union;
	pass flag to components_to_record showing Unchecked_Union.
	(make_dummy_type): Use UNION_TYPE only if Unchecked_Union and no
	components before variants; don't set TYPE_UNCHECKED_UNION_P.
	(components_to_record): New argument UNCHECKED_UNION.
	Remove special case code for Unchecked_Union and instead use main code
	with small changes.

	PR ada/26096
	(gnat_to_gnu_entity) <E_Variable>: Do not initialize the
	aligning variable with the expression being built, only its inner
	field.

	* trans.c (Handled_Sequence_Of_Statements_to_gnu): Remove call to
	emit_sequence_entry_statements.
	(emit_sequence_entry_statements, body_with_handlers_p): Delete.
	(establish_gnat_vms_condition_handler): Move before
	Subprogram_Body_to_gnu.
	(Subprogram_Body_to_gnu): On VMS, establish_gnat_vms_condition_handler
	for a subprogram if it has a foreign convention or is exported.
	(Identifier_to_gnu): Manually unshare the DECL_INITIAL tree when it is
	substituted for a CONST_DECL.
	(tree_transform, case N_Aggregate): Remove code for UNION_TYPE and pass
	Etype to assoc_to_constructor.
	(assoc_to_constructor): New argument, GNAT_ENTITY; use it to ignore
	discriminants of Unchecked_Union.
	(TARGET_ABI_OPEN_VMS): Define to 0 if not defined, so that later uses
	don't need cluttering preprocessor directives.
	(establish_gnat_vms_condition_handler): New function. Establish the GNAT
	condition handler as current in the compiled function.
	(body_with_handlers_p): New function. Tell whether a given sequence of
	statements node is attached to a package or subprogram body and involves
	exception handlers possibly nested within inner block statements.
	(emit_sequence_entry_statements): New function, to emit special
	statements on entry of sequences when necessary. Establish GNAT
	condition handler in the proper cases for VMS.
	(Handled_Sequence_Of_Statements_to_gnu): Start block code with
	emit_sequence_entry_statements.

	* utils2.c (find_common_type): If both input types are BLKmode and
	have a constant size, use the smaller one.
	(build_simple_component_ref): Also match if FIELD and NEW_FIELD are
	the same.

	* utils.c (value_factor_p): Make public, to allow uses from other gigi
	units.
	(create_type_decl): Do not set the flag DECL_IGNORED_P for dummy types.
	(convert, case UNION_TYPE): Remove special treatment for unchecked
	unions.

	PR ada/18659
	(update_pointer_to): Update variants of pointer types to
	unconstrained arrays by attaching the list of fields of the main
	variant.


Modified:
    trunk/gcc/ada/ada-tree.h
    trunk/gcc/ada/decl.c
    trunk/gcc/ada/gigi.h
    trunk/gcc/ada/trans.c
    trunk/gcc/ada/utils.c
    trunk/gcc/ada/utils2.c

Comment 12 Arnaud Charlet 2006-02-15 10:02:25 UTC
Fixed on trunk.