When running 'opt -O2 verify-uselistorder-nodbg.lto.bc', there are 33m allocations. 8.2m
come from std::string allocations in Intrinsic::getName(). Turns out this method only
returns a std::string because it needs to handle overloads, but that is not the common case.
This adds an overload of getName which just returns a StringRef when there are no overloads
and so saves on the allocations.
llvm-svn: 279113
};
/// Return the LLVM name for an intrinsic, such as "llvm.ppc.altivec.lvx".
- std::string getName(ID id, ArrayRef<Type*> Tys = None);
+ StringRef getName(ID id);
+
+ /// Return the LLVM name for an intrinsic, such as "llvm.ppc.altivec.lvx".
+ std::string getName(ID id, ArrayRef<Type*> Tys);
/// Return the function type for an intrinsic.
FunctionType *getType(LLVMContext &Context, ID id,
return Result;
}
+StringRef Intrinsic::getName(ID id) {
+ assert(id < num_intrinsics && "Invalid intrinsic ID!");
+ return IntrinsicNameTable[id];
+}
+
std::string Intrinsic::getName(ID id, ArrayRef<Type*> Tys) {
assert(id < num_intrinsics && "Invalid intrinsic ID!");
std::string Result(IntrinsicNameTable[id]);