Re: [PATCH] i386: Don't use frame pointer without stack access

2017-08-10 Thread H.J. Lu
On Thu, Aug 10, 2017 at 12:39 AM, Uros Bizjak wrote: > On Thu, Aug 10, 2017 at 9:09 AM, Richard Sandiford > wrote: >> "H.J. Lu" writes: >>> On Wed, Aug 9, 2017 at 10:28 AM, H.J. Lu wrote: On Wed,

Re: [PATCH] i386: Don't use frame pointer without stack access

2017-08-10 Thread Uros Bizjak
On Thu, Aug 10, 2017 at 9:09 AM, Richard Sandiford wrote: > "H.J. Lu" writes: >> On Wed, Aug 9, 2017 at 10:28 AM, H.J. Lu wrote: >>> On Wed, Aug 9, 2017 at 8:26 AM, Andi Kleen wrote: > This must be

Re: [PATCH] i386: Don't use frame pointer without stack access

2017-08-10 Thread Richard Sandiford
"H.J. Lu" writes: > On Wed, Aug 9, 2017 at 10:28 AM, H.J. Lu wrote: >> On Wed, Aug 9, 2017 at 8:26 AM, Andi Kleen wrote: This must be much more specific. How does it impact: 1. LTO 2. Function inlining. 3.

Re: [PATCH] i386: Don't use frame pointer without stack access

2017-08-09 Thread H.J. Lu
frame-pointer} is enabled or not. Disabled by default. > Here is the updated patch with -fkeep-frame-pointer. OK for trunk? -- H.J. From 6f5b42bbe2baa7977dcbf388219dabcb4a6b546d Mon Sep 17 00:00:00 2001 From: "H.J. Lu" <hjl.to...@gmail.com> Date: Sun, 6 Aug 2017 06:24:36 -0700 Subject: [PATCH] i386: Don't u

Re: [PATCH] i386: Don't use frame pointer without stack access

2017-08-09 Thread H.J. Lu
On Wed, Aug 9, 2017 at 8:26 AM, Andi Kleen wrote: >> This must be much more specific. How does it impact: >> >> 1. LTO >> 2. Function inlining. >> 3. Partial function inlining. >> 4. Shrink-wrapping. >> >> Any of them can impact function stack frame. > > It doesn't. It's

Re: [PATCH] i386: Don't use frame pointer without stack access

2017-08-09 Thread Andi Kleen
> This must be much more specific. How does it impact: > > 1. LTO > 2. Function inlining. > 3. Partial function inlining. > 4. Shrink-wrapping. > > Any of them can impact function stack frame. It doesn't. It's just to get back to the previous state. Also these others already have explicit

Re: [PATCH] i386: Don't use frame pointer without stack access

2017-08-09 Thread H.J. Lu
On Wed, Aug 9, 2017 at 8:05 AM, Arjan van de Ven wrote: > On 8/9/2017 8:04 AM, Andi Kleen wrote: >> >> I would add a new option >> -fforce-frame-pointer >> that gives the old -fno-omit-frame-pointer back, so that >> users relying on frame pointers everywhere have a

Re: [PATCH] i386: Don't use frame pointer without stack access

2017-08-09 Thread Arjan van de Ven
On 8/9/2017 8:04 AM, Andi Kleen wrote: I would add a new option -fforce-frame-pointer that gives the old -fno-omit-frame-pointer back, so that users relying on frame pointers everywhere have a workaround. that function should also fix the current situation where the framepointer is not useful

Re: [PATCH] i386: Don't use frame pointer without stack access

2017-08-09 Thread Andi Kleen
"H.J. Lu" writes: > > Like this? > > Note that @option{-fno-omit-frame-pointer} doesn't force a new stack > frame for all functions if it isn't otherwise needed, and hence doesn't > guarantee a new frame pointer for all functions. > > Here is the updated patch with a note for

Re: [PATCH] i386: Don't use frame pointer without stack access

2017-08-09 Thread H.J. Lu
99ab0904671919187c71d4a54594c1431 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" <hjl.to...@gmail.com> Date: Sun, 6 Aug 2017 06:24:36 -0700 Subject: [PATCH] i386: Don't use frame pointer without stack access When there is no stack access, there is no need to use frame

