[llvm] fix cratch in tail call return type (PR #210579)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 19 01:19:02 PDT 2026
https://github.com/SomeFlyingThing updated https://github.com/llvm/llvm-project/pull/210579
>From 920ead400a04fa5257993815d23360d442b7de4c Mon Sep 17 00:00:00 2001
From: SomeFlyingThing <306498559+SomeFlyingThing at users.noreply.github.com>
Date: Sun, 19 Jul 2026 08:52:10 +0100
Subject: [PATCH] fix cratch in tail call return type
---
llvm/lib/CodeGen/Analysis.cpp | 6 ++++--
llvm/test/CodeGen/X86/tail-call-empty-aggregate.ll | 9 +++++++++
2 files changed, 13 insertions(+), 2 deletions(-)
create mode 100644 llvm/test/CodeGen/X86/tail-call-empty-aggregate.ll
diff --git a/llvm/lib/CodeGen/Analysis.cpp b/llvm/lib/CodeGen/Analysis.cpp
index 9ece9f0c187a2..c4d50b38479a5 100644
--- a/llvm/lib/CodeGen/Analysis.cpp
+++ b/llvm/lib/CodeGen/Analysis.cpp
@@ -692,8 +692,10 @@ bool llvm::returnTypeIsEligibleForTailCall(const Function *F,
// We've exhausted the values produced by the tail call instruction, the
// rest are essentially undef. The type doesn't really matter, but we need
// *something*.
- Type *SlotType =
- ExtractValueInst::getIndexedType(RetSubTypes.back(), RetPath.back());
+ Type *SlotType = RetVal->getType();
+ if (!RetPath.empty())
+ SlotType = ExtractValueInst::getIndexedType(RetSubTypes.back(),
+ RetPath.back());
CallVal = UndefValue::get(SlotType);
}
diff --git a/llvm/test/CodeGen/X86/tail-call-empty-aggregate.ll b/llvm/test/CodeGen/X86/tail-call-empty-aggregate.ll
new file mode 100644
index 0000000000000..1b2e86af6f79b
--- /dev/null
+++ b/llvm/test/CodeGen/X86/tail-call-empty-aggregate.ll
@@ -0,0 +1,9 @@
+; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -o /dev/null
+
+declare { {} } @callee()
+
+define i32 @caller() {
+entry:
+ %call = tail call { {} } @callee()
+ ret i32 0
+}
More information about the llvm-commits
mailing list