Re: [PATCH] Add __builtin_stack_top

2015-08-19 Thread H.J. Lu
On Wed, Aug 19, 2015 at 5:51 AM, Segher Boessenkool seg...@kernel.crashing.org wrote: On Wed, Aug 19, 2015 at 05:23:41AM -0700, H.J. Lu wrote: You might have a reason why you want the entry stack address instead of the frame address, but you didn't really explain I think? Or I

Re: [PATCH] Add __builtin_stack_top

2015-08-19 Thread H.J. Lu
On Tue, Aug 4, 2015 at 1:50 PM, H.J. Lu hjl.to...@gmail.com wrote: On Tue, Aug 4, 2015 at 1:45 PM, Segher Boessenkool seg...@kernel.crashing.org wrote: On Tue, Aug 04, 2015 at 01:00:32PM -0700, H.J. Lu wrote: There is another issue with x86, maybe other targets. You can't get the real stack

Re: [PATCH] Add __builtin_stack_top

2015-08-19 Thread Segher Boessenkool
On Wed, Aug 19, 2015 at 05:23:41AM -0700, H.J. Lu wrote: You might have a reason why you want the entry stack address instead of the frame address, but you didn't really explain I think? Or I missed it. What would a C program do with this, that it cannot do with the frame

Re: [PATCH] Add __builtin_stack_top

2015-08-19 Thread H.J. Lu
On Wed, Aug 19, 2015 at 6:00 AM, H.J. Lu hjl.to...@gmail.com wrote: On Wed, Aug 19, 2015 at 5:51 AM, Segher Boessenkool seg...@kernel.crashing.org wrote: On Wed, Aug 19, 2015 at 05:23:41AM -0700, H.J. Lu wrote: You might have a reason why you want the entry stack address instead of the

Re: [PATCH] Add __builtin_stack_top

2015-08-19 Thread H.J. Lu
On Wed, Aug 19, 2015 at 9:58 AM, Segher Boessenkool seg...@kernel.crashing.org wrote: On Wed, Aug 19, 2015 at 08:25:49AM -0700, H.J. Lu wrote: Here is a patch to add __builtin_argument_pointer. I only have Sorry to be a pain but... all the other builtins use _address instead of _pointer,

Re: [PATCH] Add __builtin_stack_top

2015-08-19 Thread Segher Boessenkool
On Wed, Aug 19, 2015 at 10:08:01AM -0700, H.J. Lu wrote: Maybe something like (heavily cut'n'pasted): @deftypefn {Built-in Function} {void *} __builtin_argument_address (void) This function is similar to @code{__builtin_frame_address} with an argument of 0, but it returns the address

Re: [PATCH] Add __builtin_stack_top

2015-08-19 Thread H.J. Lu
On Wed, Aug 19, 2015 at 10:48 AM, Segher Boessenkool seg...@kernel.crashing.org wrote: On Wed, Aug 19, 2015 at 10:08:01AM -0700, H.J. Lu wrote: Maybe something like (heavily cut'n'pasted): @deftypefn {Built-in Function} {void *} __builtin_argument_address (void) This function is similar

Re: [PATCH] Add __builtin_stack_top

2015-08-19 Thread Segher Boessenkool
On Wed, Aug 19, 2015 at 08:25:49AM -0700, H.J. Lu wrote: Here is a patch to add __builtin_argument_pointer. I only have Sorry to be a pain but... all the other builtins use _address instead of _pointer, it's probably best to follow that. -- Built-in Function: void *

Re: [PATCH] Add __builtin_stack_top

2015-08-19 Thread Segher Boessenkool
On Wed, Aug 19, 2015 at 03:18:46PM -0700, H.J. Lu wrote: @deftypefn {Built-in Function} {void *} __builtin_argument_pointer (void) This function is similar to @code{__builtin_frame_address} with an argument of 0, but it returns the address of the incoming arguments to the current function

Re: [PATCH] Add __builtin_stack_top

2015-08-19 Thread H.J. Lu
On Wed, Aug 19, 2015 at 3:10 PM, Segher Boessenkool seg...@kernel.crashing.org wrote: On Wed, Aug 19, 2015 at 02:53:47PM -0700, H.J. Lu wrote: How about this @deftypefn {Built-in Function} {void *} __builtin_argument_pointer (void) This function is similar to @code{__builtin_frame_address}

Re: [PATCH] Add __builtin_stack_top