Re: [PATCH] i386: Don't use frame pointer without stack access

2017-08-09 Thread Michael Matz
Hi, On Wed, 9 Aug 2017, H.J. Lu wrote: > > OK, but then both -f[no-]omit-frame-pointer do not have clearly defined > > semantics and thus shouldn't be exposed to the user? > > -f[no-]omit-frame-pointer apply to cases where a new stack frame > is needed. -fno-omit-frame-pointer allows you to

Re: [PATCH] i386: Don't use frame pointer without stack access

2017-08-09 Thread H.J. Lu
On Wed, Aug 9, 2017 at 4:22 AM, Richard Biener wrote: > On August 9, 2017 9:53:05 AM GMT+02:00, Richard Sandiford > wrote: >>Richard Biener writes: >>> On August 8, 2017 7:36:35 PM GMT+02:00, Richard

Re: [PATCH] i386: Don't use frame pointer without stack access

2017-08-09 Thread Richard Biener
On August 9, 2017 9:53:05 AM GMT+02:00, Richard Sandiford wrote: >Richard Biener writes: >> On August 8, 2017 7:36:35 PM GMT+02:00, Richard Sandiford >> wrote: >>>Richard Sandiford

Re: [PATCH] i386: Don't use frame pointer without stack access

2017-08-09 Thread Richard Sandiford
Richard Biener writes: > On August 8, 2017 7:36:35 PM GMT+02:00, Richard Sandiford > wrote: >>Richard Sandiford writes: >>> Richard Biener writes: On August 8, 2017 6:38:30

Re: [PATCH] i386: Don't use frame pointer without stack access

2017-08-08 Thread H.J. Lu
On Tue, Aug 8, 2017 at 11:00 AM, Richard Biener wrote: > On August 8, 2017 7:36:35 PM GMT+02:00, Richard Sandiford > wrote: >>Richard Sandiford writes: >>> Richard Biener

Re: [PATCH] i386: Don't use frame pointer without stack access

2017-08-08 Thread Richard Biener
On August 8, 2017 7:36:35 PM GMT+02:00, Richard Sandiford wrote: >Richard Sandiford writes: >> Richard Biener writes: >>> On August 8, 2017 6:38:30 PM GMT+02:00, "H.J. Lu" > wrote:

Re: [PATCH] i386: Don't use frame pointer without stack access

2017-08-08 Thread Richard Sandiford
Richard Sandiford writes: > Richard Biener writes: >> On August 8, 2017 6:38:30 PM GMT+02:00, "H.J. Lu" >> wrote: >>>On Mon, Aug 7, 2017 at 1:05 PM, Richard Sandiford >>> wrote:

Re: [PATCH] i386: Don't use frame pointer without stack access

2017-08-08 Thread Richard Sandiford
Richard Biener writes: > On August 8, 2017 6:38:30 PM GMT+02:00, "H.J. Lu" wrote: >>On Mon, Aug 7, 2017 at 1:05 PM, Richard Sandiford >> wrote: >>> Arjan van de Ven writes: On 8/7/2017

Re: [PATCH] i386: Don't use frame pointer without stack access

2017-08-08 Thread Uros Bizjak
On Tue, Aug 8, 2017 at 6:38 PM, H.J. Lu wrote: > When Linux/x86-64 kernel is compiled with -fno-omit-frame-pointer. > this optimization removes more than 730 > > pushq %rbp > movq %rsp, %rbp > popq %rbp If you don't want the frame pointer,

Re: [PATCH] i386: Don't use frame pointer without stack access

2017-08-08 Thread Richard Biener
On August 8, 2017 6:38:30 PM GMT+02:00, "H.J. Lu" wrote: >On Mon, Aug 7, 2017 at 1:05 PM, Richard Sandiford > wrote: >> Arjan van de Ven writes: >>> On 8/7/2017 8:43 AM, Jakub Jelinek wrote: On Mon, Aug 07, 2017 at

Re: [PATCH] i386: Don't use frame pointer without stack access

2017-08-08 Thread H.J. Lu
int v8si __attribute__ ((vector_size (32))); void foo (v8si *out_start, v8si *out_end, v8si *regions) { v8si base = regions[3]; *out_start = base; *out_end = base; } OK for trunk? Thanks. -- H.J. From d18008a8052973ab8582a1662f42669a9d318d0d Mon Sep 17 00:00:00 2001 From: "

