[llvm] [NFC][LLVM] Eliminate use of `getIntrinsicInfoTableEntries` from CloneFunction.cpp (PR #195448)
Rahul Joshi via llvm-commits
llvm-commits at lists.llvm.org
Sat May 2 05:36:32 PDT 2026
https://github.com/jurahul created https://github.com/llvm/llvm-project/pull/195448
Simplify creation of constrained intrinsic calls by just using `getOrInsertDeclaration` that accepts arg and return types of an intrinsic and hence eliminating the need to look at the IIT descriptors to map overload types.
>From 2dd0b52f6127561a71f25fe8c5a399f16b4efacc Mon Sep 17 00:00:00 2001
From: Rahul Joshi <rjoshi at nvidia.com>
Date: Sat, 2 May 2026 05:32:22 -0700
Subject: [PATCH] [NFC][LLVM] Eliminate use of `getIntrinsicInfoTableEntries`
from CloneFunction.cpp
---
llvm/lib/Transforms/Utils/CloneFunction.cpp | 36 +++++----------------
1 file changed, 8 insertions(+), 28 deletions(-)
diff --git a/llvm/lib/Transforms/Utils/CloneFunction.cpp b/llvm/lib/Transforms/Utils/CloneFunction.cpp
index 56ea6bc657c52..3b2e6129468d1 100644
--- a/llvm/lib/Transforms/Utils/CloneFunction.cpp
+++ b/llvm/lib/Transforms/Utils/CloneFunction.cpp
@@ -12,6 +12,7 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/ConstantFolding.h"
@@ -470,33 +471,8 @@ PruningFunctionCloner::cloneInstruction(BasicBlock::const_iterator II) {
// be created. Assume the first arguments of constrained intrinsics are the
// same as the operands of original instruction.
- // Determine overloaded types of the intrinsic.
- SmallVector<Type *, 2> TParams;
- SmallVector<Intrinsic::IITDescriptor, 8> Descriptor;
- getIntrinsicInfoTableEntries(CIID, Descriptor);
- for (unsigned I = 0, E = Descriptor.size(); I != E; ++I) {
- Intrinsic::IITDescriptor Operand = Descriptor[I];
- switch (Operand.Kind) {
- case Intrinsic::IITDescriptor::Overloaded:
- if (Operand.getOverloadKind() != Intrinsic::IITDescriptor::AK_MatchType) {
- if (I == 0)
- TParams.push_back(OldInst.getType());
- else
- TParams.push_back(OldInst.getOperand(I - 1)->getType());
- }
- break;
- case Intrinsic::IITDescriptor::SameVecWidth:
- ++I;
- break;
- default:
- break;
- }
- }
-
// Create intrinsic call.
LLVMContext &Ctx = NewFunc->getContext();
- Function *IFn =
- Intrinsic::getOrInsertDeclaration(NewFunc->getParent(), CIID, TParams);
SmallVector<Value *, 4> Args;
unsigned NumOperands = OldInst.getNumOperands();
if (isa<CallInst>(OldInst))
@@ -510,15 +486,19 @@ PruningFunctionCloner::cloneInstruction(BasicBlock::const_iterator II) {
Args.push_back(MetadataAsValue::get(Ctx, MDString::get(Ctx, PredName)));
}
- // The last arguments of a constrained intrinsic are metadata that
- // represent rounding mode (absents in some intrinsics) and exception
- // behavior. The inlined function uses default settings.
+ // The last arguments of a constrained intrinsic are metadata that represent
+ // rounding mode (absent in some intrinsics) and exception behavior. The
+ // inlined function uses default settings.
if (Intrinsic::hasConstrainedFPRoundingModeOperand(CIID))
Args.push_back(
MetadataAsValue::get(Ctx, MDString::get(Ctx, "round.tonearest")));
Args.push_back(
MetadataAsValue::get(Ctx, MDString::get(Ctx, "fpexcept.ignore")));
+ SmallVector<Type *> ArgTys =
+ llvm::to_vector(llvm::map_range(Args, &Value::getType));
+ Function *IFn = Intrinsic::getOrInsertDeclaration(NewFunc->getParent(), CIID,
+ OldInst.getType(), ArgTys);
return CallInst::Create(IFn, Args, OldInst.getName() + ".strict");
}
More information about the llvm-commits
mailing list