-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Open
Labels
backend:ARMquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!
Description
We used Clang 15 to build our kernel and encountered a problem during the process. I'm not sure if this is a bug or an issue with our configuration.
- The kernel code is as follows:
https://github.com/torvalds/linux/blob/2c85ebc57b3e1817b6ce1a6b703928e113a90442/arch/arm/kernel/unwind.c#L68-L77
enum regs {
#ifdef CONFIG_THUMB2_KERNEL
FP = 7,
#else
FP = 11,
#endif
SP = 13,
LR = 14,
PC = 15
};
When using CONFIG_THUMB2_KERNEL, the frame pointer (FP) is set to r7. However, after compiling with Clang 15 and setting the option '-mframe-chain=aapcs+leaf', the frame pointer changes to r11.
- I noticed that this part of the llvm code caused
llvm-project/llvm/lib/Target/ARM/ARMSubtarget.h
Lines 374 to 379 in cb30169
MCPhysReg getFramePointerReg() const { if (isTargetDarwin() || (!isTargetWindows() && isThumb() && !createAAPCSFrameChain())) return ARM::R7; return ARM::R11; }
When the -mframe-chain=aapcs+leaf
option is set, the createAAPCSFrameChain() function returns true, and the getFramePointerReg() function uses ARM::R11 as the frame pointer. However, when I compile with GCC using the options -mthumb -mabi=aapcs
, it still uses r7 as the frame pointer.
- This is my demo to illustrate the difference:
https://godbolt.org/z/GcMGhKvq1
Metadata
Metadata
Assignees
Labels
backend:ARMquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!