This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Gimplilfy ICE in gnat.dg/array18.adb


Hi,


The patch modifies gcc/ada/gcc-interface/trans.c that way :

   /* First, create the temporary for the return value if we need it: for a
-     variable-sized return type if there is no target or if this is slice,
-     because the gimplifier doesn't support these cases; or for a function
-     with copy-in/copy-out parameters if there is no target, because we'll
-     need to preserve the return value before copying back the parameters.
-     This must be done before we push a new binding level around the call
-     as we will pop it before copying the return value.  */
+     variable-sized return type if there is no target and this is not an
+     object declaration, or else there is a target and it is a slice or an
+     array with fixed size, as the gimplifier doesn't handle these cases;
+     otherwise for a function with copy-in/copy-out parameters if there is
+     no target, because we need to preserve the return value before copying
+     back the parameters.  This must be done before we push a binding level
+     around the call as we will pop it before copying the return value.  */
   if (function_call
       && ((TREE_CODE (TYPE_SIZE (gnu_result_type)) != INTEGER_CST
-          && (!gnu_target || TREE_CODE (gnu_target) == ARRAY_RANGE_REF))
+          && ((!gnu_target
+               && Nkind (Parent (gnat_node)) != N_Object_Declaration)
+              || (gnu_target
+                  && (TREE_CODE (gnu_target) == ARRAY_RANGE_REF
+                      || (TREE_CODE (TREE_TYPE (gnu_target)) == ARRAY_TYPE
+                          && TREE_CODE (TYPE_SIZE (TREE_TYPE (gnu_target)))
+                             == INTEGER_CST)))))
          || (!gnu_target && TYPE_CI_CO_LIST (gnu_subprog_type))))



So I gdb to compared the tree  'gnu_target' and 'gnu_result_type' in my port and in x86_64 port.

X86_64 gnu_target:
<var_decl 0x2ad27c795460 a
    type <array_type 0x2ad27c8cae70 array18__TaS
        type <integer_type 0x2ad27c79a348 character sizes-gimplified public visited unsigned string-flag QI
            size <integer_cst 0x2ad27c79c080 constant visited 8>
            unit size <integer_cst 0x2ad27c79c0a0 constant visited 1>
            align 8 symtab 0 alias set -1 canonical type 0x2ad27c79a348 precision 8 min <integer_cst 0x2ad27c79c0c0 0> max <integer_cst 0x2ad27c79c040 255> context <translation_unit_decl 0x2ad27c7a4228 D.22>
            pointer_to_this <pointer_type 0x2ad27c7abe70 access_character>>
        nonaliased-component QI size <integer_cst 0x2ad27c79c080 8> unit size <integer_cst 0x2ad27c79c0a0 1>
        align 8 symtab 0 alias set 0 canonical type 0x2ad27c8cae70
        domain <integer_type 0x2ad27c8cadc8 type <integer_type 0x2ad27c79a000 sizetype>
            DI
            size <integer_cst 0x2ad27c789ec0 constant visited 64>
            unit size <integer_cst 0x2ad27c789ee0 constant visited 8>
            align 64 symtab 0 alias set -1 canonical type 0x2ad27c8cadc8 precision 64 min <integer_cst 0x2ad27c79c0a0 1> max <integer_cst 0x2ad27c79c0a0 1> index type <integer_type 0x2ad27c8cad20 array18__TTaSP1___XDLU_1__1>
            chain <type_decl 0x2ad27c8ed0b8 D.2402>> context <function_decl 0x2ad27c8ec300 array18>
        chain <type_decl 0x2ad27c8ed170 array18__TaS>>
    QI file array18.adb line 7 col 4 size <integer_cst 0x2ad27c79c080 8> unit size <integer_cst 0x2ad27c79c0a0 1>
    align 8 context <function_decl 0x2ad27c8ec300 array18> chain <type_decl 0x2ad27c8ed170 array18__TaS>>

My gnu_target:
<var_decl 0x2add91a1b460 a
    type <record_type 0x2add91ace930 array18__a___PAD type_5 SI
        size <integer_cst 0x2add91a1a420 constant visited 32>
        unit size <integer_cst 0x2add91a1a440 constant visited 4>
        align 32 symtab 0 alias set -1 canonical type 0x2add91ace930
        fields <field_decl 0x2add91a358e8 F type <array_type 0x2add91ace888 array18__TaS>
            decl_3 QI file array18.adb line 7 col 4
            size <integer_cst 0x2add91a1a620 constant visited 8>
            unit size <integer_cst 0x2add91a1a640 constant visited 1>
            align 8 offset_align 64
            offset <integer_cst 0x2add91a1a460 constant visited 0>
            bit offset <integer_cst 0x2add91a1a500 constant 0> context <record_type 0x2add91ace930 array18__a___PAD>> context <function_decl 0x2add91aee700 array18> Ada size <integer_cst 0x2add91a1a620 8>
        chain <type_decl 0x2add91aef170 array18__a___PAD>>
    SI file array18.adb line 7 col 4 size <integer_cst 0x2add91a1a420 32> unit size <integer_cst 0x2add91a1a440 4>
    align 32 context <function_decl 0x2add91aee700 array18> chain <type_decl 0x2add91aef170 array18__a___PAD>>

