[RS6000] Weak functions may not be file local
authorAlan Modra <amodra@gmail.com>
Tue, 1 Sep 2015 23:03:19 +0000 (08:33 +0930)
committerAlan Modra <amodra@gcc.gnu.org>
Tue, 1 Sep 2015 23:03:19 +0000 (08:33 +0930)
A weak symbol defined in the current object file may not turn out to
be the definition used at link time, if other copies of the symbol
exist.  This means they can't be considered file local.

PR target/67417
* config/rs6000/predicates.md (current_file_function_operand): Don't
return true for weak symbols.
* config/rs6000/rs6000.c (rs6000_function_ok_for_sibcall): Likewise.

From-SVN: r227386

gcc/ChangeLog
gcc/config/rs6000/predicates.md
gcc/config/rs6000/rs6000.c

index b9e7bac3266409142f9c3b096ee09894de0006ca..ba0a8f1e27bb85f9db56cee4d5cbf300c529e83b 100644 (file)
@@ -1,3 +1,10 @@
+2015-09-02  Alan Modra  <amodra@gmail.com>
+
+       PR target/67417
+       * config/rs6000/predicates.md (current_file_function_operand): Don't
+       return true for weak symbols.
+       * config/rs6000/rs6000.c (rs6000_function_ok_for_sibcall): Likewise.
+
 2015-09-01  Matthew Fortune  <matthew.fortune@imgtec.com>
            Andrew Bennett  <andrew.bennett@imgtec.com>
 
index b111df62df887490e1b49bbc2c45d3512660ab55..3edb4774e7528622c9d5c81418d95a880a4ce3cd 100644 (file)
 (define_predicate "current_file_function_operand"
   (and (match_code "symbol_ref")
        (match_test "(DEFAULT_ABI != ABI_AIX || SYMBOL_REF_FUNCTION_P (op))
-                   && ((SYMBOL_REF_LOCAL_P (op)
-                        && ((DEFAULT_ABI != ABI_AIX
-                             && DEFAULT_ABI != ABI_ELFv2)
-                            || !SYMBOL_REF_EXTERNAL_P (op)))
-                       || (op == XEXP (DECL_RTL (current_function_decl),
-                                                 0)))")))
+                   && (SYMBOL_REF_LOCAL_P (op)
+                       || op == XEXP (DECL_RTL (current_function_decl), 0))
+                   && !((DEFAULT_ABI == ABI_AIX
+                         || DEFAULT_ABI == ABI_ELFv2)
+                        && (SYMBOL_REF_EXTERNAL_P (op)
+                            || SYMBOL_REF_WEAK (op)))")))
 
 ;; Return 1 if this operand is a valid input for a move insn.
 (define_predicate "input_operand"
index 500effa7331fee5c2e4173f99af80bd6eddb9f69..8107bec8e6e379d2c6a9f49a43739b452a73ea24 100644 (file)
@@ -22833,6 +22833,7 @@ rs6000_function_ok_for_sibcall (tree decl, tree exp)
       || ((DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)
          && decl
          && !DECL_EXTERNAL (decl)
+         && !DECL_WEAK (decl)
          && (*targetm.binds_local_p) (decl))
       || (DEFAULT_ABI == ABI_V4
          && (!TARGET_SECURE_PLT