Alias tweaks
Richard Kenner
kenner@vlsi1.ultra.nyu.edu
Thu Jun 1 09:21:00 GMT 2000
This is in response to some of the issues raised on this list plus
a desire to eliminate unnecessary calls:
Thu Jun 1 12:24:21 2000 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
* alias.c (get_alias_set): Don't call language-specific routine more
than is needed and clean up code a bit.
* c-common.c (c_get_alias_set): All references whose type
is char get alias set 0, but character types need not.
* varasm.c (make_function_rtl): Don't call set_mem_attributes.
(make_decl_rtl): Don't call it for FUNCTION_DECL.
*** alias.c 2000/05/31 18:36:02 1.83
--- alias.c 2000/06/01 16:09:24
*************** get_alias_set (t)
*** 339,342 ****
--- 339,343 ----
tree t;
{
+ tree orig_t;
HOST_WIDE_INT set;
HOST_WIDE_INT bitsize, bitpos;
*************** get_alias_set (t)
*** 358,400 ****
each other to figure out what to do. At each juncture, we see if
this is a tree that the language may need to handle specially.
! But first remove nops since we care only about the actual object. */
! while (TREE_CODE (t) == NOP_EXPR || TREE_CODE (t) == CONVERT_EXPR
! || TREE_CODE (t) == NON_LVALUE_EXPR)
! t = TREE_OPERAND (t, 0);
!
! /* Now give the language a chance to do something. */
! if (lang_get_alias_set != 0
! && (set = (*lang_get_alias_set) (t)) != -1)
! return set;
!
! /* If this is a reference, go inside it and use the underlying object. */
! if (TREE_CODE_CLASS (TREE_CODE (t)) == 'r')
! t = get_inner_reference (t, &bitsize, &bitpos, &offset, &mode,
! &unsignedp, &volatilep, &alignment);
!
! if (TREE_CODE (t) == INDIRECT_REF)
{
! /* Check for accesses through restrict-qualified pointers. */
! tree decl = find_base_decl (TREE_OPERAND (t, 0));
! if (decl && DECL_POINTER_ALIAS_SET_KNOWN_P (decl))
! /* We use the alias set indicated in the declaration. */
! return DECL_POINTER_ALIAS_SET (decl);
!
! /* If we have an INDIRECT_REF via a void pointer, we don't know anything
! about what that might alias. */
! if (TREE_CODE (TREE_TYPE (t)) == VOID_TYPE)
! return 0;
}
-
- /* Give the language another chance to do something special. */
- if (lang_get_alias_set != 0
- && (set = (*lang_get_alias_set) (t)) != -1)
- return set;
-
- /* Now we are done with expressions, so get the type if this isn't
- a type. */
- if (! TYPE_P (t))
- t = TREE_TYPE (t);
/* Variant qualifiers don't affect the alias set, so get the main
--- 359,406 ----
each other to figure out what to do. At each juncture, we see if
this is a tree that the language may need to handle specially.
! First handle things that aren't types and start by removing nops
! since we care only about the actual object. */
! if (! TYPE_P (t))
{
! while (TREE_CODE (t) == NOP_EXPR || TREE_CODE (t) == CONVERT_EXPR
! || TREE_CODE (t) == NON_LVALUE_EXPR)
! t = TREE_OPERAND (t, 0);
!
! /* Now give the language a chance to do something but record what we
! gave it this time. */
! orig_t = t;
! if (lang_get_alias_set != 0
! && (set = (*lang_get_alias_set) (t)) != -1)
! return set;
!
! /* If this is a reference, go inside it and use the underlying
! object. */
! if (TREE_CODE_CLASS (TREE_CODE (t)) == 'r')
! t = get_inner_reference (t, &bitsize, &bitpos, &offset, &mode,
! &unsignedp, &volatilep, &alignment);
!
! if (TREE_CODE (t) == INDIRECT_REF)
! {
! /* Check for accesses through restrict-qualified pointers. */
! tree decl = find_base_decl (TREE_OPERAND (t, 0));
!
! if (decl && DECL_POINTER_ALIAS_SET_KNOWN_P (decl))
! /* We use the alias set indicated in the declaration. */
! return DECL_POINTER_ALIAS_SET (decl);
!
! /* If we have an INDIRECT_REF via a void pointer, we don't
! know anything about what that might alias. */
! if (TREE_CODE (TREE_TYPE (t)) == VOID_TYPE)
! return 0;
! }
!
! /* Give the language another chance to do something special. */
! if (orig_t != t && lang_get_alias_set != 0
! && (set = (*lang_get_alias_set) (t)) != -1)
! return set;
! /* Now all we care about is the type. */
! t = TREE_TYPE (t);
}
/* Variant qualifiers don't affect the alias set, so get the main
*** c-common.c 2000/05/31 18:36:02 1.112
--- c-common.c 2000/06/01 16:09:38
*************** c_get_alias_set (t)
*** 3285,3293 ****
/* If this is a char *, the ANSI C standard says it can alias
! anything. */
! else if (TREE_CODE (t) == INDIRECT_REF
! && TREE_CODE (TREE_TYPE (TREE_OPERAND (t, 0))) == INTEGER_TYPE
! && (TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (t, 0)))
! == TYPE_PRECISION (char_type_node)))
return 0;
--- 3285,3292 ----
/* If this is a char *, the ANSI C standard says it can alias
! anything. Note that all references need do this. */
! if (TREE_CODE_CLASS (TREE_CODE (t)) == 'r'
! && TREE_CODE (TREE_TYPE (t)) == INTEGER_TYPE
! && TYPE_PRECISION (TREE_TYPE (t)) == TYPE_PRECISION (char_type_node))
return 0;
*************** c_get_alias_set (t)
*** 3296,3315 ****
return -1;
! if (TREE_CODE (t) == INTEGER_TYPE)
! {
! /* The C standard specifically allows aliasing between signed and
! unsigned variants of the same type. We treat the signed
! variant as canonical. */
! tree signed_variant = signed_type (t);
- if (signed_variant == signed_char_type_node)
- /* The C standard guarantess that any object may be accessed
- via an lvalue that has character type. We don't have to
- check for unsigned_char_type_node or char_type_node because
- we are specifically looking at the signed variant. */
- return 0;
- else if (signed_variant != t)
- return get_alias_set (signed_variant);
- }
else if (POINTER_TYPE_P (t))
{
--- 3295,3304 ----
return -1;
! /* The C standard specifically allows aliasing between signed and
! unsigned variants of the same type. We treat the signed
! variant as canonical. */
! if (TREE_CODE (t) == INTEGER_TYPE && TREE_UNSIGNED (t))
! return get_alias_set (signed_type (t));
else if (POINTER_TYPE_P (t))
{
*** varasm.c 2000/06/01 01:12:19 1.122
--- varasm.c 2000/06/01 16:09:52
*************** make_function_rtl (decl)
*** 560,564 ****
= gen_rtx_MEM (DECL_MODE (decl),
gen_rtx_SYMBOL_REF (Pmode, name));
- set_mem_attributes (DECL_RTL (decl), decl, 1);
/* Optionally set flags or add text to the name to record
--- 560,563 ----
*************** make_decl_rtl (decl, asmspec, top_level)
*** 813,817 ****
DECL_RTL (decl) = gen_rtx_MEM (DECL_MODE (decl),
gen_rtx_SYMBOL_REF (Pmode, name));
! set_mem_attributes (DECL_RTL (decl), decl, 1);
/* Optionally set flags or add text to the name to record information
--- 812,817 ----
DECL_RTL (decl) = gen_rtx_MEM (DECL_MODE (decl),
gen_rtx_SYMBOL_REF (Pmode, name));
! if (TREE_CODE (decl) != FUNCTION_DECL)
! set_mem_attributes (DECL_RTL (decl), decl, 1);
/* Optionally set flags or add text to the name to record information
More information about the Gcc-patches
mailing list