* [RS6000] Emit inline PLT when -mno-tls-markers
@ 2019-01-07 1:58 Alan Modra
2019-01-07 2:24 ` [RS6000] Implement -mno-pltseq Alan Modra
2019-01-10 11:06 ` [RS6000] Emit inline PLT when -mno-tls-markers Segher Boessenkool
0 siblings, 2 replies; 5+ messages in thread
From: Alan Modra @ 2019-01-07 1:58 UTC (permalink / raw)
To: gcc-patches; +Cc: Segher Boessenkool
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.
Bootstrapped and regression tested powerpc64le-linux and
powerpc64-linux, with and without -mno-tls-markers. OK to apply?
* 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_<mode>),
(pltseq_plt16_ha_<mode>, pltseq_plt16_lo_<mode>),
(pltseq_mtctr_<mode>): Don't test TARGET_TLS_MARKERS in predicate.
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 4e3c5fc135f..c126734d3e6 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -21618,7 +21618,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",
@@ -21707,7 +21707,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",
@@ -32768,7 +32768,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;
@@ -37767,7 +37766,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)
{
@@ -37792,7 +37790,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);
@@ -37933,8 +37930,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;
}
@@ -37948,7 +37944,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);
@@ -38005,8 +38000,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;
}
@@ -38019,7 +38013,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 0d5ef31f9f2..58070447639 100644
--- a/gcc/config/rs6000/rs6000.md
+++ b/gcc/config/rs6000/rs6000.md
@@ -10250,7 +10250,7 @@ (define_insn "*pltseq_tocsave_<mode>"
(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);
@@ -10262,7 +10262,7 @@ (define_insn "*pltseq_plt16_ha_<mode>"
(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);
@@ -10274,7 +10274,7 @@ (define_insn "*pltseq_plt16_lo_<mode>"
(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);
@@ -10287,7 +10287,7 @@ (define_insn "*pltseq_mtctr_<mode>"
(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);
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] 5+ messages in thread
* [RS6000] Implement -mno-pltseq
2019-01-07 1:58 [RS6000] Emit inline PLT when -mno-tls-markers Alan Modra
@ 2019-01-07 2:24 ` Alan Modra
2019-01-10 11:09 ` Segher Boessenkool
2019-01-10 11:06 ` [RS6000] Emit inline PLT when -mno-tls-markers Segher Boessenkool
1 sibling, 1 reply; 5+ messages in thread
From: Alan Modra @ 2019-01-07 2:24 UTC (permalink / raw)
To: gcc-patches; +Cc: Segher Boessenkool
Since the last patch untangled inline PLT and TLS marker support there
now isn't a way of requesting the older long call sequences on a
compiler built with inline PLT support. This patch adds support for
a new -mno-pltseq option.
Bootstrapped etc. powerpc64le-linux and powerpc64-linux. OK?
* config/rs6000/rs6000.opt (mpltseq): New option.
* config/rs6000/rs6000.h (TARGET_PLTSEQ): Define.
* config/rs6000/rs6000.c (rs6000_option_override_internal): Error
if given -mpltseq when assembler support is lacking.
(rs6000_indirect_call_template_1, rs6000_longcall_ref),
(rs6000_call_aix, rs6000_call_sysv, rs6000_sibcall_sysv): Replace
uses of HAVE_AS_PLTSEQ with TARGET_PLTSEQ.
* config/rs6000/rs6000.md (pltseq_tocsave_<mode>),
(pltseq_plt16_ha_<mode>, pltseq_plt16_lo_<mode>),
(pltseq_mtctr_<mode>): Likewise.
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index c126734d3e6..e846e676810 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -4513,6 +4513,9 @@ rs6000_option_override_internal (bool global_init_p)
if (TARGET_DEBUG_REG || TARGET_DEBUG_TARGET)
rs6000_print_isa_options (stderr, 0, "after subtarget", rs6000_isa_flags);
+ if (global_options_set.x_rs6000_pltseq && TARGET_PLTSEQ != rs6000_pltseq)
+ error ("%qs not supported by your assembler", "-mpltseq");
+
rs6000_always_hint = (rs6000_tune != PROCESSOR_POWER4
&& rs6000_tune != PROCESSOR_POWER5
&& rs6000_tune != PROCESSOR_POWER6
@@ -21613,7 +21616,7 @@ rs6000_indirect_call_template_1 (rtx *operands, unsigned int funop,
|| (REG_P (operands[funop])
&& REGNO (operands[funop]) == LR_REGNO));
- if (!TARGET_MACHO && HAVE_AS_PLTSEQ && GET_CODE (operands[funop]) == UNSPEC)
+ if (!TARGET_MACHO && TARGET_PLTSEQ && GET_CODE (operands[funop]) == UNSPEC)
{
const char *rel64 = TARGET_64BIT ? "64" : "";
char tls[29];
@@ -32767,7 +32770,7 @@ rs6000_longcall_ref (rtx call_ref, rtx arg)
call_ref = gen_rtx_SYMBOL_REF (VOIDmode, IDENTIFIER_POINTER (node));
}
- if (HAVE_AS_PLTSEQ
+ if (TARGET_PLTSEQ
&& (DEFAULT_ABI == ABI_ELFv2 || DEFAULT_ABI == ABI_V4))
{
rtx base = const0_rtx;
@@ -37765,7 +37768,7 @@ rs6000_call_aix (rtx value, rtx func_desc, rtx tlsarg, rtx cookie)
gen_rtx_PLUS (Pmode, stack_ptr,
stack_toc_offset));
MEM_VOLATILE_P (stack_toc_mem) = 1;
- if (HAVE_AS_PLTSEQ
+ if (TARGET_PLTSEQ
&& DEFAULT_ABI == ABI_ELFv2
&& GET_CODE (func_desc) == SYMBOL_REF)
{
@@ -37789,7 +37792,7 @@ rs6000_call_aix (rtx value, rtx func_desc, rtx tlsarg, rtx cookie)
calls via LR, so move the address there. Needed to mark
this insn for linker plt sequence editing too. */
func_addr = gen_rtx_REG (Pmode, CTR_REGNO);
- if (HAVE_AS_PLTSEQ
+ if (TARGET_PLTSEQ
&& GET_CODE (func_desc) == SYMBOL_REF)
{
rtvec v = gen_rtvec (3, abi_reg, func_desc, tlsarg);
@@ -37930,7 +37933,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)
+ if (TARGET_PLTSEQ)
abi_reg = func;
}
@@ -37943,7 +37946,7 @@ rs6000_call_sysv (rtx value, rtx func_desc, rtx tlsarg, rtx cookie)
calls via LR, so move the address there. Needed to mark
this insn for linker plt sequence editing too. */
func_addr = gen_rtx_REG (Pmode, CTR_REGNO);
- if (HAVE_AS_PLTSEQ
+ if (TARGET_PLTSEQ
&& GET_CODE (func_desc) == SYMBOL_REF)
{
rtvec v = gen_rtvec (3, func, func_desc, tlsarg);
@@ -38000,7 +38003,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)
+ if (TARGET_PLTSEQ)
abi_reg = func;
}
@@ -38012,7 +38015,7 @@ rs6000_sibcall_sysv (rtx value, rtx func_desc, rtx tlsarg, rtx cookie)
/* Indirect sibcalls must go via CTR. Needed to mark
this insn for linker plt sequence editing too. */
func_addr = gen_rtx_REG (Pmode, CTR_REGNO);
- if (HAVE_AS_PLTSEQ
+ if (TARGET_PLTSEQ
&& GET_CODE (func_desc) == SYMBOL_REF)
{
rtvec v = gen_rtvec (3, func, func_desc, tlsarg);
diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h
index 9c0cc8de2b6..5ffa55e562c 100644
--- a/gcc/config/rs6000/rs6000.h
+++ b/gcc/config/rs6000/rs6000.h
@@ -226,6 +226,12 @@ extern const char *host_detect_local_cpu (int argc, const char **argv);
#define HAVE_AS_PLTSEQ 0
#endif
+#if !HAVE_AS_PLTSEQ
+#define TARGET_PLTSEQ 0
+#else
+#define TARGET_PLTSEQ rs6000_pltseq
+#endif
+
#ifndef TARGET_LINK_STACK
#define TARGET_LINK_STACK 0
#endif
diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md
index 58070447639..b028b48aacc 100644
--- a/gcc/config/rs6000/rs6000.md
+++ b/gcc/config/rs6000/rs6000.md
@@ -10250,7 +10250,7 @@ (define_insn "*pltseq_tocsave_<mode>"
(match_operand:P 2 "symbol_ref_operand" "s")
(match_operand:P 3 "" "")]
UNSPEC_PLTSEQ))]
- "HAVE_AS_PLTSEQ
+ "TARGET_PLTSEQ
&& DEFAULT_ABI == ABI_ELFv2"
{
return rs6000_pltseq_template (operands, 0);
@@ -10262,7 +10262,7 @@ (define_insn "*pltseq_plt16_ha_<mode>"
(match_operand:P 2 "symbol_ref_operand" "s")
(match_operand:P 3 "" "")]
UNSPEC_PLT16_HA))]
- "HAVE_AS_PLTSEQ
+ "TARGET_PLTSEQ
&& (DEFAULT_ABI == ABI_ELFv2 || DEFAULT_ABI == ABI_V4)"
{
return rs6000_pltseq_template (operands, 1);
@@ -10274,7 +10274,7 @@ (define_insn "*pltseq_plt16_lo_<mode>"
(match_operand:P 2 "symbol_ref_operand" "s")
(match_operand:P 3 "" "")]
UNSPEC_PLT16_LO))]
- "HAVE_AS_PLTSEQ
+ "TARGET_PLTSEQ
&& (DEFAULT_ABI == ABI_ELFv2 || DEFAULT_ABI == ABI_V4)"
{
return rs6000_pltseq_template (operands, 2);
@@ -10287,7 +10287,7 @@ (define_insn "*pltseq_mtctr_<mode>"
(match_operand:P 2 "symbol_ref_operand" "s")
(match_operand:P 3 "" "")]
UNSPEC_PLTSEQ))]
- "HAVE_AS_PLTSEQ
+ "TARGET_PLTSEQ
&& (DEFAULT_ABI == ABI_ELFv2 || DEFAULT_ABI == ABI_V4)"
{
return rs6000_pltseq_template (operands, 3);
diff --git a/gcc/config/rs6000/rs6000.opt b/gcc/config/rs6000/rs6000.opt
index 2e90bf37747..3f94bb7671c 100644
--- a/gcc/config/rs6000/rs6000.opt
+++ b/gcc/config/rs6000/rs6000.opt
@@ -405,6 +405,10 @@ mlongcall
Target Report Var(rs6000_default_long_calls) Save
Avoid all range limits on call instructions.
+mpltseq
+Target Report Var(rs6000_pltseq) Init(1) Save
+Use inline plt sequences to implement long calls.
+
; This option existed in the past, but now is always on.
mgen-cell-microcode
Target RejectNegative Undocumented Ignore
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RS6000] Emit inline PLT when -mno-tls-markers
2019-01-07 1:58 [RS6000] Emit inline PLT when -mno-tls-markers Alan Modra
2019-01-07 2:24 ` [RS6000] Implement -mno-pltseq Alan Modra
@ 2019-01-10 11:06 ` Segher Boessenkool
1 sibling, 0 replies; 5+ messages in thread
From: Segher Boessenkool @ 2019-01-10 11:06 UTC (permalink / raw)
To: Alan Modra; +Cc: gcc-patches
Hi Alan,
This patch is okay (for trunk, and backports if needed), thanks!
I'll review your other patches next week.
Segher
On Mon, Jan 07, 2019 at 12:28:44PM +1030, Alan Modra wrote:
> 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.
>
> Bootstrapped and regression tested powerpc64le-linux and
> powerpc64-linux, with and without -mno-tls-markers. OK to apply?
>
> * 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_<mode>),
> (pltseq_plt16_ha_<mode>, pltseq_plt16_lo_<mode>),
> (pltseq_mtctr_<mode>): Don't test TARGET_TLS_MARKERS in predicate.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RS6000] Implement -mno-pltseq
2019-01-07 2:24 ` [RS6000] Implement -mno-pltseq Alan Modra
@ 2019-01-10 11:09 ` Segher Boessenkool
2019-01-10 12:05 ` Alan Modra
0 siblings, 1 reply; 5+ messages in thread
From: Segher Boessenkool @ 2019-01-10 11:09 UTC (permalink / raw)
To: Alan Modra; +Cc: gcc-patches
On Mon, Jan 07, 2019 at 12:54:02PM +1030, Alan Modra wrote:
> Since the last patch untangled inline PLT and TLS marker support there
> now isn't a way of requesting the older long call sequences on a
> compiler built with inline PLT support. This patch adds support for
> a new -mno-pltseq option.
Is this a useful option to have?
It needs documentation (in the manual), then.
Segher
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RS6000] Implement -mno-pltseq
2019-01-10 11:09 ` Segher Boessenkool
@ 2019-01-10 12:05 ` Alan Modra
0 siblings, 0 replies; 5+ messages in thread
From: Alan Modra @ 2019-01-10 12:05 UTC (permalink / raw)
To: Segher Boessenkool; +Cc: gcc-patches
On Thu, Jan 10, 2019 at 05:09:06AM -0600, Segher Boessenkool wrote:
> On Mon, Jan 07, 2019 at 12:54:02PM +1030, Alan Modra wrote:
> > Since the last patch untangled inline PLT and TLS marker support there
> > now isn't a way of requesting the older long call sequences on a
> > compiler built with inline PLT support. This patch adds support for
> > a new -mno-pltseq option.
>
> Is this a useful option to have?
I figure the most use it will get is by gcc maintainers and others
investigating bug reports. You get a bug report and can't reproduce
the failure even though compiler flags and gcc version are well
specified. -mno-pltseq gives you a way of quickly trying out
something that might be different in their auto-host.h to yours.
> It needs documentation (in the manual), then.
OK, will do.
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-01-10 12:05 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-07 1:58 [RS6000] Emit inline PLT when -mno-tls-markers Alan Modra
2019-01-07 2:24 ` [RS6000] Implement -mno-pltseq Alan Modra
2019-01-10 11:09 ` Segher Boessenkool
2019-01-10 12:05 ` Alan Modra
2019-01-10 11:06 ` [RS6000] Emit inline PLT when -mno-tls-markers Segher Boessenkool
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).