[llvm] r279466 - Add comments and an assert to follow-up on r279113. NFC.

Pete Cooper via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 22 13:18:29 PDT 2016


Author: pete
Date: Mon Aug 22 15:18:28 2016
New Revision: 279466

URL: http://llvm.org/viewvc/llvm-project?rev=279466&view=rev
Log:
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.

Modified:
    llvm/trunk/include/llvm/IR/Intrinsics.h
    llvm/trunk/lib/IR/Function.cpp

Modified: llvm/trunk/include/llvm/IR/Intrinsics.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Intrinsics.h?rev=279466&r1=279465&r2=279466&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Intrinsics.h (original)
+++ llvm/trunk/include/llvm/IR/Intrinsics.h Mon Aug 22 15:18:28 2016
@@ -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.

Modified: llvm/trunk/lib/IR/Function.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Function.cpp?rev=279466&r1=279465&r2=279466&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Function.cpp (original)
+++ llvm/trunk/lib/IR/Function.cpp Mon Aug 22 15:18:28 2016
@@ -553,6 +553,8 @@ static std::string getMangledTypeStr(Typ
 
 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];
 }
 




More information about the llvm-commits mailing list