Re: [pushed][PATCH v3] LoongArch: Avoid non-returning indirect jumps through $ra [PR110136]

2023-06-18 Thread WANG Xuerui
+2895,10 @@ (define_insn "*jump_pic"   }     [(set_attr "type" "branch")]) +;; Micro-architecture unconditionally treats a "jr $ra" as "return from subroutine", +;; non-returning indirect jumps through $ra would interfere with both subrouti

Re: [pushed][PATCH v3] LoongArch: Avoid non-returning indirect jumps through $ra [PR110136]

2023-06-15 Thread Xi Ruoyao via Gcc-patches
garch.md | 8 ++-- > >   1 file changed, 6 insertions(+), 2 deletions(-) > > > > diff --git a/gcc/config/loongarch/loongarch.md > > b/gcc/config/loongarch/loongarch.md > > index 816a943d155..b37e070660f 100644 > > --- a/gcc/config/loongarch/loongarc

Re: [pushed][PATCH v3] LoongArch: Avoid non-returning indirect jumps through $ra [PR110136]

2023-06-15 Thread Lulu Cheng
ngarch.md +++ b/gcc/config/loongarch/loongarch.md @@ -2895,6 +2895,10 @@ (define_insn "*jump_pic" } [(set_attr "type" "branch")]) +;; Micro-architecture unconditionally treats a "jr $ra" as "return from subroutine", +;; non-returning indirect jumps through

[PATCH v3] LoongArch: Avoid non-returning indirect jumps through $ra [PR110136]

2023-06-14 Thread Lulu Cheng
[(set_attr "type" "branch")]) +;; Micro-architecture unconditionally treats a "jr $ra" as "return from subroutine", +;; non-returning indirect jumps through $ra would interfere with both subroutine +;; return prediction and the more general indirect br

Ping: [PATCH 1/3] Add power10 zero cycle moves for switches & indirect jumps

2021-12-13 Thread Michael Meissner via Gcc-patches
Ping patch. | Date: Fri, 19 Nov 2021 09:53:14 -0500 | From: Michael Meissner | Subject: [PATCH 1/3] Add power10 zero cycle moves for switches & indirect jumps | Message-ID: https://gcc.gnu.org/pipermail/gcc-patches/2021-November/585005.html Note, I will on-line through December 20th. I

Re: [PATCH 1/3] Add power10 zero cycle moves for switches & indirect jumps

