From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: [PATCH 7/8] xen/x86: Fix get_cpu_info() when built with clang Date: Tue, 9 Feb 2016 20:01:47 +0000 Message-ID: <1455048108-5045-8-git-send-email-andrew.cooper3@citrix.com> References: <1455048108-5045-1-git-send-email-andrew.cooper3@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1455048108-5045-1-git-send-email-andrew.cooper3@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Xen-devel Cc: Andrew Cooper , Jan Beulich List-Id: xen-devel@lists.xenproject.org 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 --- CC: Jan Beulich --- xen/include/asm-x86/current.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/xen/include/asm-x86/current.h b/xen/include/asm-x86/current.h index f011d2d..15b99ff 100644 --- a/xen/include/asm-x86/current.h +++ b/xen/include/asm-x86/current.h @@ -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; } -- 2.1.4