[llvm] [NFC][ExpandVariadics] Pass VarargsTy instead of re-querying from alloca (PR #177434)
Jameson Nash via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 22 10:58:18 PST 2026
https://github.com/vtjnash created https://github.com/llvm/llvm-project/pull/177434
The struct type is already available at the call site, so pass it through to initializeStructAlloca() instead of retrieving it via getAllocatedType(). Reduces reliance on `getAllocatedType`.
>From fed856e39fbc9cb75309bc595b39ac39324eb6df Mon Sep 17 00:00:00 2001
From: Jameson Nash <vtjnash+github at gmail.com>
Date: Wed, 21 Jan 2026 19:17:55 +0000
Subject: [PATCH] [NFC][ExpandVariadics] Pass VarargsTy instead of re-querying
from alloca
The struct type is already available at the call site, so pass it
through to initializeStructAlloca() instead of retrieving it via
getAllocatedType(). Reduces reliance on `getAllocatedType`.
Co-Authored-By: Claude Opus 4.5 <noreply at anthropic.com>
---
llvm/lib/Transforms/IPO/ExpandVariadics.cpp | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/llvm/lib/Transforms/IPO/ExpandVariadics.cpp b/llvm/lib/Transforms/IPO/ExpandVariadics.cpp
index 36c94e9395c80..a908db0d1830a 100644
--- a/llvm/lib/Transforms/IPO/ExpandVariadics.cpp
+++ b/llvm/lib/Transforms/IPO/ExpandVariadics.cpp
@@ -310,9 +310,7 @@ class ExpandVariadics : public ModulePass {
}
void initializeStructAlloca(const DataLayout &DL, IRBuilder<> &Builder,
- AllocaInst *Alloced) {
-
- StructType *VarargsTy = cast<StructType>(Alloced->getAllocatedType());
+ AllocaInst *Alloced, StructType *VarargsTy) {
for (size_t I = 0; I < size(); I++) {
@@ -758,7 +756,7 @@ bool ExpandVariadics::expandCall(Module &M, IRBuilder<> &Builder, CallBase *CB,
// Initialize the fields in the struct
Builder.SetInsertPoint(CB);
Builder.CreateLifetimeStart(Alloced);
- Frame.initializeStructAlloca(DL, Builder, Alloced);
+ Frame.initializeStructAlloca(DL, Builder, Alloced, VarargsTy);
const unsigned NumArgs = FuncType->getNumParams();
SmallVector<Value *> Args(CB->arg_begin(), CB->arg_begin() + NumArgs);
More information about the llvm-commits
mailing list