[fortran] Set TREE_STATIC flag on static initializers

H.J. Lu hjl.tools@gmail.com
Fri Sep 10 14:38:00 GMT 2010


On Fri, Sep 10, 2010 at 6:20 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> 2010/9/8 Jan Hubicka <hubicka@ucw.cz>:
>>> On Sat, Sep 4, 2010 at 4:18 PM, Jan Hubicka <hubicka@ucw.cz> wrote:
>>> > Hi,
>>> > fortran, unlike all other frontends, does not set TREE_STATIC flag on static
>>> > initializers.  This prevents us from folding till the cfgexpand time.  To be honest,
>>> > I am not quite sure why we insist on the flag (I guess we should assert that all statics
>>> > are initializerd with static initializer or ignore it), but this patch brings gfortran
>>> > into sync with others.
>>> >
>>> > Bootstrapped/regtested x86_64-linux, OK?
>>> >
>>> > Honza
>>> >
>>> >        * trans-expr.c (gfc_conv_initializer): Set TREE_STATIC on static ctors.
>>>
>>> This caused:
>>>
>>> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45598
>>
>> It was previously latent.  I am testing fix for that.
>>
>
> Revision 164111:
>
> http://gcc.gnu.org/ml/gcc-cvs/2010-09/msg00403.html

Jan, shouldn't

      /* Fold read from constant string.  */
      if (TREE_CODE (ctor) == STRING_CST)
        {
          if ((TYPE_MODE (TREE_TYPE (t))
               == TYPE_MODE (TREE_TYPE (TREE_TYPE (ctor))))
              && (GET_MODE_CLASS (TYPE_MODE (TREE_TYPE (TREE_TYPE (ctor))))
                  == MODE_INT)
              && GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (TREE_TYPE (ctor)))) == 1
              && compare_tree_int (idx, TREE_STRING_LENGTH (ctor)) < 0)
            return build_int_cst_type (TREE_TYPE (t),
                                       (TREE_STRING_POINTER (ctor)
                                        [TREE_INT_CST_LOW (idx)]));
          return NULL_TREE;
        }


in tree-ssa-ccp.c need a similar fix?


-- 
H.J.



More information about the Gcc-patches mailing list