Re: [PATCH] i386: Don't use frame pointer without stack access

2017-08-07 Thread Richard Sandiford
Arjan van de Ven writes: > On 8/7/2017 8:43 AM, Jakub Jelinek wrote: >> On Mon, Aug 07, 2017 at 08:39:24AM -0700, H.J. Lu wrote: >>> When Linux/x86-64 kernel is compiled with -fno-omit-frame-pointer. >>> this optimization removes more than 730 >>> >>> pushq %rbp >>> movq

Re: [PATCH] i386: Don't use frame pointer without stack access

2017-08-07 Thread Uros Bizjak
On Mon, Aug 7, 2017 at 3:48 PM, Michael Matz wrote: > Hi, > > On Mon, 7 Aug 2017, H.J. Lu wrote: > >> >> [hjl@gnu-tools-1 pr81736]$ >> >> >> >> Does it mean clang is broken? >> > >> > In my book, yes. >> >> Does GCC do this for all targets or just x86? > > No idea. If so I'd say

Re: [PATCH] i386: Don't use frame pointer without stack access

2017-08-07 Thread Michael Matz
Hi, On Mon, 7 Aug 2017, Arjan van de Ven wrote: > I'm not surprised to see one. > I'm surprised to see a useless one. > > The "perf" benefit is real, and that's why I asked for one... but the reorder > made it an expensive 3 instruction nop for all intents and purposes. > If the pop was just

Re: [PATCH] i386: Don't use frame pointer without stack access

2017-08-07 Thread H.J. Lu
On Mon, Aug 7, 2017 at 9:19 AM, Arjan van de Ven wrote: > On 8/7/2017 9:16 AM, Michael Matz wrote: >> >> Hi, >> >> On Mon, 7 Aug 2017, Arjan van de Ven wrote: >> >>> wanting a framepointer is very nice and desired... >>> ... but if the optimizer/ins scheduler moves

Re: [PATCH] i386: Don't use frame pointer without stack access

2017-08-07 Thread Arjan van de Ven
On 8/7/2017 9:16 AM, Michael Matz wrote: Hi, On Mon, 7 Aug 2017, Arjan van de Ven wrote: wanting a framepointer is very nice and desired... ... but if the optimizer/ins scheduler moves instructions outside of the frame'd portion, (it does it for cases like below as well), the value is already

Re: [PATCH] i386: Don't use frame pointer without stack access

2017-08-07 Thread Michael Matz
Hi, On Mon, 7 Aug 2017, Arjan van de Ven wrote: > wanting a framepointer is very nice and desired... > ... but if the optimizer/ins scheduler moves instructions outside of the > frame'd portion, > (it does it for cases like below as well), the value is already negative for > these > functions

Re: [PATCH] i386: Don't use frame pointer without stack access

2017-08-07 Thread Arjan van de Ven
On 8/7/2017 8:43 AM, Jakub Jelinek wrote: On Mon, Aug 07, 2017 at 08:39:24AM -0700, H.J. Lu wrote: When Linux/x86-64 kernel is compiled with -fno-omit-frame-pointer. this optimization removes more than 730 pushq %rbp movq %rsp, %rbp popq %rbp If you don't want the frame pointer, why are you

Re: [PATCH] i386: Don't use frame pointer without stack access

2017-08-07 Thread Jakub Jelinek
On Mon, Aug 07, 2017 at 08:39:24AM -0700, H.J. Lu wrote: > When Linux/x86-64 kernel is compiled with -fno-omit-frame-pointer. > this optimization removes more than 730 > > pushq %rbp > movq %rsp, %rbp > popq %rbp If you don't want the frame pointer, why are you compiling with

Re: [PATCH] i386: Don't use frame pointer without stack access

2017-08-07 Thread H.J. Lu
On Mon, Aug 7, 2017 at 7:06 AM, Alexander Monakov wrote: > On Mon, 7 Aug 2017, Michael Matz wrote: >> > I am looking for a run-time test which breaks unwinder. >> >> I don't have one handy. Idea: make two threads, one endlessly looping in >> the "frame-less" function, the

