<div dir="ltr">On Thu, Nov 7, 2013 at 6:29 PM, Behan Webster <span dir="ltr"><<a href="mailto:behanw@converseincode.com" target="_blank">behanw@converseincode.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On 11/07/13 01:47, Joerg Sonnenberger wrote:<br>
> On Wed, Nov 06, 2013 at 05:46:43PM -0800, Behan Webster wrote:<br>
>> Another way would be to introduce a new builtin in parallel to others<br>
>> like __builtin_return_address(). Essentially adding a<br>
>> __builtin_stack_pointer() which does what the above code does. The idea<br>
>> would be to get something like this added to both clang and gcc in order<br>
>> to make this work across compilers, and across arches.<br>
> You still haven't said what the intended behavior of this builtin is<br>
> when the function containing it is inlined.<br>
</div>The intent in all situations is for it to use the current value in the<br>
stack pointer register. It doesn't matter whether it is inlined or not.<br>
It should be the immediate value of R13 on ARM or esp on X86_64 (etc for<br>
other arches).<br>
<br>
The idea is to preclude the need to use ASM to move the value in the<br>
stack pointer to another register in order to use it in C code (which is<br>
inefficient).<br>
<br>
Essentially I'm looking for a better solution than adding a C symbol<br>
name to the stack register.<br>
<br>
Does that make sense?</blockquote><div><br></div><div>Not yet. Why do you want this? What will you do with it? What semantics do you want the returned pointer to have? How can correct code ever do anything with this pointer? (Remember that the backend is in principle allowed to modify the stack pointer at any time, including between the point where you call this intrinsic and the point where you use its result.)</div>
</div></div></div>