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: refinements to definition of TREE_READONLY ?


> 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.

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


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