[llvm] [PowerPC] Expand global named register support (PR #112603)

Lei Huang via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 23 06:33:44 PDT 2024


lei137 wrote:

> For what it's worth, this breaks building the Linux kernel for 32-bit powerpc for me because [the kernel uses `r2` as a global register variable for `current`](https://elixir.bootlin.com/linux/v6.11.4/source/arch/powerpc/include/asm/current.h#L33).
> 
> ```
> $ make -skj"$(nproc)" ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu- LLVM=1 LLVM_IAS=0 mrproper pmac32_defconfig ipc/namespace.o
> fatal error: error in backend: Trying to obtain a reserved register "r2".
> ...
> ```
> 
> While this seems expected given the change, just in case, I ran this through `cvise`, which spits out:
> 
> ```c
> register struct task_struct *current asm("r2");
> struct task_struct {
>   struct cred *cred;
> };
> struct cred {
>   int euid;
> } inc_ucount(int);
> int *create_ipc_ns() {
>   inc_ucount(({ ({ current->cred; })->euid; }));
>   return (void *)8;
> }
> ```
> 
> which works with `clang` immediately prior to this change and GCC:
> 
> ```
> $ clang --version | head -1
> ClangBuiltLinux clang version 20.0.0git (https://github.com/llvm/llvm-project.git 06d192925d3510d0af6c10e6f64f6deabf66b75f)
> 
> $ clang --target=powerpc-linux-gnu -Wall -Werror -Wfatal-errors -c -o /dev/null namespace.i
> fatal error: error in backend: Trying to obtain a reserved register "r2".
> ...
> ```
> 
> ```
> $ clang --version | head -1
> ClangBuiltLinux clang version 20.0.0git (https://github.com/llvm/llvm-project.git e57548387000071562f44bfd66644480c8e6542d)
> 
> $ clang --target=powerpc-linux-gnu -Wall -Werror -Wfatal-errors -c -o /dev/null namespace.i
> ```
> 
> ```
> $ powerpc-linux-gcc --version | head -1
> powerpc-linux-gcc (GCC) 14.2.0
> 
> $ powerpc-linux-gcc -O2 -Wall -Werror -Wfatal-errors -c -o /dev/null namespace.i
> ```

Thanks for reporting this.  I will revert this change to unblock you and investigate further.

https://github.com/llvm/llvm-project/pull/112603


More information about the llvm-commits mailing list