[llvm] [Aarch64] [ISel] Don't save vaargs registers if vaargs are unused (PR #126780)
Pavel Skripkin via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 22 02:46:58 PST 2025
================
@@ -8189,7 +8189,7 @@ SDValue AArch64TargetLowering::LowerFormalArguments(
}
// varargs
- if (isVarArg) {
+ if (isVarArg && DAG.getMachineFunction().getFrameInfo().hasVAStart()) {
----------------
pskrgag wrote:
Hm, I don't think I get what you mean, sorry.
IIUC, GlobalIsel is quite new approach for generating machine code, which is supposed to be a successor for SelectionDAG. It can be turned on using `--global-isel=0`.
So, I didn't find any `hasVAStart()` references in GISel code and tried simple examples to see if such optimization exists.
After some tests I've observed that llc actually crashes on vaargs, when GISel is turned on. Here is godbolt link for x86 https://godbolt.org/z/q66feEb65. And locally (after addressing @ostannard review) I got similar failure on `CodeGen/AArch64/win64_vararg2.ll` test.
```
+ /home/paskripkin/Documents/git/llvm-project/build/bin/llc -global-isel -mtriple=aarch64-pc-win32
+ /home/paskripkin/Documents/git/llvm-project/build/bin/FileCheck /home/paskripkin/Documents/git/llvm-project/llvm/test/CodeGen/AArch64/win64_vararg2.ll --check-prefix=GISEL
LLVM ERROR: cannot select: G_VASTART %17:gpr(p0) :: (store (s64) into %ir.valist) (in function: va_func)
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /home/paskripkin/Documents/git/llvm-project/build/bin/llc -global-isel -mtriple=aarch64-pc-win32
1. Running pass 'Function Pass Manager' on module '<stdin>'.
2. Running pass 'InstructionSelect' on function '@va_func'
````
Is it known? If not, I will try to look deeper
https://github.com/llvm/llvm-project/pull/126780
More information about the llvm-commits
mailing list