This is the mail archive of the gcc-bugs@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]

[Bug fortran/68649] [6 Regression] note: code may be misoptimized unless -fno-strict-aliasing is used


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68649

--- Comment #7 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
The function is:
 <function_decl 0x7ffff6cc1380 _gfortran_reshape_r8
    type <function_type 0x7ffff6cc3930
        type <void_type 0x7ffff6af0150 void VOID
            align 8 symtab 0 alias set -1 structural equality
            pointer_to_this <pointer_type 0x7ffff6af02a0>>
        QI
        size <integer_cst 0x7ffff6ad7ca8 constant 8>
        unit size <integer_cst 0x7ffff6ad7cc0 constant 1>
        align 8 symtab 0 alias set -1 structural equality
        attributes <tree_list 0x7ffff6cc2140
            purpose <identifier_node 0x7ffff6b09a78 fn spec>
            value <tree_list 0x7ffff6cc2118
                value <string_cst 0x7ffff6cb72e0 constant ".wrrrr">>>
        arg-types <tree_list 0x7ffff6cc2258 value <reference_type
0x7ffff6cc3888>
            chain <tree_list 0x7ffff6cbcf28 value <reference_type
0x7ffff6cbfe70>
                chain <tree_list 0x7ffff6cbcf00 value <reference_type
0x7ffff6cbfd20>
                    chain <tree_list 0x7ffff6cbced8 value <pointer_type
0x7ffff6af0738>
                        chain <tree_list 0x7ffff6cbceb0 value <pointer_type
0x7ffff6cbaf18> chain <tree_list 0x7ffff6ae99b0>>>>>>
        pointer_to_this <pointer_type 0x7ffff6cc79d8>>
    addressable public external QI file a.f90 line 3 col 0 align 8 context
<translation_unit_decl 0x7ffff6ae1168 D.3880>>

Second decl is:
 <function_decl 0x7ffff6cc12a0 _gfortran_reshape_r8
    type <function_type 0x7ffff6cc3498
        type <void_type 0x7ffff6af0150 void VOID
            align 8 symtab 0 alias set -1 structural equality
            pointer_to_this <pointer_type 0x7ffff6af02a0>>
        QI
        size <integer_cst 0x7ffff6ad7ca8 constant 8>
        unit size <integer_cst 0x7ffff6ad7cc0 constant 1>
        align 8 symtab 0 alias set -1 structural equality
        attributes <tree_list 0x7ffff6cc2140
            purpose <identifier_node 0x7ffff6b09a78 fn spec>
            value <tree_list 0x7ffff6cc2118
                value <string_cst 0x7ffff6cb72e0 constant ".wrrrr">>>
        arg-types <tree_list 0x7ffff6cc20f0 value <reference_type
0x7ffff6cc33f0>
            chain <tree_list 0x7ffff6cbcf28 value <reference_type
0x7ffff6cbfe70>
                chain <tree_list 0x7ffff6cbcf00 value <reference_type
0x7ffff6cbfd20>
                    chain <tree_list 0x7ffff6cbced8 value <pointer_type
0x7ffff6af0738>
                        chain <tree_list 0x7ffff6cbceb0 value <pointer_type
0x7ffff6cbaf18> chain <tree_list 0x7ffff6ae99b0>>>>>>
        pointer_to_this <pointer_type 0x7ffff6cc7d20>>
    addressable public external QI file a.f90 line 4 col 0 align 8 context
<translation_unit_decl 0x7ffff6ae1168 D.3880>>


The reason is that the declaration is duplicated (that by itself is a bug
violating one-decl rule) and we warn because reference type 0x7ffff6cc3888 is
not compatible with reference type 0x7ffff6cc33f0. They point to different type
of structure:

 <reference_type 0x7ffff6cc3888
    type <record_type 0x7ffff6cc37e0 array1_real(kind=8) BLK
        size <integer_cst 0x7ffff6cabd08 constant 384>
        unit size <integer_cst 0x7ffff6cabd98 constant 48>
        align 64 symtab 0 alias set -1 canonical type 0x7ffff6cc3690
        fields <field_decl 0x7ffff6cbebe0 data type <pointer_type
0x7ffff6cbff18>
            unsigned DI file a.f90 line 3 col 0
            size <integer_cst 0x7ffff6ad7bb8 constant 64>
            unit size <integer_cst 0x7ffff6ad7bd0 constant 8>
            align 64 offset_align 128
            offset <integer_cst 0x7ffff6ad7be8 constant 0>
            bit offset <integer_cst 0x7ffff6ad7c30 constant 0> context
<record_type 0x7ffff6cc3690 array_descriptor1> chain <field_decl 0x7ffff6cbeb48
offset>>
        reference_to_this <reference_type 0x7ffff6cc3888> chain <type_decl
0x7ffff6cc4000 D.3909>>
    unsigned DI size <integer_cst 0x7ffff6ad7bb8 64> unit size <integer_cst
0x7ffff6ad7bd0 8>
    align 64 symtab 0 alias set 6 structural equality>

compared to:

 <reference_type 0x7ffff6cc33f0
    type <record_type 0x7ffff6cc3348 array2_real(kind=8) BLK
        size <integer_cst 0x7ffff6cabdb0 constant 576>
        unit size <integer_cst 0x7ffff6cabde0 constant 72>
        align 64 symtab 0 alias set -1 canonical type 0x7ffff6cc31f8
        fields <field_decl 0x7ffff6cbe558 data type <pointer_type
0x7ffff6cbff18>
            unsigned DI file a.f90 line 4 col 0
            size <integer_cst 0x7ffff6ad7bb8 constant 64>
            unit size <integer_cst 0x7ffff6ad7bd0 constant 8>
            align 64 offset_align 128
            offset <integer_cst 0x7ffff6ad7be8 constant 0>
            bit offset <integer_cst 0x7ffff6ad7c30 constant 0> context
<record_type 0x7ffff6cc31f8 array_descriptor2> chain <field_decl 0x7ffff6cbe4c0
offset>>
        reference_to_this <reference_type 0x7ffff6cc33f0> chain <type_decl
0x7ffff6cbe980 D.3898>>
    unsigned DI size <integer_cst 0x7ffff6ad7bb8 64> unit size <integer_cst
0x7ffff6ad7bd0 8>
    align 64 symtab 0 alias set 7 structural equality>

Notice the difference in size of the records.
This will indeed make TBAA code to believe that those two pointers are not
compatible. In libgfortran there is 
void
reshape_r8 (gfc_array_r8 * const restrict ret, 
        gfc_array_r8 * const restrict source, 
        shape_type * const restrict shape,
        gfc_array_r8 * const restrict pad, 
        shape_type * const restrict order)

ideally the fortran-fe produced declaration of reshape_r8 should be just one
per unit and interoperable with the declaration above that is pointer to:
#define GFC_ARRAY_DESCRIPTOR(r, type) \
struct {\
  type *base_addr;\
  size_t offset;\
  index_type dtype;\
  descriptor_dimension dim[r];\
}

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