Skip to content

Commit 879a557

Browse files
committed
[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().
1 parent 05491e0 commit 879a557

File tree

1 file changed

+1
-20
lines changed

1 file changed

+1
-20
lines changed

llvm/lib/Transforms/IPO/ExpandVariadics.cpp

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -132,25 +132,6 @@ class VariadicABIInfo {
132132
virtual ~VariadicABIInfo() = default;
133133
};
134134

135-
// Module implements getFunction() which returns nullptr on missing declaration
136-
// and getOrInsertFunction which creates one when absent. Intrinsics.h only
137-
// implements getDeclaration which creates one when missing. Checking whether
138-
// an intrinsic exists thus inserts it in the module and it then needs to be
139-
// deleted again to clean up.
140-
// The right name for the two functions on intrinsics would match Module::,
141-
// but doing that in a single change would introduce nullptr dereferences
142-
// where currently there are none. The minimal collateral damage approach
143-
// would split the change over a release to help downstream branches. As it
144-
// is unclear what approach will be preferred, implementing the trivial
145-
// function here in the meantime to decouple from that discussion.
146-
Function *getPreexistingDeclaration(Module *M, Intrinsic::ID Id,
147-
ArrayRef<Type *> Tys = {}) {
148-
if (Tys.empty())
149-
return Intrinsic::getDeclarationIfExists(M, Id);
150-
auto *FT = Intrinsic::getType(M->getContext(), Id, Tys);
151-
return Intrinsic::getDeclarationIfExists(M, Id, Tys, FT);
152-
}
153-
154135
class ExpandVariadics : public ModulePass {
155136

156137
// The pass construction sets the default to optimize when called from middle
@@ -201,7 +182,7 @@ class ExpandVariadics : public ModulePass {
201182
bool Changed = false;
202183
const DataLayout &DL = M.getDataLayout();
203184
if (Function *Intrinsic =
204-
getPreexistingDeclaration(&M, ID, {IntrinsicArgType})) {
185+
Intrinsic::getDeclarationIfExists(&M, ID, {IntrinsicArgType})) {
205186
for (User *U : make_early_inc_range(Intrinsic->users()))
206187
if (auto *I = dyn_cast<InstructionType>(U))
207188
Changed |= expandVAIntrinsicCall(Builder, DL, I);

0 commit comments

Comments
 (0)