Re: [PATCH] i386: Don't use frame pointer without stack access

2017-08-07 Thread Alexander Monakov
On Mon, 7 Aug 2017, Michael Matz wrote: > > I am looking for a run-time test which breaks unwinder. > > I don't have one handy. Idea: make two threads, one endlessly looping in > the "frame-less" function, the other causing a signal to the first thread, > and the signal handler checking that

Re: [PATCH] i386: Don't use frame pointer without stack access

2017-08-07 Thread Michael Matz
Hi, On Mon, 7 Aug 2017, H.J. Lu wrote: > >> [hjl@gnu-tools-1 pr81736]$ > >> > >> Does it mean clang is broken? > > > > In my book, yes. > > Does GCC do this for all targets or just x86? No idea. If so I'd say those other targets are broken as well (as long as the concept of frame pointer

Re: [PATCH] i386: Don't use frame pointer without stack access

2017-08-07 Thread H.J. Lu
On Mon, Aug 7, 2017 at 6:32 AM, Michael Matz wrote: > Hi, > > On Mon, 7 Aug 2017, H.J. Lu wrote: > >> >> This will break unwinders relying on frame pointers to exist on all >> >> functions, for which projects conciously forced a frame pointer with this >> >> option. I don't think

Re: [PATCH] i386: Don't use frame pointer without stack access

2017-08-07 Thread Andreas Schwab
On Aug 07 2017, Michael Matz wrote: > +/* { dg-final { scan-assembler "%\[re\]bp" } } */ Please use {} for regexps. Andreas. -- Andreas Schwab, SUSE Labs, sch...@suse.de GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 "And now for something completely

Re: [PATCH] i386: Don't use frame pointer without stack access

2017-08-07 Thread Michael Matz
Hi, On Mon, 7 Aug 2017, H.J. Lu wrote: > >> This will break unwinders relying on frame pointers to exist on all > >> functions, for which projects conciously forced a frame pointer with this > >> option. I don't think we can simply override user specified explicit > >> wishes in this way,

Re: [PATCH] i386: Don't use frame pointer without stack access

2017-08-07 Thread H.J. Lu
On Mon, Aug 7, 2017 at 6:21 AM, Uros Bizjak wrote: > On Mon, Aug 7, 2017 at 3:15 PM, Michael Matz wrote: >> Hi, >> >> On Mon, 7 Aug 2017, Uros Bizjak wrote: >> >>> On Sun, Aug 6, 2017 at 9:40 PM, H.J. Lu wrote: >>> > When there is no stack

Re: [PATCH] i386: Don't use frame pointer without stack access

2017-08-07 Thread Uros Bizjak
On Mon, Aug 7, 2017 at 3:15 PM, Michael Matz wrote: > Hi, > > On Mon, 7 Aug 2017, Uros Bizjak wrote: > >> On Sun, Aug 6, 2017 at 9:40 PM, H.J. Lu wrote: >> > When there is no stack access, there is no need to use frame pointer >> > even if

Re: [PATCH] i386: Don't use frame pointer without stack access

2017-08-07 Thread Michael Matz
Hi, On Mon, 7 Aug 2017, Uros Bizjak wrote: > On Sun, Aug 6, 2017 at 9:40 PM, H.J. Lu wrote: > > When there is no stack access, there is no need to use frame pointer > > even if -fno-omit-frame-pointer is used. > > > > Tested on i686 and x86-64. OK for trunk? > > LGTM.

Re: [PATCH] i386: Don't use frame pointer without stack access

2017-08-07 Thread Uros Bizjak
On Sun, Aug 6, 2017 at 9:40 PM, H.J. Lu wrote: > When there is no stack access, there is no need to use frame pointer > even if -fno-omit-frame-pointer is used. > > Tested on i686 and x86-64. OK for trunk? > > H.J. > --- > gcc/ > > PR target/81736 > *

[PATCH] i386: Don't use frame pointer without stack access

2017-08-06 Thread H.J. Lu
When there is no stack access, there is no need to use frame pointer even if -fno-omit-frame-pointer is used. Tested on i686 and x86-64. OK for trunk? H.J. --- gcc/ PR target/81736 * config/i386/i386.c (ix86_finalize_stack_realign_flags): Renamed to ...