[cfe-dev] A new builtin: __builtin_stack_pointer()

Behan Webster behanw at converseincode.com
Thu Nov 7 18:29:34 PST 2013


On 11/07/13 01:47, Joerg Sonnenberger wrote:
> On Wed, Nov 06, 2013 at 05:46:43PM -0800, Behan Webster wrote:
>> Another way would be to introduce a new builtin in parallel to others
>> like __builtin_return_address(). Essentially adding a
>> __builtin_stack_pointer() which does what the above code does. The idea
>> would be to get something like this added to both clang and gcc in order
>> to make this work across compilers, and across arches.
> You still haven't said what the intended behavior of this builtin is
> when the function containing it is inlined.
The intent in all situations is for it to use the current value in the
stack pointer register. It doesn't matter whether it is inlined or not.
It should be the immediate value of R13 on ARM or esp on X86_64 (etc for
other arches).

The idea is to preclude the need to use ASM to move the value in the
stack pointer to another register in order to use it in C code (which is
inefficient).

Essentially I'm looking for a better solution than adding a C symbol
name to the stack register.

Does that make sense?

Behan

-- 
Behan Webster
behanw at converseincode.com




More information about the cfe-dev mailing list