On 01/09/15 12:06, Daniel Sanders wrote: >> -----Original Message----- >> From: David Daney [mailto:ddaney.cavm@xxxxxxxxx] >> Sent: 09 January 2015 17:26 >> To: Daniel Sanders >> Cc: Sergei Shtylyov; linux-mips@xxxxxxxxxxxxxx; Ralf Baechle; Paul Burton; >> Markos Chandras; James Hogan; Behan Webster >> Subject: Re: [PATCH] MIPS: Changed current_thread_info() to an equivalent >> supported by both clang and GCC >> >> On 01/09/2015 05:23 AM, Daniel Sanders wrote: >>> Hi, >>> >>> Thanks for the quick reply. >>> >>>> -----Original Message----- >>>> From: Sergei Shtylyov [mailto:sergei.shtylyov@xxxxxxxxxxxxxxxxxx] >>>> Sent: 09 January 2015 12:18 >>>> To: Daniel Sanders; linux-mips@xxxxxxxxxxxxxx; Ralf Baechle >>>> Cc: Paul Burton; Markos Chandras; James Hogan; Behan Webster >>>> Subject: Re: [PATCH] MIPS: Changed current_thread_info() to an equivalent >>>> supported by both clang and GCC >>>> >>>> Hello. >>>> >>>> On 1/9/2015 3:06 PM, Daniel Sanders wrote: >>>> >>>>> Without this, a 'break' instruction is executed very early in the boot and >>>>> the boot hangs. >>>>> The problem is that clang doesn't honour named registers on local >> variables >>>>> and silently treats them as normal uninitialized variables. However, it >>>>> does honour them on global variables. >> Why not fix clang instead? > There's some significant implementation difficulties in LLVM that appear to stem from it not being designed to accommodate this extension. There were also some objections based on the future direction of LLVM. The thread can be found at http://lists.cs.uiuc.edu/pipermail/llvmdev/2014-March/071555.html. I've linked to the bit where the issues started to be discussed rather than the start of the thread. > > Difficulty and objections aside, it's also a very large amount of work to support a single (as far as I know) user of named register locals, especially when Linux has already accepted patches to switch named register locals to named register globals elsewhere. On balance, it seems best to change Linux. > >>>>> Signed-off-by: Daniel Sanders <daniel.sanders@xxxxxxxxxx> >>>> [...] >>>> >>>>> diff --git a/arch/mips/include/asm/thread_info.h >>>> b/arch/mips/include/asm/thread_info.h >>>>> index 99eea59..2a2f3c4 100644 >>>>> --- a/arch/mips/include/asm/thread_info.h >>>>> +++ b/arch/mips/include/asm/thread_info.h >>>>> @@ -58,11 +58,11 @@ struct thread_info { >>>>> #define init_stack (init_thread_union.stack) >>>>> >>>>> /* How to get the thread information struct from C. */ >>>>> +register struct thread_info *current_gp_register asm("$28"); >>>> *static* missing? >>>> >>>> WBR, Sergei >>> Combining 'register' and 'static' is invalid. >> Defining global variables in header files is also invalid. > I agree with that statement but named register globals are not the same as normal global variables. In particular, they do not take up space in the data section and they do not have an entry in the symbol table. They can therefore be included in multiple objects without causing link errors. Daniel's code is in line with the solution already used in both the arm and arm64/aarch64 arches which works with both gcc and clang. Just in case that helps. Behan -- Behan Webster behanw@xxxxxxxxxxxxxxxxxx