Add comments and an assert to follow-up on r279113. NFC.

Philip commented on r279113 to ask for better comments as to
when to use the different versions of getName.  Its also possible
to assert in the simple case that we aren't an overloaded intrinsic
as those have to use the more capable version of getName.

Thanks for the comments Philip.

llvm-svn: 279466
This commit is contained in:
Pete Cooper 2016-08-22 20:18:28 +00:00
parent 775b554129
commit a5f8c722c4
2 changed files with 8 additions and 0 deletions

View File

@ -45,9 +45,15 @@ namespace Intrinsic {
};
/// Return the LLVM name for an intrinsic, such as "llvm.ppc.altivec.lvx".
/// Note, this version is for intrinsics with no overloads. Use the other
/// version of getName if overloads are required.
StringRef getName(ID id);
/// Return the LLVM name for an intrinsic, such as "llvm.ppc.altivec.lvx".
/// Note, this version of getName supports overloads, but is less efficient
/// than the StringRef version of this function. If no overloads are
/// requried, it is safe to use this version, but better to use the StringRef
/// version.
std::string getName(ID id, ArrayRef<Type*> Tys);
/// Return the function type for an intrinsic.

View File

@ -553,6 +553,8 @@ static std::string getMangledTypeStr(Type* Ty) {
StringRef Intrinsic::getName(ID id) {
assert(id < num_intrinsics && "Invalid intrinsic ID!");
assert(!isOverloaded(id) &&
"This version of getName does not support overloading");
return IntrinsicNameTable[id];
}