<div dir="ltr">Hi Behan,<div><br></div><div>Only saw this thread now. I think having the built-in makes sense, but you sent the description and patch to the LLVM list, not the Clang list. ;)</div><div><br></div><div>I'd copy the cfe-dev, but I think now the thread is more complex than cross-posting would allow. So, maybe it'd be better if you posted there again, your original email, the patch and some of the comments on this thread.</div>
<div><br></div><div>cheers,</div><div>--renato</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On 5 November 2013 16:15, Behan Webster <span dir="ltr"><<a href="mailto:behanw@converseincode.com" target="_blank">behanw@converseincode.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000"><div><div class="h5">
<div>On 11/05/13 11:30, Jean-Daniel Dupas
wrote:<br>
</div>
<blockquote type="cite">
<br>
<div>
<div>Le 5 nov. 2013 à 19:00, Behan Webster <<a href="mailto:behanw@converseincode.com" target="_blank">behanw@converseincode.com</a>>
a écrit :</div>
<br>
<blockquote type="cite">
<div style="font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
On 11/05/13 09:26, Konstantin Tokarev wrote:<br>
<blockquote type="cite"><br>
11.10.2013, 01:39, "Jakob Stoklund Olesen" <<a href="mailto:stoklund@2pi.dk" target="_blank">stoklund@2pi.dk</a>>:<br>
<blockquote type="cite">On Oct 10, 2013, at 12:32 PM,
Behan Webster <<a href="mailto:behanw@converseincode.com" target="_blank">behanw@converseincode.com</a>>
wrote:<br>
<br>
<blockquote type="cite">One of the issues the LLVMLinux
project is having is with the use of<br>
named registers in the Linux kernel code. The kernel
uses something like<br>
this in order to assign a C variable name to a
register (one for each<br>
kernel arch).<br>
<br>
register unsigned long current_stack_pointer
asm("esp");<br>
<br>
clang doesn't allow this kind of thing which required
a patch which less<br>
efficient:<br>
<br>
#define current_stack_pointer ({ \<br>
unsigned long esp; \<br>
asm("mov %%esp, %0" : "=r"(esp)); \<br>
esp; \<br>
})<br>
<br>
This works for both gcc and clang, but often adds in 3
extra<br>
instructions since you need to copy the stack pointer
to another<br>
register, but first that register needs to be saved to
the stack and<br>
then restored after the stackpointer has been used;
inefficient.<br>
</blockquote>
#define current_stack_pointer ({ \<br>
register unsigned long esp asm("esp"); \<br>
asm("" : "=r"(esp)); \<br>
esp; \<br>
})<br>
</blockquote>
And #ifdef it for each arch? Builtin would be much more
handy.<br>
</blockquote>
Actually no #ifdef is required with Jakob's suggestion
(works the same<br>
in both clang and gcc).<br>
<br>
</div>
</blockquote>
<div><br>
</div>
<div>It may works for both GCC and clang, it does not means it
will works with every arch linux supports (ARM, PPC, AArch, …)</div>
</div>
</blockquote></div></div>
True enough. Which is indeed another argument for
__builtin_stack_pointer().<br>
<br>
That point is precisely one of the reasons that we're pushing for
this addition.<div class="im"><br>
<br>
Behan<br>
<pre cols="72">--
Behan Webster
<a href="mailto:behanw@converseincode.com" target="_blank">behanw@converseincode.com</a></pre>
</div></div>
<br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br></blockquote></div><br></div>