From bf5d4f20368d1173a8d586f6bdd258b00b807e33 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Wed, 11 Feb 2015 17:37:48 -0800 Subject: [PATCH 1/5] Replace local_p with direct returns --- gcc/varasm.c | 66 +++++++++++++++++++++++++++++++----------------------------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/gcc/varasm.c b/gcc/varasm.c index 3f62fca..83d9de3 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -6814,7 +6814,6 @@ default_binds_local_p (const_tree exp) bool default_binds_local_p_1 (const_tree exp, int shlib) { - bool local_p; bool resolved_locally = false; bool resolved_to_local_def = false; @@ -6845,54 +6844,57 @@ default_binds_local_p_1 (const_tree exp, int shlib) /* A non-decl is an entry in the constant pool. */ if (!DECL_P (exp)) - local_p = true; + return true; + /* Weakrefs may not bind locally, even though the weakref itself is always static and therefore local. Similarly, the resolver for ifunc functions might resolve to a non-local function. FIXME: We can resolve the weakref case more curefuly by looking at the weakref alias. */ - else if (lookup_attribute ("weakref", DECL_ATTRIBUTES (exp)) + if (lookup_attribute ("weakref", DECL_ATTRIBUTES (exp)) || (TREE_CODE (exp) == FUNCTION_DECL && lookup_attribute ("ifunc", DECL_ATTRIBUTES (exp)))) - local_p = false; + return false; + /* Static variables are always local. */ - else if (! TREE_PUBLIC (exp)) - local_p = true; - /* A variable is local if the user has said explicitly that it will - be. */ - else if ((DECL_VISIBILITY_SPECIFIED (exp) - || resolved_to_local_def) - && DECL_VISIBILITY (exp) != VISIBILITY_DEFAULT) - local_p = true; + if (! TREE_PUBLIC (exp)) + return true; + + /* A variable is local if the user has said explicitly that it will be. */ + if ((DECL_VISIBILITY_SPECIFIED (exp) || resolved_to_local_def) + && DECL_VISIBILITY (exp) != VISIBILITY_DEFAULT) + return true; + /* Variables defined outside this object might not be local. */ - else if (DECL_EXTERNAL (exp) && !resolved_locally) - local_p = false; - /* If defined in this object and visibility is not default, must be - local. */ - else if (DECL_VISIBILITY (exp) != VISIBILITY_DEFAULT) - local_p = true; + if (DECL_EXTERNAL (exp) && !resolved_locally) + return false; + + /* If defined in this object and visibility is not default, + must be local. */ + if (DECL_VISIBILITY (exp) != VISIBILITY_DEFAULT) + return true; + /* Default visibility weak data can be overridden by a strong symbol in another module and so are not local. */ - else if (DECL_WEAK (exp) - && !resolved_locally) - local_p = false; + if (DECL_WEAK (exp) && !resolved_locally) + return false; + /* If PIC, then assume that any global name can be overridden by symbols resolved from other modules. */ - else if (shlib) - local_p = false; + if (shlib) + return false; + /* Uninitialized COMMON variable may be unified with symbols resolved from other modules. */ - else if (DECL_COMMON (exp) - && !resolved_locally - && (DECL_INITIAL (exp) == NULL - || (!in_lto_p && DECL_INITIAL (exp) == error_mark_node))) - local_p = false; + if (DECL_COMMON (exp) + && !resolved_locally + && (DECL_INITIAL (exp) == NULL + || (!in_lto_p && DECL_INITIAL (exp) == error_mark_node))) + return false; + /* Otherwise we're left with initialized (or non-common) global data which is of necessity defined locally. */ - else - local_p = true; - - return local_p; + return true; } /* Return true when references to DECL must bind to current definition in -- 2.1.0