It looks like the code generated by clang and gcc do different things. On gcc, s8 is updated to 123. On clang, s8 is temporarily updated to 123, only to be restored to its original value. Is there some sort of UB going on or is this a miscompile?
The spills are generated because this register is included in as a SavedReg in determineCalleeSaves. TargetFrameLowering::determineCalleeSaves makes a call to getCalleeSavedRegs and this register is part of this list. We could probably avoid adding it to the list in the first place, or have determineCalleeSaves skip over it in this case.
gcc doesn’t spill the register when used as a global register variable regardless of -ffixed-x24, but llvm doesn’t allow x24 as a global register variable without -ffixed-x24.
I’m not sure MRI::isReserved approach would be correct. For example, some targets may reserve a register, separate from the user fixing it. such as x4 on RISC-V. This is different than passing -ffixed-x4.
I’m not sure MRI::isReserved approach would be correct. For example, some targets may reserve a register, separate from the user fixing it. such as x4 on RISC-V. This is different than passing -ffixed-x4 .
Why is it different? X4 isn’t part of the callee saved register list because it is always reserved.