[llvm] 879a557 - [ExpandVariadics] Clean up intrinsic declaration lookup (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 23 06:31:25 PDT 2025
Author: Nikita Popov
Date: 2025-06-23T15:31:17+02:00
New Revision: 879a55793a2d9540e9403938e4df6a827028a3ba
URL: https://github.com/llvm/llvm-project/commit/879a55793a2d9540e9403938e4df6a827028a3ba
DIFF: https://github.com/llvm/llvm-project/commit/879a55793a2d9540e9403938e4df6a827028a3ba.diff
LOG: [ExpandVariadics] Clean up intrinsic declaration lookup (NFC)
The comment was outdated, as getDeclarationIfExists has been
introduced in the meantime.
We also only use this in one place where neither the Tys.empty()
case nor the FT is relevant, so just include the call to
getDeclarationIfExists().
Added:
Modified:
llvm/lib/Transforms/IPO/ExpandVariadics.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/IPO/ExpandVariadics.cpp b/llvm/lib/Transforms/IPO/ExpandVariadics.cpp
index 16ffd503300ee..da60f521bf084 100644
--- a/llvm/lib/Transforms/IPO/ExpandVariadics.cpp
+++ b/llvm/lib/Transforms/IPO/ExpandVariadics.cpp
@@ -132,25 +132,6 @@ class VariadicABIInfo {
virtual ~VariadicABIInfo() = default;
};
-// Module implements getFunction() which returns nullptr on missing declaration
-// and getOrInsertFunction which creates one when absent. Intrinsics.h only
-// implements getDeclaration which creates one when missing. Checking whether
-// an intrinsic exists thus inserts it in the module and it then needs to be
-// deleted again to clean up.
-// The right name for the two functions on intrinsics would match Module::,
-// but doing that in a single change would introduce nullptr dereferences
-// where currently there are none. The minimal collateral damage approach
-// would split the change over a release to help downstream branches. As it
-// is unclear what approach will be preferred, implementing the trivial
-// function here in the meantime to decouple from that discussion.
-Function *getPreexistingDeclaration(Module *M, Intrinsic::ID Id,
- ArrayRef<Type *> Tys = {}) {
- if (Tys.empty())
- return Intrinsic::getDeclarationIfExists(M, Id);
- auto *FT = Intrinsic::getType(M->getContext(), Id, Tys);
- return Intrinsic::getDeclarationIfExists(M, Id, Tys, FT);
-}
-
class ExpandVariadics : public ModulePass {
// The pass construction sets the default to optimize when called from middle
@@ -201,7 +182,7 @@ class ExpandVariadics : public ModulePass {
bool Changed = false;
const DataLayout &DL = M.getDataLayout();
if (Function *Intrinsic =
- getPreexistingDeclaration(&M, ID, {IntrinsicArgType})) {
+ Intrinsic::getDeclarationIfExists(&M, ID, {IntrinsicArgType})) {
for (User *U : make_early_inc_range(Intrinsic->users()))
if (auto *I = dyn_cast<InstructionType>(U))
Changed |= expandVAIntrinsicCall(Builder, DL, I);
More information about the llvm-commits
mailing list