strangely my var_decl for 'a' is a record and not an array_type so the 'if' condition is false (and true on X86_64)....
I looked for somewhere in my backend something that would transform an array_type into a record_type but I did not find anything.



X86_64 gnu_result_type:
<array_type 0x2add91acef18 array18_pkg__s
    type <integer_type 0x2add91a1e348 character sizes-gimplified public visited unsigned string-flag QI
        size <integer_cst 0x2add91a1a620 constant visited 8>
        unit size <integer_cst 0x2add91a1a640 constant visited 1>
        align 8 symtab 0 alias set -1 canonical type 0x2add91a1e348 precision 8 min <integer_cst 0x2add91a1a660 0> max <integer_cst 0x2add91a1a5e0 255> context <translation_unit_decl 0x2add91a27170 D.16>
        pointer_to_this <pointer_type 0x2add91a329d8 access_character>>
    sizes-gimplified visited nonaliased-component BLK
    size <mult_expr 0x2add91aec210
        type <integer_type 0x2add91a1e0a8 bitsizetype public unsigned sizetype DI
            size <integer_cst 0x2add91a1a4c0 constant visited 64>
            unit size <integer_cst 0x2add91a1a4e0 constant visited 8>
            align 64 symtab 0 alias set -1 canonical type 0x2add91a1e0a8 precision 64 min <integer_cst 0x2add91a1a500 0> max <integer_cst 0x2add91a1a520 -1>>
        readonly visited
        arg 0 <nop_expr 0x2add91aede88 type <integer_type 0x2add91a1e0a8 bitsizetype>
            readonly visited arg 0 <var_decl 0x2add91a1b500 array18_pkg__R1s>> arg 1 <integer_cst 0x2add91a1a620 8>>
    unit size <nop_expr 0x2add91aedf78
        type <integer_type 0x2add91a1e000 sizetype public unsigned sizetype SI
            size <integer_cst 0x2add91a1a420 constant visited 32>
            unit size <integer_cst 0x2add91a1a440 constant visited 4>
            align 32 symtab 0 alias set -1 canonical type 0x2add91a1e000 precision 32 min <integer_cst 0x2add91a1a460 0> max <integer_cst 0x2add91a1a480 -1>>
        readonly visited
        arg 0 <var_decl 0x2add91a1b500 array18_pkg__R1s type <integer_type 0x2add91acedc8 positive___XDLU_1__2147483647>
            readonly public visited unsigned ignored external SI file array18_pkg.ads line 5 col 30 size <integer_cst 0x2add91a1a420 32> unit size <integer_cst 0x2add91a1a440 4>
            align 32 context <translation_unit_decl 0x2add91a27170 D.16>>>
    align 8 symtab 0 alias set 0 canonical type 0x2add91acef18
    domain <integer_type 0x2add91acee70 type <integer_type 0x2add91a1e000 sizetype>
        sizes-gimplified visited SI size <integer_cst 0x2add91a1a420 32> unit size <integer_cst 0x2add91a1a440 4>
        align 32 symtab 0 alias set -1 canonical type 0x2add91acee70 precision 32 min <integer_cst 0x2add91a1a640 1> max <nop_expr 0x2add91aedd70>
        index type <integer_type 0x2add91acebd0 array18_pkg__TsP1___XDL_1 type <integer_type 0x2add91a1e5e8 integer>
            sizes-gimplified public visited unsigned SI size <integer_cst 0x2add91a1a420 32> unit size <integer_cst 0x2add91a1a440 4>
            align 32 symtab 0 alias set 0 canonical type 0x2add91acebd0 precision 32 min <integer_cst 0x2add91ad9860 0> max <integer_cst 0x2add91ad9740 4294967295> context <translation_unit_decl 0x2add91a27170 D.16> RM size <integer_cst 0x2add91a33180 31> RM min <integer_cst 0x2add91a1aa60 1> RM max <nop_expr 0x2add91aedd20>
            chain <type_decl 0x2add91aef228 array18_pkg__TsP1___XDL_1>>
        chain <type_decl 0x2add91aef2e0 D.1403>> context <translation_unit_decl 0x2add91a27170 D.16>
    chain <type_decl 0x2add91aef398 array18_pkg__s>>


