From f824e5c36eea7d0a9a5b9a5147751278de4778c0 Mon Sep 17 00:00:00 2001 From: Richard Kenner Date: Thu, 1 Jun 2000 16:18:18 +0000 Subject: [PATCH] alias.c (get_alias_set): Don't call language-specific routine more than is needed and clean up code a bit. * 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. From-SVN: r34341 --- gcc/ChangeLog | 9 ++++++ gcc/alias.c | 74 +++++++++++++++++++++++++++----------------------- gcc/c-common.c | 31 +++++++-------------- gcc/varasm.c | 4 +-- 4 files changed, 61 insertions(+), 57 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 56530bb7ffd..3959db26df3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +Thu Jun 1 12:24:21 2000 Richard Kenner + + * 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. + 2000-06-01 Bruce Korb * fixinc/tests/base/...: new base result files diff --git a/gcc/alias.c b/gcc/alias.c index feed5415ad8..4541d519858 100644 --- a/gcc/alias.c +++ b/gcc/alias.c @@ -338,6 +338,7 @@ HOST_WIDE_INT get_alias_set (t) tree t; { + tree orig_t; HOST_WIDE_INT set; HOST_WIDE_INT bitsize, bitpos; tree offset; @@ -357,45 +358,50 @@ get_alias_set (t) language-specific routine may make mutually-recursive calls to 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) + First handle things that aren't types and start by removing nops + since we care only about the actual object. */ + if (! TYPE_P (t)) { - /* Check for accesses through restrict-qualified pointers. */ - tree decl = find_base_decl (TREE_OPERAND (t, 0)); + 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 (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; - } + /* 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; + /* 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 we are done with expressions, so get the type if this isn't - a type. */ - if (! TYPE_P (t)) - t = TREE_TYPE (t); + /* Now all we care about is the type. */ + t = TREE_TYPE (t); + } /* Variant qualifiers don't affect the alias set, so get the main variant. If this is a type with a known alias set, return it. */ diff --git a/gcc/c-common.c b/gcc/c-common.c index 5cc34c960a1..0ba68733118 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -3284,33 +3284,22 @@ c_get_alias_set (t) return 0; /* 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))) + 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; /* That's all the expressions we handle specially. */ if (! TYPE_P (t)) 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); - } + /* 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)) { tree t1; diff --git a/gcc/varasm.c b/gcc/varasm.c index 04937370c90..75af9466530 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -559,7 +559,6 @@ make_function_rtl (decl) 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 such as that it is a function name. If the name @@ -812,7 +811,8 @@ make_decl_rtl (decl, asmspec, top_level) = get_identifier (name[0] == '*' ? name + 1 : name); DECL_RTL (decl) = gen_rtx_MEM (DECL_MODE (decl), gen_rtx_SYMBOL_REF (Pmode, name)); - set_mem_attributes (DECL_RTL (decl), decl, 1); + 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 such as that it is a function name. -- 2.30.2