2015-08-19 Thread H.J. Lu
On Wed, Aug 19, 2015 at 10:53 AM, H.J. Lu hjl.to...@gmail.com wrote: On Wed, Aug 19, 2015 at 10:48 AM, Segher Boessenkool seg...@kernel.crashing.org wrote: On Wed, Aug 19, 2015 at 10:08:01AM -0700, H.J. Lu wrote: Maybe something like (heavily cut'n'pasted): @deftypefn {Built-in

Re: [PATCH] Add __builtin_stack_top

2015-08-19 Thread Segher Boessenkool
On Wed, Aug 19, 2015 at 02:53:47PM -0700, H.J. Lu wrote: How about this @deftypefn {Built-in Function} {void *} __builtin_argument_pointer (void) This function is similar to @code{__builtin_frame_address} with an argument of 0, but it returns the address of the incoming arguments to the

Re: [PATCH] Add __builtin_stack_top

2015-08-04 Thread Mike Stump
On Aug 4, 2015, at 5:30 AM, H.J. Lu hjl.to...@gmail.com wrote: Where does this feature belong? I prefer the middle end.

Re: [PATCH] Add __builtin_stack_top

2015-08-04 Thread H.J. Lu
On Tue, Aug 4, 2015 at 8:40 AM, Mike Stump mikest...@comcast.net wrote: On Aug 4, 2015, at 5:30 AM, H.J. Lu hjl.to...@gmail.com wrote: Where does this feature belong? I prefer the middle end. Any comments on my middle-end patch? Thanks. -- H.J.

Re: [PATCH] Add __builtin_stack_top

2015-08-04 Thread H.J. Lu
On Tue, Aug 4, 2015 at 10:43 AM, Segher Boessenkool seg...@kernel.crashing.org wrote: On Tue, Aug 04, 2015 at 10:28:00AM -0700, H.J. Lu wrote: Any comments on my middle-end patch? So, if the answer is the same as frame_address (0), why not have the fallback just expand to that? Then,

Re: [PATCH] Add __builtin_stack_top

2015-08-04 Thread Mike Stump
On Aug 4, 2015, at 8:44 AM, H.J. Lu hjl.to...@gmail.com wrote: On Tue, Aug 4, 2015 at 8:40 AM, Mike Stump mikest...@comcast.net wrote: On Aug 4, 2015, at 5:30 AM, H.J. Lu hjl.to...@gmail.com wrote: Where does this feature belong? I prefer the middle end. Any comments on my middle-end

Re: [PATCH] Add __builtin_stack_top

2015-08-04 Thread H.J. Lu
On Tue, Aug 4, 2015 at 10:16 AM, Mike Stump mikest...@comcast.net wrote: On Aug 4, 2015, at 8:44 AM, H.J. Lu hjl.to...@gmail.com wrote: On Tue, Aug 4, 2015 at 8:40 AM, Mike Stump mikest...@comcast.net wrote: On Aug 4, 2015, at 5:30 AM, H.J. Lu hjl.to...@gmail.com wrote: Where does this feature

Re: [PATCH] Add __builtin_stack_top

2015-08-04 Thread Segher Boessenkool
On Tue, Aug 04, 2015 at 10:28:00AM -0700, H.J. Lu wrote: Any comments on my middle-end patch? So, if the answer is the same as frame_address (0), why not have the fallback just expand to that? Then, one can use this builtin everywhere that frame address is used today. People that

Re: [PATCH] Add __builtin_stack_top

2015-08-04 Thread H.J. Lu
On Tue, Aug 4, 2015 at 11:50 AM, H.J. Lu hjl.to...@gmail.com wrote: On Tue, Aug 4, 2015 at 10:43 AM, Segher Boessenkool seg...@kernel.crashing.org wrote: On Tue, Aug 04, 2015 at 10:28:00AM -0700, H.J. Lu wrote: Any comments on my middle-end patch? So, if the answer is the same as

Re: [PATCH] Add __builtin_stack_top

2015-08-04 Thread H.J. Lu
On Tue, Aug 4, 2015 at 12:29 PM, Segher Boessenkool seg...@kernel.crashing.org wrote: On Tue, Aug 04, 2015 at 11:50:00AM -0700, H.J. Lu wrote: The motivation of __builtin_stack_top is that frame_address requires a frame pointer register, which isn't desirable for x86. __builtin_stack_top

Re: [PATCH] Add __builtin_stack_top

2015-08-04 Thread H.J. Lu
On Tue, Aug 4, 2015 at 1:45 PM, Segher Boessenkool seg...@kernel.crashing.org wrote: On Tue, Aug 04, 2015 at 01:00:32PM -0700, H.J. Lu wrote: There is another issue with x86, maybe other targets. You can't get the real stack top when stack is realigned and -maccumulate-outgoing-args isn't

Re: [PATCH] Add __builtin_stack_top

2015-08-04 Thread Segher Boessenkool
On Tue, Aug 04, 2015 at 01:00:32PM -0700, H.J. Lu wrote: There is another issue with x86, maybe other targets. You can't get the real stack top when stack is realigned and -maccumulate-outgoing-args isn't used since ix86_expand_prologue will create and return another stack frame for

Re: [PATCH] Add __builtin_stack_top

2015-08-04 Thread Segher Boessenkool
On Tue, Aug 04, 2015 at 11:50:00AM -0700, H.J. Lu wrote: The motivation of __builtin_stack_top is that frame_address requires a frame pointer register, which isn't desirable for x86. __builtin_stack_top doesn't require a frame pointer register. If the target just returns

Re: [PATCH] Add __builtin_stack_top to x86 backend

2015-08-03 Thread Uros Bizjak
On Thu, Jul 30, 2015 at 8:41 PM, H.J. Lu hongjiu...@intel.com wrote: On Tue, Jul 21, 2015 at 02:45:39PM -0700, H.J. Lu wrote: When __builtin_frame_address is used to retrieve the address of the function stack frame, the frame pointer is always kept, which wastes one register and 2