aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2017-01-20 09:49:19 +1030
committerAlan Modra <amodra@gcc.gnu.org>2017-01-20 09:49:19 +1030
commit5699b9d11556148547b478d1b4591359c7b89ac5 (patch)
tree2af0ac8212f9f4209d79244b9c6345cfc2fe7e06
parent8e4160112d24d56852a17ca3627dec24d3ffa1ed (diff)
downloadgcc-5699b9d11556148547b478d1b4591359c7b89ac5.zip
gcc-5699b9d11556148547b478d1b4591359c7b89ac5.tar.gz
gcc-5699b9d11556148547b478d1b4591359c7b89ac5.tar.bz2
[RS6000] PR79144, cmpstrnsi optimization breaks glibc
glibc compiled with current gcc-7 fails one test due to strcmp and strncmp appearing in the PLT. This is because the inline expansion of those functions falls back to a function call, but doesn't use the asm name for the call. PR target/79144 * config/rs6000/rs6000.c (expand_strn_compare): Get the asm name for strcmp and strncmp from corresponding builtin decl. From-SVN: r244659
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/config/rs6000/rs6000.c28
2 files changed, 24 insertions, 10 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 5cdcfa8..33eb129 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2017-01-20 Alan Modra <amodra@gmail.com>
+
+ PR target/79144
+ * config/rs6000/rs6000.c (expand_strn_compare): Get the asm name
+ for strcmp and strncmp from corresponding builtin decl.
+
2017-01-19 Uros Bizjak <ubizjak@gmail.com>
* config.gcc (x86_64-*-rtems*): Use i386/rtemself.h
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 44d18e9..4c6bada 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -19869,10 +19869,13 @@ expand_strn_compare (rtx operands[], int no_length)
}
if (no_length)
- emit_library_call_value (gen_rtx_SYMBOL_REF (Pmode, "strcmp"),
- target, LCT_NORMAL, GET_MODE (target), 2,
- force_reg (Pmode, XEXP (src1, 0)), Pmode,
- force_reg (Pmode, XEXP (src2, 0)), Pmode);
+ {
+ tree fun = builtin_decl_explicit (BUILT_IN_STRCMP);
+ emit_library_call_value (XEXP (DECL_RTL (fun), 0),
+ target, LCT_NORMAL, GET_MODE (target), 2,
+ force_reg (Pmode, XEXP (src1, 0)), Pmode,
+ force_reg (Pmode, XEXP (src2, 0)), Pmode);
+ }
else
{
/* -m32 -mpowerpc64 results in word_mode being DImode even
@@ -19886,7 +19889,8 @@ expand_strn_compare (rtx operands[], int no_length)
emit_move_insn (len_rtx, bytes_rtx);
- emit_library_call_value (gen_rtx_SYMBOL_REF (Pmode, "strncmp"),
+ tree fun = builtin_decl_explicit (BUILT_IN_STRNCMP);
+ emit_library_call_value (XEXP (DECL_RTL (fun), 0),
target, LCT_NORMAL, GET_MODE (target), 3,
force_reg (Pmode, XEXP (src1, 0)), Pmode,
force_reg (Pmode, XEXP (src2, 0)), Pmode,
@@ -20131,10 +20135,13 @@ expand_strn_compare (rtx operands[], int no_length)
/* Construct call to strcmp/strncmp to compare the rest of the string. */
if (no_length)
- emit_library_call_value (gen_rtx_SYMBOL_REF (Pmode, "strcmp"),
- target, LCT_NORMAL, GET_MODE (target), 2,
- force_reg (Pmode, XEXP (src1, 0)), Pmode,
- force_reg (Pmode, XEXP (src2, 0)), Pmode);
+ {
+ tree fun = builtin_decl_explicit (BUILT_IN_STRCMP);
+ emit_library_call_value (XEXP (DECL_RTL (fun), 0),
+ target, LCT_NORMAL, GET_MODE (target), 2,
+ force_reg (Pmode, XEXP (src1, 0)), Pmode,
+ force_reg (Pmode, XEXP (src2, 0)), Pmode);
+ }
else
{
rtx len_rtx;
@@ -20144,7 +20151,8 @@ expand_strn_compare (rtx operands[], int no_length)
len_rtx = gen_reg_rtx (SImode);
emit_move_insn (len_rtx, GEN_INT (bytes - compare_length));
- emit_library_call_value (gen_rtx_SYMBOL_REF (Pmode, "strncmp"),
+ tree fun = builtin_decl_explicit (BUILT_IN_STRNCMP);
+ emit_library_call_value (XEXP (DECL_RTL (fun), 0),
target, LCT_NORMAL, GET_MODE (target), 3,
force_reg (Pmode, XEXP (src1, 0)), Pmode,
force_reg (Pmode, XEXP (src2, 0)), Pmode,