[AArch64] [GlobalISel] Fix clobbered callee saved registers with win64 varargs
authorMartin Storsjö <martin@martin.st>
Fri, 18 Aug 2023 12:23:44 +0000 (15:23 +0300)
committerTobias Hieta <tobias@hieta.se>
Tue, 22 Aug 2023 05:48:46 +0000 (07:48 +0200)
commit96d150b34f1a3e10e983ebe5be34c29a42a4b72c
tree8be980dec663ff6ab6d844218c7fc9fc6286bdbd
parent6a8234396322ac6265f39ee439c71bc689b595e9
[AArch64] [GlobalISel] Fix clobbered callee saved registers with win64 varargs

This fixes a regression since 1c10d5b175992a9d056a2d763a932e5652386fc1
/ https://reviews.llvm.org/D130903 by applying the same fix from
SelectionDAG from 8cb3667541a94c4fa11b06e19020f753414c1d03 /
https://reviews.llvm.org/D35720.

This could possibly have been detected if the existing testcases
in win64_vararg.ll had been tested with GlobalISel too, but all
the IR snippets there fail to be translated with GlobalISel.

This adds a separate testcase based on real world LLVM IR (instead of
hand-reduced IR), which GlobalISel does translate happily - tested
with both SelectionDAG and GlobalISel.

Before this change, the stack object locations (visible in MIR
with "llc -print-after-all") didn't match with what the prologue
emitted by AArch64FrameLowering actually looked like, which caused
clobbered callee saved registers when function local stack objects
aliased the actual location of the callee saved registers.

This fixes https://github.com/llvm/llvm-project/issues/64740.

Differential Revision: https://reviews.llvm.org/D158272

(cherry picked from commit 955d7615bd7563cc78a5106215daf9e6e47ffb5e)
llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp
llvm/test/CodeGen/AArch64/win64_vararg2.ll [new file with mode: 0644]