OSDN Git Service

[AArch64] Treat x18 as callee-saved in functions with windows calling convention...
authorMartin Storsjö <martin@martin.st>
Tue, 30 Apr 2019 08:50:09 +0000 (11:50 +0300)
committerMartin Storsjö <martin@martin.st>
Sat, 30 May 2020 06:22:09 +0000 (09:22 +0300)
commitcf97e0ec42b800ade5a18401a35ada96f355693f
tree67de4f4570dcec0d8647e832cb55a87dff61811e
parent2388a096e7865c043e83ece4e26654bd3d1a20d5
[AArch64] Treat x18 as callee-saved in functions with windows calling convention on non-windows OSes

Treat it as callee-saved, and always back it up. When windows code calls
entry points in unix code, marked with the windows calling convention,
that unix code can call other functions that isn't compiled with
-ffixed-x18 which may clobber x18 freely. By backing it up and restoring
it on return, we preserve the register across the function call,
fulfilling this part of the windows calling convention on another OS.

This isn't enough for making sure that x18 is preseved when non-windows
code does a callback to windows code, but is a clear improvement over
the current status quo. Additionally, wine is nowadays building many
modules as PE DLLs, which avoids the callback issue altogether for those
DLLs.

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