[AArch64] Treat x18 as callee-saved in functions with Windows calling convention...
authorVladislav Dzhidzhoev <vdzhidzhoev@accesssoftek.com>
Wed, 27 Jul 2022 20:54:56 +0000 (23:54 +0300)
committerVladislav Dzhidzhoev <vdzhidzhoev@accesssoftek.com>
Tue, 2 Aug 2022 17:33:42 +0000 (20:33 +0300)
commit71aecbb75c7d8b603b1882afa7301e54f3091587
tree9880919652d81756c5b8e5749bcad905c2d9f80d
parentbb99d4b11d84ae178d9ea3ea2c9da4d4c2e1eafc
[AArch64] Treat x18 as callee-saved in functions with Windows calling convention on Darwin

rGcf97e0ec42b8 makes $x18 to be treated as callee-saved in functions with
Windows calling convention on non-Windows OSes.

Here we mark $x18 as callee-saved for functions with Windows calling
convention on Darwin, as well as on other non-Windows platforms, in
order to prevent some miscompilations (like miscompilation of
win64cc-darwin-backup-x18.ll).

Since getCalleeSavedRegs doesn't return x18 in list of callee-saved
registers, assignCalleeSavedSpillSlots and determineCalleeSaves
consider different sets of registers as callee-saved. It causes an
error:
```
Assertion failed: ((!HasCalleeSavedStackSize || getCalleeSavedStackSize() == Size) && "Invalid size calculated for callee saves"), function getCalleeSavedStackSize, file
AArch64MachineFunctionInfo.h, line 292.
```

Differential Revision: https://reviews.llvm.org/D130676
llvm/lib/Target/AArch64/AArch64CallingConvention.td
llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
llvm/lib/Target/AArch64/AArch64RegisterInfo.cpp
llvm/test/CodeGen/AArch64/win64cc-darwin-backup-x18.ll [new file with mode: 0644]