This patch emits a warning when the stack pointer register (R1) is found in
the clobber list of an inline asm statement. Clobbering the stack pointer is
not supported.
Details
- Reviewers
nemanjai stefanp - Group Reviewers
Restricted Project - Commits
- rG6a028296fe62: [PowerPC] Emit warning when SP is clobbered by asm
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp | ||
---|---|---|
396 | PowerPC overrides getReservedRegs(), why don't we use this function and only warn for R1 even no X1? |
llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp | ||
---|---|---|
396 | It is unfortunately not as simple as that. We do have some reserved registers that can be clobbered. For example R2 can be clobbered since the compiler will spill and restore it. Furthermore, there needs to be a 64-bit test as well. |
Addressing review comments. Added a comment about why we are not using getReservedRegs(). Added implementation for PPC64.
llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp | ||
---|---|---|
396 | Only marking R1/X1 as reserved for PowerPC should be working. But I still think using getReservedRegs() is a better way. If we reserve some registers which can be allocated for some cases conservatively, maybe we should change the logic in getReservedRegs? For the R2/X2 example, I saw there is a TODO to make it allocatable. And even we are aggressive to mark R2/X2(all registers in getReservedRegs()) as reserved, we have to choose which one of the below two cases is worse: Anyhow I will not be a blocker for this patch to get in as it is also right. |
This needs more work.
- We need a clang test case similar to clang/test/Misc/inline-asm-clobber-warning.c
- We need to handle r1 on both 64-bit and 32-bit because x1 is just an internal LLVM name
- We need to handle sp as an alias for r1 as GCC does
llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp | ||
---|---|---|
396 | While I certainly agree that only focusing on R1 is a bit problematic, false warnings aren't free. There are definitely projects that use inline asm and build with -Werror. Breaking such projects would definitely be an undesirable outcome. |
Adressing review comments. Added register alias sp for the register r1.
Added a front end testcase to test the location information and all of the
aliases for r1. Merged the back end test cases so that we are testing both
r1 and x1 in 32bit and 64bit.
PowerPC overrides getReservedRegs(), why don't we use this function and only warn for R1 even no X1?