[llvm] 8a68898 - [NFC][LLVM] Eliminate use of `getIntrinsicInfoTableEntries` from CloneFunction.cpp (#195448)

via llvm-commits llvm-commits at lists.llvm.org
Sun May 3 05:38:00 PDT 2026


Author: Rahul Joshi
Date: 2026-05-03T05:37:55-07:00
New Revision: 8a688983ab0b5aa3ac3cfbcd94d3727d023a169e

URL: https://github.com/llvm/llvm-project/commit/8a688983ab0b5aa3ac3cfbcd94d3727d023a169e
DIFF: https://github.com/llvm/llvm-project/commit/8a688983ab0b5aa3ac3cfbcd94d3727d023a169e.diff

LOG: [NFC][LLVM] Eliminate use of `getIntrinsicInfoTableEntries` from CloneFunction.cpp (#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.

Added: 
    

Modified: 
    llvm/lib/Transforms/Utils/CloneFunction.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Utils/CloneFunction.cpp b/llvm/lib/Transforms/Utils/CloneFunction.cpp
index 56ea6bc657c52..75342a5d1894f 100644
--- a/llvm/lib/Transforms/Utils/CloneFunction.cpp
+++ b/llvm/lib/Transforms/Utils/CloneFunction.cpp
@@ -13,6 +13,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/SmallVectorExtras.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Analysis/ConstantFolding.h"
 #include "llvm/Analysis/DomTreeUpdater.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,18 @@ 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::map_to_vector(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