On Fri, Jul 11, 2008 at 8:17 PM, Eric Botcazou <[EMAIL PROTECTED]> wrote:
>> For static storage yes, which it seems to test:
>>
>>       else if (TREE_CODE (rhs) == VAR_DECL
>>                && TREE_STATIC (rhs)
>>                && TREE_READONLY (rhs)
>>                && targetm.binds_local_p (rhs))
>>         fns->init (lhs_elt, DECL_INITIAL (rhs), bsi);
>
> I think there is a problem with binds_local_p though, which explains why PR
> tree-opt/35493 has been fixed for ELF but not for PE-COFF (PR ada/36207):
> what if we have DECL_EXTERNAL, targetm.binds_local_p and no DECL_INITIAL?
> In this case, the code will replace the VAR_DECL with zero, which is wrong.
> tree-ssa-ccp.c:get_symbol_constant_value will do the same.

But it also tests TREE_STATIC which should not be true for automatic variables.
The binds_local_p check is only to guard against overriding the symbol with
an external definition.

Richard.

> For example, expand_expr_real_1 does test the non-nullity of DECL_INITIAL:
>
>        else if (optimize >= 1
>                 && modifier != EXPAND_CONST_ADDRESS
>                 && modifier != EXPAND_INITIALIZER
>                 && modifier != EXPAND_MEMORY
>                 && TREE_READONLY (array) && ! TREE_SIDE_EFFECTS (array)
>                 && TREE_CODE (array) == VAR_DECL && DECL_INITIAL (array)
>                 && TREE_CODE (DECL_INITIAL (array)) != ERROR_MARK
>                 && targetm.binds_local_p (array))
>
> Here's the hook for PE-COFF:
>
> bool
> i386_pe_binds_local_p (const_tree exp)
> {
>  /* PE does not do dynamic binding.  Indeed, the only kind of
>     non-local reference comes from a dllimport'd symbol.  */
>  if ((TREE_CODE (exp) == VAR_DECL || TREE_CODE (exp) == FUNCTION_DECL)
>      && DECL_DLLIMPORT_P (exp))
>    return false;
>
>  return true;
> }
>
> --
> Eric Botcazou
>

Reply via email to