My gnu_result_type:
<array_type 0x2ad27c8ee498 array18_pkg__s
    type <integer_type 0x2ad27c79a348 character sizes-gimplified public visited unsigned string-flag QI
        size <integer_cst 0x2ad27c79c080 constant visited 8>
        unit size <integer_cst 0x2ad27c79c0a0 constant visited 1>
        align 8 symtab 0 alias set -1 canonical type 0x2ad27c79a348 precision 8 min <integer_cst 0x2ad27c79c0c0 0> max <integer_cst 0x2ad27c79c040 255> context <translation_unit_decl 0x2ad27c7a4228 D.22>
        pointer_to_this <pointer_type 0x2ad27c7abe70 access_character>>
    sizes-gimplified visited nonaliased-component BLK
    size <mult_expr 0x2ad27c8e9240
        type <integer_type 0x2ad27c79a0a8 bitsizetype public unsigned sizetype DI
            size <integer_cst 0x2ad27c789ec0 constant visited 64>
            unit size <integer_cst 0x2ad27c789ee0 constant visited 8>
            align 64 symtab 0 alias set -1 canonical type 0x2ad27c79a0a8 precision 64 min <integer_cst 0x2ad27c789f60 0> max <integer_cst 0x2ad27c789f80 -1>>
        readonly visited
        arg 0 <nop_expr 0x2ad27c8ebd20 type <integer_type 0x2ad27c79a0a8 bitsizetype>
            readonly visited
            arg 0 <nop_expr 0x2ad27c8ebca8 type <integer_type 0x2ad27c79a000 sizetype>
                readonly visited
                arg 0 <nop_expr 0x2ad27c8ebc58 type <integer_type 0x2ad27c79a5e8 integer>
                    readonly visited arg 0 <var_decl 0x2ad27c795500 array18_pkg__R1s>>>> arg 1 <integer_cst 0x2ad27c79c080 8>> unit size <nop_expr 0x2ad27c8ebca8>
    align 8 symtab 0 alias set 0 canonical type 0x2ad27c8ee498
    domain <integer_type 0x2ad27c8ee3f0
        type <integer_type 0x2ad27c79a000 sizetype public unsigned sizetype DI size <integer_cst 0x2ad27c789ec0 64> unit size <integer_cst 0x2ad27c789ee0 8>
            align 64 symtab 0 alias set -1 canonical type 0x2ad27c79a000 precision 64 min <integer_cst 0x2ad27c789f00 0> max <integer_cst 0x2ad27c789f20 -1>>
        sizes-gimplified visited DI size <integer_cst 0x2ad27c789ec0 64> unit size <integer_cst 0x2ad27c789ee0 8>
        align 64 symtab 0 alias set -1 canonical type 0x2ad27c8ee3f0 precision 64 min <integer_cst 0x2ad27c79c0a0 1> max <nop_expr 0x2ad27c8ebca8>
        index type <integer_type 0x2ad27c8ee150 array18_pkg__TsP1___XDL_1 type <integer_type 0x2ad27c79a5e8 integer>
            sizes-gimplified public visited unsigned SI
            size <integer_cst 0x2ad27c79c240 constant visited 32>
            unit size <integer_cst 0x2ad27c79c260 constant visited 4>
            align 32 symtab 0 alias set 0 canonical type 0x2ad27c8ee150 precision 32 min <integer_cst 0x2ad27c8e6500 0> max <integer_cst 0x2ad27c8e63e0 4294967295> context <translation_unit_decl 0x2ad27c7a4228 D.22> RM size <integer_cst 0x2ad27c79cce0 31> RM min <integer_cst 0x2ad27c79c500 1> RM max <nop_expr 0x2ad27c8ebc58>
            chain <type_decl 0x2ad27c8ed228 array18_pkg__TsP1___XDL_1>>
        chain <type_decl 0x2ad27c8ed2e0 D.2410>> context <translation_unit_decl 0x2ad27c7a4228 D.22>
    chain <type_decl 0x2ad27c8ed398 array18_pkg__s>>

There are also differenced in the gnu_result_type I cannot explain ...





-----Message d'origine-----
De : Eric Botcazou [mailto:ebotcazou@adacore.com] 
Envoyé : vendredi 6 juin 2014 00:00
À : BELBACHIR Selim
Cc : gcc@gcc.gnu.org
Objet : Re: Gimplilfy ICE in gnat.dg/array18.adb

> Can someone give me a hint to solve my problem ? I have no idea which 
> part of my backend could be related to the GENERIC or GIMPLE 
> generation and I'm very unfamiliar with this part of GCC.

Look at the patch installed in conjunction with gnat.dg/array18.adb.

--
Eric Botcazou


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]