[llvm] [NFC][LLVM] Use `isIntrinsicVarArg` in Intrinsic::getType (PR #195528)
Rahul Joshi via llvm-commits
llvm-commits at lists.llvm.org
Sun May 3 07:09:30 PDT 2026
https://github.com/jurahul created https://github.com/llvm/llvm-project/pull/195528
None
>From f0c5062ebe399d0d8ee3d19c5f22a1f830e23989 Mon Sep 17 00:00:00 2001
From: Rahul Joshi <rjoshi at nvidia.com>
Date: Sun, 3 May 2026 07:07:55 -0700
Subject: [PATCH] [NFC][LLVM] Use `isIntrinsicVarArg` in Intrinsic::getType
---
llvm/lib/IR/Intrinsics.cpp | 27 +++++++++++----------------
1 file changed, 11 insertions(+), 16 deletions(-)
diff --git a/llvm/lib/IR/Intrinsics.cpp b/llvm/lib/IR/Intrinsics.cpp
index 22f2a8078f500..00cc17b3cabf5 100644
--- a/llvm/lib/IR/Intrinsics.cpp
+++ b/llvm/lib/IR/Intrinsics.cpp
@@ -37,6 +37,14 @@
using namespace llvm;
+// Forward declaration of static functions.
+static bool isIntrinsicVarArg(ArrayRef<Intrinsic::IITDescriptor> &Infos,
+ bool Consume);
+static bool isSignatureValid(FunctionType *FTy,
+ ArrayRef<Intrinsic::IITDescriptor> &Infos,
+ SmallVectorImpl<Type *> &OverloadTys,
+ raw_ostream &OS);
+
/// Table of string intrinsic names indexed by enum value.
#define GET_INTRINSIC_NAME_TABLE
#include "llvm/IR/IntrinsicImpl.inc"
@@ -601,21 +609,15 @@ FunctionType *Intrinsic::getType(LLVMContext &Context, ID id,
ArrayRef<Type *> OverloadTys) {
SmallVector<IITDescriptor, 8> Table;
getIntrinsicInfoTableEntries(id, Table);
-
ArrayRef<IITDescriptor> TableRef = Table;
+
+ bool IsVarArg = isIntrinsicVarArg(TableRef, /*Consume=*/true);
+
Type *ResultTy = DecodeFixedType(TableRef, OverloadTys, Context);
SmallVector<Type *, 8> ArgTys;
while (!TableRef.empty())
ArgTys.push_back(DecodeFixedType(TableRef, OverloadTys, Context));
-
- // VarArg intrinsics encode a void type as the last argument type. Detect that
- // and then drop the void argument.
- bool IsVarArg = false;
- if (!ArgTys.empty() && ArgTys.back()->isVoidTy()) {
- ArgTys.pop_back();
- IsVarArg = true;
- }
return FunctionType::get(ResultTy, ArgTys, IsVarArg);
}
@@ -779,13 +781,6 @@ Function *Intrinsic::getOrInsertDeclaration(Module *M, ID id,
return getOrInsertIntrinsicDeclarationImpl(M, id, OverloadTys, FT);
}
-static bool isIntrinsicVarArg(ArrayRef<Intrinsic::IITDescriptor> &Infos,
- bool Consume);
-static bool isSignatureValid(FunctionType *FTy,
- ArrayRef<Intrinsic::IITDescriptor> &Infos,
- SmallVectorImpl<Type *> &OverloadTys,
- raw_ostream &OS);
-
Function *Intrinsic::getOrInsertDeclaration(Module *M, ID id, Type *RetTy,
ArrayRef<Type *> ArgTys) {
// If the intrinsic is not overloaded, use the non-overloaded version.
More information about the llvm-commits
mailing list