Issue 108019
Summary [Clang] Clang vs. GCC Frame Pointer Differences
Labels clang
Assignees
Reporter guoxin049
    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
https://github.com/llvm/llvm-project/blob/cb30169422446b79d99df12b4cf5ab3d9d46d54c/llvm/lib/Target/ARM/ARMSubtarget.h#L374-L379


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

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to