diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp --- a/llvm/lib/IR/Function.cpp +++ b/llvm/lib/IR/Function.cpp @@ -781,6 +781,8 @@ std::string Intrinsic::getName(ID id, ArrayRef Tys) { assert(id < num_intrinsics && "Invalid intrinsic ID!"); + assert((Tys.empty() || Intrinsic::isOverloaded(id)) && + "This version of getName is for overloaded intrinsics only"); std::string Result(IntrinsicNameTable[id]); for (Type *Ty : Tys) { Result += "." + getMangledTypeStr(Ty); @@ -1243,7 +1245,7 @@ // There can never be multiple globals with the same name of different types, // because intrinsics must be a specific type. return cast( - M->getOrInsertFunction(getName(id, Tys), + M->getOrInsertFunction(Tys.empty() ? getName(id) : getName(id, Tys), getType(M->getContext(), id, Tys)) .getCallee()); }