From d92ec61d23834a69e962fe66acd7c192c3abc972 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Mon, 4 Feb 2019 23:48:14 +1030 Subject: [PATCH] [RS6000] Emit inline PLT when -mno-tls-markers I restricted output of inline PLT sequences to when TLS marker relocs were also available, which is obviously true when just considering assembler support. However, there is a -mno-tls-markers option to disable emitting the marker relocs. Currently that option also disables inline PLT sequences, which is a bug (*). This patch fixes that problem. *) To be honest, it was a deliberate bug. I didn't want to have to deal with inline PLT __tls_get_addr sequences lacking the marker relocs in the linker, but it turns out the existing linker support for old-style __tls_get_addr calls works reasonably well. * config/rs6000/rs6000.c (rs6000_indirect_call_template_1), (rs6000_pltseq_template): Guard output of TLS markers with TARGET_TLS_MARKERS. (rs6000_longcall_ref, rs6000_call_aix, rs6000_call_sysv), (rs6000_sibcall_sysv): Ignore TARGET_TLS_MARKERS when deciding to use inline PLT sequences. * config/rs6000/rs6000.md (pltseq_tocsave_), (pltseq_plt16_ha_, pltseq_plt16_lo_), (pltseq_mtctr_): Don't test TARGET_TLS_MARKERS in predicate. From-SVN: r268519 --- gcc/ChangeLog | 12 ++++++++++++ gcc/config/rs6000/rs6000.c | 15 ++++----------- gcc/config/rs6000/rs6000.md | 8 ++++---- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8f2a05d6275..efe3f5bfe6e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,15 @@ +2019-02-04 Alan Modra + + * config/rs6000/rs6000.c (rs6000_indirect_call_template_1), + (rs6000_pltseq_template): Guard output of TLS markers with + TARGET_TLS_MARKERS. + (rs6000_longcall_ref, rs6000_call_aix, rs6000_call_sysv), + (rs6000_sibcall_sysv): Ignore TARGET_TLS_MARKERS when deciding + to use inline PLT sequences. + * config/rs6000/rs6000.md (pltseq_tocsave_), + (pltseq_plt16_ha_, pltseq_plt16_lo_), + (pltseq_mtctr_): Don't test TARGET_TLS_MARKERS in predicate. + 2019-02-04 Martin Liska PR ipa/88985 diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 401e7194887..7d417b626e8 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -21633,7 +21633,7 @@ rs6000_indirect_call_template_1 (rtx *operands, unsigned int funop, const char *rel64 = TARGET_64BIT ? "64" : ""; char tls[29]; tls[0] = 0; - if (GET_CODE (operands[funop + 1]) == UNSPEC) + if (TARGET_TLS_MARKERS && GET_CODE (operands[funop + 1]) == UNSPEC) { if (XINT (operands[funop + 1], 1) == UNSPEC_TLSGD) sprintf (tls, ".reloc .,R_PPC%s_TLSGD,%%%u\n\t", @@ -21722,7 +21722,7 @@ rs6000_pltseq_template (rtx *operands, int which) const char *rel64 = TARGET_64BIT ? "64" : ""; char tls[28]; tls[0] = 0; - if (GET_CODE (operands[3]) == UNSPEC) + if (TARGET_TLS_MARKERS && GET_CODE (operands[3]) == UNSPEC) { if (XINT (operands[3], 1) == UNSPEC_TLSGD) sprintf (tls, ".reloc .,R_PPC%s_TLSGD,%%3\n\t", @@ -32782,7 +32782,6 @@ rs6000_longcall_ref (rtx call_ref, rtx arg) } if (HAVE_AS_PLTSEQ - && TARGET_TLS_MARKERS && (DEFAULT_ABI == ABI_ELFv2 || DEFAULT_ABI == ABI_V4)) { rtx base = const0_rtx; @@ -37781,7 +37780,6 @@ rs6000_call_aix (rtx value, rtx func_desc, rtx tlsarg, rtx cookie) stack_toc_offset)); MEM_VOLATILE_P (stack_toc_mem) = 1; if (HAVE_AS_PLTSEQ - && TARGET_TLS_MARKERS && DEFAULT_ABI == ABI_ELFv2 && GET_CODE (func_desc) == SYMBOL_REF) { @@ -37806,7 +37804,6 @@ rs6000_call_aix (rtx value, rtx func_desc, rtx tlsarg, rtx cookie) this insn for linker plt sequence editing too. */ func_addr = gen_rtx_REG (Pmode, CTR_REGNO); if (HAVE_AS_PLTSEQ - && TARGET_TLS_MARKERS && GET_CODE (func_desc) == SYMBOL_REF) { rtvec v = gen_rtvec (3, abi_reg, func_desc, tlsarg); @@ -37947,8 +37944,7 @@ rs6000_call_sysv (rtx value, rtx func_desc, rtx tlsarg, rtx cookie) func = rs6000_longcall_ref (func_desc, tlsarg); /* If the longcall was implemented using PLT16 relocs, then r11 needs to be valid at the call for lazy linking. */ - if (HAVE_AS_PLTSEQ - && TARGET_TLS_MARKERS) + if (HAVE_AS_PLTSEQ) abi_reg = func; } @@ -37962,7 +37958,6 @@ rs6000_call_sysv (rtx value, rtx func_desc, rtx tlsarg, rtx cookie) this insn for linker plt sequence editing too. */ func_addr = gen_rtx_REG (Pmode, CTR_REGNO); if (HAVE_AS_PLTSEQ - && TARGET_TLS_MARKERS && GET_CODE (func_desc) == SYMBOL_REF) { rtvec v = gen_rtvec (3, func, func_desc, tlsarg); @@ -38019,8 +38014,7 @@ rs6000_sibcall_sysv (rtx value, rtx func_desc, rtx tlsarg, rtx cookie) func = rs6000_longcall_ref (func_desc, tlsarg); /* If the longcall was implemented using PLT16 relocs, then r11 needs to be valid at the call for lazy linking. */ - if (HAVE_AS_PLTSEQ - && TARGET_TLS_MARKERS) + if (HAVE_AS_PLTSEQ) abi_reg = func; } @@ -38033,7 +38027,6 @@ rs6000_sibcall_sysv (rtx value, rtx func_desc, rtx tlsarg, rtx cookie) this insn for linker plt sequence editing too. */ func_addr = gen_rtx_REG (Pmode, CTR_REGNO); if (HAVE_AS_PLTSEQ - && TARGET_TLS_MARKERS && GET_CODE (func_desc) == SYMBOL_REF) { rtvec v = gen_rtvec (3, func, func_desc, tlsarg); diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index a307518cbdf..70a4900b067 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -10179,7 +10179,7 @@ (match_operand:P 2 "symbol_ref_operand" "s") (match_operand:P 3 "" "")] UNSPEC_PLTSEQ))] - "HAVE_AS_PLTSEQ && TARGET_TLS_MARKERS + "HAVE_AS_PLTSEQ && DEFAULT_ABI == ABI_ELFv2" { return rs6000_pltseq_template (operands, 0); @@ -10191,7 +10191,7 @@ (match_operand:P 2 "symbol_ref_operand" "s") (match_operand:P 3 "" "")] UNSPEC_PLT16_HA))] - "HAVE_AS_PLTSEQ && TARGET_TLS_MARKERS + "HAVE_AS_PLTSEQ && (DEFAULT_ABI == ABI_ELFv2 || DEFAULT_ABI == ABI_V4)" { return rs6000_pltseq_template (operands, 1); @@ -10203,7 +10203,7 @@ (match_operand:P 2 "symbol_ref_operand" "s") (match_operand:P 3 "" "")] UNSPEC_PLT16_LO))] - "HAVE_AS_PLTSEQ && TARGET_TLS_MARKERS + "HAVE_AS_PLTSEQ && (DEFAULT_ABI == ABI_ELFv2 || DEFAULT_ABI == ABI_V4)" { return rs6000_pltseq_template (operands, 2); @@ -10216,7 +10216,7 @@ (match_operand:P 2 "symbol_ref_operand" "s") (match_operand:P 3 "" "")] UNSPEC_PLTSEQ))] - "HAVE_AS_PLTSEQ && TARGET_TLS_MARKERS + "HAVE_AS_PLTSEQ && (DEFAULT_ABI == ABI_ELFv2 || DEFAULT_ABI == ABI_V4)" { return rs6000_pltseq_template (operands, 3); -- 2.30.2