Re: Builtin: stack pointer

2014-03-27 Thread Behan Webster

On 03/27/14 04:20, Renato Golin wrote:

Hi Jakub,

Just to make it clear, I'm not an official representative of Clang, or
LLVM, nor I was involved in all discussions about implementing
extensions either. I do not have an agenda to promote LLVM changes.
I also don't speak for either clang nor the Linux kernel, but merely for 
the LLVMLinux project team.


However, I am trying to promote change to both code bases such that the 
Linux kernel can be compiled with both gcc and clang. Indeed both myself 
and others in the project send patches upstream to both code bases.


__builtin_stack_pointer is an idea from a couple of us on the LLVMLinux 
project. Renato is merely helping us out connecting us to the right 
people to talk to.



To me this sounds like clang proposing extensions because they aren't
willing to implement existing extensions, not a good reason to change.
Actually the proposal was more about making it easier to solve this 
particular problem in a way which might be acceptable to all parties.


I'm open to all suggestions.

Behan

--
Behan Webster
beh...@converseincode.com



Re: [llvmlinux] Builtin: stack pointer

2014-03-27 Thread Behan Webster

On 03/27/14 03:44, Andrew Pinski wrote:

On Thu, Mar 27, 2014 at 3:25 AM, Renato Golin  wrote:

On 27 March 2014 10:12, Andreas Schwab  wrote:

Can't you use __builtin_frame_address (0) instead?

That would give me the frame pointer, not the stack pointer, and the
user would have to calculate manually the offset to get the actual
stack pointer, which would be target-specific, possibly making it even
worse. Is that what you meant?


So if we audit what the kernel uses this method.  There is stack
tracing code which is highly target dependent.

Yup.


And then there is current_thread_info which is also highly target
dependent code (though it can use __builtin_frame_address(0) there
since it is doing an alignment of a huge value at that point).
Already tried that. Patches doing exactly this in the ARM code in these 
cases were rejected as generates less efficient code in the situation 
where the kernel is compiled without a frame-pointer. So no, that is not 
acceptable to upstream kernel maintainers.


That is what led to this proposal.


I don't see why there needs to be an builtin function for this case,
adding one extra instruction inside an inline-asm for the moving from
the stack point to a normal register should be good enough.
Because one extra instruction was not acceptable upstream. Patch also 
rejected.



Take arch/arm64/include/asm/thread_info.h for an example,
__builtin_frame_address(0) should be good enough since the sp and fp
should be on the same page (that is what THREAD_SIZE is about).

Less efficient if compiled without a frame-pointer. Patch was rejected.


(so you need to split by arch with ifdefs),

Except it is already in the kernel anyways; not even by ifdefs but by
different files so the reasoning adding a new builtin is not useful.
For the existing cases this is true. However such a builtin would allow 
it to be used in common code (as a theoretical example).


Behan

--
Behan Webster
beh...@converseincode.com