Add comments and an assert to follow-up on r279113. NFC.
authorPete Cooper <peter_cooper@apple.com>
Mon, 22 Aug 2016 20:18:28 +0000 (20:18 +0000)
committerPete Cooper <peter_cooper@apple.com>
Mon, 22 Aug 2016 20:18:28 +0000 (20:18 +0000)
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

llvm/include/llvm/IR/Intrinsics.h
llvm/lib/IR/Function.cpp

index 29760b2..66894cd 100644 (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.
index 90f94e6..fa34158 100644 (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];
 }