x86: fix get_cpu_info() when built with clang

Clang understands the GCCism in use here, but still complains that sp is
unintialised.  In such cases, resort to the older version of this code, which
directly reads %rsp into the temporary variable.

Note that we still keep the GCCism in the default case, as it causes GCC to
create rather better assembly.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
This commit is contained in:
Andrew Cooper authored and Jan Beulich committed 2016-02-10 14:51:25 +01:00
1 parent 9fd8bbff56
commit c26b88bf64
1 file changed
+6
+6
View File
@@ -47,7 +47,13 @@ struct cpu_info {
static inline struct cpu_info *get_cpu_info(void)
{
#ifdef __clang__
/* Clang complains that sp in the else case is not initialised. */
unsigned long sp;
asm ( "mov %%rsp, %0" : "=r" (sp) );
#else
register unsigned long sp asm("rsp");
#endif
return (struct cpu_info *)((sp & ~(STACK_SIZE-1)) + STACK_SIZE) - 1;
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.