2021-11-22 Thread Michael Meissner via Gcc-patches
On Mon, Nov 22, 2021 at 10:36:13AM -0600, Bill Schmidt wrote: > Hi Mike, > > Thanks for this patch! > > --- a/gcc/config/rs6000/rs6000.md > > +++ b/gcc/config/rs6000/rs6000.md > > @@ -12988,15 +12988,34 @@ (define_expand "indirect_jump" > > emit_jump_insn (gen_indirect_jump_nospec (Pmode, ope

Re: [PATCH 1/3] Add power10 zero cycle moves for switches & indirect jumps

2021-11-22 Thread Bill Schmidt via Gcc-patches
Hi Mike, Thanks for this patch! On 11/19/21 8:53 AM, Michael Meissner wrote: > Add power10 zero cycle moves for switches. > > Power10 will fuse adjacenet 'mtctr' and 'bctr' instructions to form zero > cycle moves. This code exploits this fusion opportunity. > > I have built bootstrapped compiler

[PATCH 1/3] Add power10 zero cycle moves for switches & indirect jumps

2021-11-19 Thread Michael Meissner via Gcc-patches
Add power10 zero cycle moves for switches. Power10 will fuse adjacenet 'mtctr' and 'bctr' instructions to form zero cycle moves. This code exploits this fusion opportunity. I have built bootstrapped compilers with this patch on little endian power9 and power10 systems with no regressions. Can I

Re: [PATCH, rs6000] Deprecate -mno-speculate-indirect-jumps

2018-02-06 Thread Bill Schmidt
On Feb 6, 2018, at 10:33 AM, Segher Boessenkool wrote: > > Hi Bill, > > On Mon, Feb 05, 2018 at 12:28:34PM -0600, Bill Schmidt wrote: >> It's been determined that we won't recommend use of the recently added >> undocumented option -mno-speculate-indirec

Re: [PATCH, rs6000] Deprecate -mno-speculate-indirect-jumps

2018-02-06 Thread Segher Boessenkool
Hi Bill, On Mon, Feb 05, 2018 at 12:28:34PM -0600, Bill Schmidt wrote: > It's been determined that we won't recommend use of the recently added > undocumented option -mno-speculate-indirect-jumps. This patch provides > a warning indicating that the option is deprecated. We wi

[PATCH, rs6000] Deprecate -mno-speculate-indirect-jumps

2018-02-05 Thread Bill Schmidt
Hi, It's been determined that we won't recommend use of the recently added undocumented option -mno-speculate-indirect-jumps. This patch provides a warning indicating that the option is deprecated. We will leave the code in place for potential emergency use (not expected), and plan to

Re: [PATCH, rs6000] Requested cleanups for BE handling of -mno-speculate-indirect-jumps

2018-01-20 Thread Segher Boessenkool
Hi! On Fri, Jan 19, 2018 at 09:46:27PM -0600, Bill Schmidt wrote: > Segher had previously requested some cleanups in > https://gcc.gnu.org/ml/gcc-patches/2018-01/msg01605.html. > Due to time pressures, I delayed those, but they are ready now. Here they > are, > bootstrapped and tested on powerp

[PATCH, rs6000] Requested cleanups for BE handling of -mno-speculate-indirect-jumps

2018-01-19 Thread Bill Schmidt
Hi, Segher had previously requested some cleanups in https://gcc.gnu.org/ml/gcc-patches/2018-01/msg01605.html. Due to time pressures, I delayed those, but they are ready now. Here they are, bootstrapped and tested on powerpc64le-linux-gnu and powerpc64-linux-gnu. Is this okay for trunk? I don'

Re: [PATCH v2, rs6000] Implement 32- and 64-bit BE handling for -mno-speculate-indirect-jumps

2018-01-19 Thread Bill Schmidt
ked up on a respin anyway. So I should have the fix in place before that happens. Bill > > Thanks, David > > On Tue, Jan 16, 2018 at 9:08 PM, Bill Schmidt > wrote: >> Hi, >> >> This patch supercedes and extends >> https://gcc.gnu.org/ml/gcc-patches/2018-01/msg0

Re: [PATCH v3, rs6000] Add -mspeculate-indirect-jumps option and implement non-speculating bctr / bctrl

2018-01-19 Thread Segher Boessenkool
On Fri, Jan 19, 2018 at 10:01:50AM -0700, Sandra Loosemore wrote: > > I see no documentation for the new option here :-( +;; -mno-speculate-indirect-jumps adds deliberate misprediction to indirect +;; branches via the CTR. +mspeculate-indirect-jumps +Target Undocument

Re: [PATCH v2, rs6000] Implement 32- and 64-bit BE handling for -mno-speculate-indirect-jumps

2018-01-19 Thread David Edelsohn
incorrect. I am going to try testing with "$" in trunk. GCC 7.3 must be re-spun. Thanks, David On Tue, Jan 16, 2018 at 9:08 PM, Bill Schmidt wrote: > Hi, > > This patch supercedes and extends > https://gcc.gnu.org/ml/gcc-patches/2018-01/msg01479.html, > adding the remaini

Re: [PATCH v3, rs6000] Add -mspeculate-indirect-jumps option and implement non-speculating bctr / bctrl

2018-01-19 Thread Sandra Loosemore
On 01/15/2018 04:09 PM, Bill Schmidt wrote: [gcc] 2018-01-15 Bill Schmidt * config/rs6000/rs6000.c (rs6000_opt_vars): Add entry for -mspeculate-indirect-jumps. * config/rs6000/rs6000.md (*call_indirect_elfv2): Disable for -mno-speculate-indirect-jumps

Re: [PATCH v2, rs6000] Implement 32- and 64-bit BE handling for -mno-speculate-indirect-jumps

2018-01-17 Thread Segher Boessenkool
On Tue, Jan 16, 2018 at 08:08:57PM -0600, Bill Schmidt wrote: > This patch supercedes and extends > https://gcc.gnu.org/ml/gcc-patches/2018-01/msg01479.html, > adding the remaining big-endian support for -mno-speculate-indirect-jumps. > This includes 32-bit support for indirect calls

[PATCH v2, rs6000] Implement 32- and 64-bit BE handling for -mno-speculate-indirect-jumps

2018-01-16 Thread Bill Schmidt
Hi, This patch supercedes and extends https://gcc.gnu.org/ml/gcc-patches/2018-01/msg01479.html, adding the remaining big-endian support for -mno-speculate-indirect-jumps. This includes 32-bit support for indirect calls and sibling calls, and 64-bit support for indirect calls. The endian

[PATCH, rs6000] Implement ABI_AIX indirect call handling for -mno-speculate-indirect-jumps

2018-01-16 Thread Bill Schmidt
Hi, This patch fills in a gap from the previous -mno-speculate-indirect-jumps patch. That patch didn't provide support for indirect calls using ABI_AIX as the default ABI. This fills in that missing support and changes the one related powerpc64le-only test case to be compiled for all subta

Re: [PATCH v3, rs6000] Add -mspeculate-indirect-jumps option and implement non-speculating bctr / bctrl

2018-01-16 Thread Bill Schmidt
f we have any knobs to tune we >> should probably >> tweak them away from the indirect jump using variants with >> -mno-speculate-indirect-jumps, >> right? > > We can generate indirect jumps for other situations so this patch will > still be needed. Also, I'm

Re: [PATCH v3, rs6000] Add -mspeculate-indirect-jumps option and implement non-speculating bctr / bctrl

2018-01-16 Thread Segher Boessenkool
Hi! On Mon, Jan 15, 2018 at 05:09:06PM -0600, Bill Schmidt wrote: > @@ -12933,9 +12974,27 @@ >"" > { >if (TARGET_32BIT) > -emit_jump_insn (gen_tablejumpsi (operands[0], operands[1])); > +{ > + if (rs6000_speculate_indirect_jumps) > + emit_jump_insn (gen_tablejumpsi (opera

Re: [PATCH v3, rs6000] Add -mspeculate-indirect-jumps option and implement non-speculating bctr / bctrl

2018-01-16 Thread Segher Boessenkool
rect jump using variants with > -mno-speculate-indirect-jumps, > right? We can generate indirect jumps for other situations so this patch will still be needed. > Performance optimization, so shouldn't block this patch - I just > thought I should probably > mention this. Yeah let's get this done first :-) Segher

Re: [PATCH v3, rs6000] Add -mspeculate-indirect-jumps option and implement non-speculating bctr / bctrl

2018-01-16 Thread Richard Biener
e have any knobs to tune we should probably tweak them away from the indirect jump using variants with -mno-speculate-indirect-jumps, right? Performance optimization, so shouldn't block this patch - I just thought I should probably mention this. Richard. > Thanks, > Bill >

[PATCH v3, rs6000] Add -mspeculate-indirect-jumps option and implement non-speculating bctr / bctrl

2018-01-15 Thread Bill Schmidt
sions. Is this okay for trunk? Thanks, Bill [gcc] 2018-01-15 Bill Schmidt * config/rs6000/rs6000.c (rs6000_opt_vars): Add entry for -mspeculate-indirect-jumps. * config/rs6000/rs6000.md (*call_indirect_elfv2): Disable for -mno-speculate-indi

Re: [PATCH v2, rs6000] Add -msafe-indirect-jumps option and implement safe bctr / bctrl

2018-01-15 Thread Segher Boessenkool
On Mon, Jan 15, 2018 at 11:54:41AM -0600, Bill Schmidt wrote: > > I think we settled on calling the option -mmispredict-indirect-jumps; > > please let me know if you still agree with that. Or have thought of a > > better name :-) > > Looks like we are now looking at -

Re: [PATCH v2, rs6000] Add -msafe-indirect-jumps option and implement safe bctr / bctrl

2018-01-15 Thread Bill Schmidt
Hi Segher, Thanks for the quick review! > On Jan 15, 2018, at 10:38 AM, Segher Boessenkool > wrote: > > Hi! > > On Sat, Jan 13, 2018 at 10:53:57PM -0600, Bill Schmidt wrote: >> This patch adds a new option for the compiler to produce only "safe" indirect

Re: [PATCH, rs6000] Executable tests for -msafe-indirect-jumps

2018-01-15 Thread Bill Schmidt
On Jan 15, 2018, at 11:05 AM, Segher Boessenkool wrote: > > Hi! > > On Sun, Jan 14, 2018 at 11:34:06AM -0600, Bill Schmidt wrote: >> It was pointed out off-list that I should add some executable tests for >> the new -msafe-indirect-jumps implementation. This patch add

Re: [PATCH, rs6000] Executable tests for -msafe-indirect-jumps

2018-01-15 Thread Segher Boessenkool
Hi! On Sun, Jan 14, 2018 at 11:34:06AM -0600, Bill Schmidt wrote: > It was pointed out off-list that I should add some executable tests for > the new -msafe-indirect-jumps implementation. This patch adds three > such tests to demonstrate correct behavior. > > Tested on powerpc6

Re: [PATCH v2, rs6000] Add -msafe-indirect-jumps option and implement safe bctr / bctrl

2018-01-15 Thread Segher Boessenkool
Hi! On Sat, Jan 13, 2018 at 10:53:57PM -0600, Bill Schmidt wrote: > This patch adds a new option for the compiler to produce only "safe" indirect > jumps, in the sense that these jumps are deliberately mispredicted to inhibit > speculative execution. For now, this option is

Re: [PATCH v2, rs6000] Add -msafe-indirect-jumps option and implement safe bctr / bctrl

2018-01-15 Thread Bill Schmidt
he assembly code produced by that patch (bad >> memory on my account of how to spell "crset eq"). I've also increased the >> function provided; see below.] >> >> This patch adds a new option for the compiler to produce only "safe" indirect >>

Re: [PATCH v2, rs6000] Add -msafe-indirect-jumps option and implement safe bctr / bctrl

2018-01-15 Thread Richard Biener
;crset eq"). I've also increased the > function provided; see below.] > > This patch adds a new option for the compiler to produce only "safe" indirect > jumps, in the sense that these jumps are deliberately mispredicted to inhibit > speculative execution. For n

[PATCH, rs6000] Executable tests for -msafe-indirect-jumps

2018-01-14 Thread Bill Schmidt
Hi, It was pointed out off-list that I should add some executable tests for the new -msafe-indirect-jumps implementation. This patch adds three such tests to demonstrate correct behavior. Tested on powerpc64-linux-gnu and powerpc64le-linux-gnu. Are these tests okay for trunk after the other

Re: [PATCH, rs6000] Add -msafe-indirect-jumps option and implement safe bctrl

2018-01-13 Thread Bill Schmidt
Hi, This is now superceded by https://gcc.gnu.org/ml/gcc-patches/2018-01/msg01204.html. Sorry for the noise. Thanks, Bill > On Jan 12, 2018, at 4:33 PM, Bill Schmidt wrote: > > Hi, > > This patch adds a new option for the compiler to produce only "safe" indirect &

[PATCH v2, rs6000] Add -msafe-indirect-jumps option and implement safe bctr / bctrl

2018-01-13 Thread Bill Schmidt
is patch adds a new option for the compiler to produce only "safe" indirect jumps, in the sense that these jumps are deliberately mispredicted to inhibit speculative execution. For now, this option is undocumented; this may change at some future date. It is intended eventually for the

[PATCH, rs6000] Add -msafe-indirect-jumps option and implement safe bctrl

2018-01-12 Thread Bill Schmidt
Hi, This patch adds a new option for the compiler to produce only "safe" indirect jumps, in the sense that these jumps are deliberately mispredicted to inhibit speculative execution. For now, this option is undocumented; this may change at some future date. It is intended eventual

Re: Indirect jumps

2015-08-25 Thread Nathan Sidwell
On 08/25/15 15:10, Jeff Law wrote: On 08/25/2015 08:11 AM, Nathan Sidwell wrote: We could emulate by creating a new stack frame and shoving the target of the branch into the stack, then executing a return. However, I don't think that's worth doing ;-) And wouldn't work for PTX anyway -- all

Re: Indirect jumps

2015-08-25 Thread Jeff Law
On 08/25/2015 08:11 AM, Nathan Sidwell wrote: Ptx is one of those rare (unique?) machines that doesn't have an indirect branch. optabs is prepared for such a target and emits a sorry when an indirect branch is needed. However it then goes on to try and emit such an instruction and ends up I

Indirect jumps

2015-08-25 Thread Nathan Sidwell
=== --- gcc/optabs.c (revision 227128) +++ gcc/optabs.c (working copy) @@ -4488,11 +4488,13 @@ emit_indirect_jump (rtx loc) { if (!targetm.have_indirect_jump ()) sorry ("indirect jumps are not available on this target"); - - struct expand_operand ops[1]; - create_addr

[patch, nios2] add IJMP_REGS reg class for indirect jumps

2015-05-12 Thread Sandra Loosemore
While testing something else, I noticed a couple compilation errors like: /tmp/ccCxOOoN.s: Assembler messages: /tmp/ccCxOOoN.s:164: Error: r31 cannot be used with jmp; use ret instead The assembler is correct in rejecting this code, since this is a documented restriction of the JMP instruction.

Re: The nvptx port [1/11+] indirect jumps

2014-11-04 Thread Richard Henderson
On 11/04/2014 04:32 PM, Bernd Schmidt wrote: > On 10/20/2014 04:19 PM, Bernd Schmidt wrote: >> ptx doesn't have indirect jumps, so CODE_FOR_indirect_jump may not be >> defined. Add a sorry. > > Looking back through all the mails it turns out this one wasn't approved yet. > Ping? Ok. r~

Re: The nvptx port [1/11+] indirect jumps

2014-11-04 Thread Bernd Schmidt
On 10/20/2014 04:19 PM, Bernd Schmidt wrote: ptx doesn't have indirect jumps, so CODE_FOR_indirect_jump may not be defined. Add a sorry. Looking back through all the mails it turns out this one wasn't approved yet. Ping? Bernd

Re: The nvptx port [1/11+] indirect jumps

2014-10-22 Thread Jakub Jelinek
On Wed, Oct 22, 2014 at 12:02:16PM +0200, Richard Biener wrote: > > I'm not sure that's what you're suggesting, but at least on non-shared > > memory offloading devices, you can't switch arbitrarily between > > offloading device(s) and host-fallback, for you have to do data > > management between t

Re: The nvptx port [1/11+] indirect jumps

2014-10-22 Thread Richard Biener
On Wed, Oct 22, 2014 at 10:34 AM, Thomas Schwinge wrote: > Hi! > > On Wed, 22 Oct 2014 10:18:49 +0200, Richard Biener > wrote: >> On Tue, Oct 21, 2014 at 11:32 PM, Bernd Schmidt >> wrote: >> > On 10/21/2014 11:30 PM, Jakub Jelinek wrote: >> >> >> >> At least for OpenMP, the best would be if th

Re: The nvptx port [1/11+] indirect jumps

2014-10-22 Thread Thomas Schwinge
Hi! On Wed, 22 Oct 2014 10:18:49 +0200, Richard Biener wrote: > On Tue, Oct 21, 2014 at 11:32 PM, Bernd Schmidt > wrote: > > On 10/21/2014 11:30 PM, Jakub Jelinek wrote: > >> > >> At least for OpenMP, the best would be if the #pragma omp target regions > >> and/or #pragma omp declare target fu

Re: The nvptx port [1/11+] indirect jumps

2014-10-22 Thread Jakub Jelinek
On Wed, Oct 22, 2014 at 10:18:49AM +0200, Richard Biener wrote: > On Tue, Oct 21, 2014 at 11:32 PM, Bernd Schmidt > wrote: > > On 10/21/2014 11:30 PM, Jakub Jelinek wrote: > >> > >> At least for OpenMP, the best would be if the #pragma omp target regions > >> and/or #pragma omp declare target fun

Re: The nvptx port [1/11+] indirect jumps

2014-10-22 Thread Richard Biener
On Tue, Oct 21, 2014 at 11:32 PM, Bernd Schmidt wrote: > On 10/21/2014 11:30 PM, Jakub Jelinek wrote: >> >> At least for OpenMP, the best would be if the #pragma omp target regions >> and/or #pragma omp declare target functions contain anything a particular >> offloading accelerator can't handle,

Re: The nvptx port [1/11+] indirect jumps

2014-10-21 Thread Bernd Schmidt
On 10/21/2014 11:30 PM, Jakub Jelinek wrote: At least for OpenMP, the best would be if the #pragma omp target regions and/or #pragma omp declare target functions contain anything a particular offloading accelerator can't handle, instead of failing the whole compilation perhaps just emit some at l

Re: The nvptx port [1/11+] indirect jumps

2014-10-21 Thread Jakub Jelinek
On Tue, Oct 21, 2014 at 11:00:35PM +0200, Bernd Schmidt wrote: > On 10/21/2014 08:26 PM, Jeff Law wrote: > >>* optabs.c (emit_indirect_jump): Test HAVE_indirect_jump and emit a > >>sorry if necessary. > >So doesn't this imply no hot-cold partitioning since

Re: The nvptx port [1/11+] indirect jumps

2014-10-21 Thread Bernd Schmidt
On 10/21/2014 08:26 PM, Jeff Law wrote: * optabs.c (emit_indirect_jump): Test HAVE_indirect_jump and emit a sorry if necessary. So doesn't this imply no hot-cold partitioning since we use indirect jumps to get across the partition? Similarly doesn't this imply other missin

Re: The nvptx port [1/11+] indirect jumps

2014-10-21 Thread Jeff Law
On 10/20/14 14:19, Bernd Schmidt wrote: ptx doesn't have indirect jumps, so CODE_FOR_indirect_jump may not be defined. Add a sorry. Bernd 001-indjumps.diff gcc/ * optabs.c (emit_indirect_jump): Test HAVE_indirect_jump and emit a sorry if necessary. So doesn&#

The nvptx port [1/11+] indirect jumps

2014-10-20 Thread Bernd Schmidt
ptx doesn't have indirect jumps, so CODE_FOR_indirect_jump may not be defined. Add a sorry. Bernd gcc/ * optabs.c (emit_indirect_jump): Test HAVE_indirect_jump and emit a sorry if necessary. Index: gcc/opt