For PR1328:
authorReid Spencer <rspencer@reidspencer.com>
Mon, 16 Apr 2007 06:54:34 +0000 (06:54 +0000)
committerReid Spencer <rspencer@reidspencer.com>
Mon, 16 Apr 2007 06:54:34 +0000 (06:54 +0000)
Don't assert everytime an intrinsic name isn't recognized. Instead, make
the assert optional when callin getIntrinsicID(). This allows the assembler
to handle invalid intrinsic names gracefully.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36120 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Function.h
lib/VMCore/Function.cpp
utils/TableGen/IntrinsicEmitter.cpp

index 751d1a3c4bdf87f34015a8603a05aebc986ee7a6..90a8275bec10f381c55b25ef4597071466d8bfcd 100644 (file)
@@ -103,7 +103,7 @@ public:
   /// The particular intrinsic functions which correspond to this value are
   /// defined in llvm/Intrinsics.h.
   ///
-  unsigned getIntrinsicID() const;
+  unsigned getIntrinsicID(bool noAssert = false) const;
   bool isIntrinsic() const { return getIntrinsicID() != 0; }
 
   /// getCallingConv()/setCallingConv(uint) - These method get and set the
index e2a015fabbbd8e7f474b3871387f5d189bbb46dd..5176a05d760c296e96bcad4e241bb89514a454f2 100644 (file)
@@ -224,20 +224,21 @@ void Function::dropAllReferences() {
 /// particular intrinsic functions which correspond to this value are defined in
 /// llvm/Intrinsics.h.
 ///
-unsigned Function::getIntrinsicID() const {
+unsigned Function::getIntrinsicID(bool noAssert) const {
   const ValueName *ValName = this->getValueName();
   unsigned Len = ValName->getKeyLength();
   const char *Name = ValName->getKeyData();
   
-  if (Len < 5 || Name[4] != '.' || Name[0] != 'l' || Name[1] != 'l'
+  if (Len <= 5 || Name[4] != '.' || Name[0] != 'l' || Name[1] != 'l'
       || Name[2] != 'v' || Name[3] != 'm')
     return 0;  // All intrinsics start with 'llvm.'
 
-  assert(Len != 5 && "'llvm.' is an invalid intrinsic name!");
+  assert((Len != 5 || noAssert) && "'llvm.' is an invalid intrinsic name!");
 
 #define GET_FUNCTION_RECOGNIZER
 #include "llvm/Intrinsics.gen"
 #undef GET_FUNCTION_RECOGNIZER
+  assert(noAssert && "Invalid LLVM intrinsic name");
   return 0;
 }
 
index f884c424a71f3c9fd6208fad043ca64f0cb36079..834e1429ba49da4e10b5e0f660f3b04421430619 100644 (file)
@@ -103,8 +103,6 @@ EmitFnNameRecognizer(const std::vector<CodeGenIntrinsic> &Ints,
          << Ints[I->second].EnumName << ";\n";
   }
   OS << "  }\n";
-  OS << "  // The 'llvm.' namespace is reserved!\n";
-  OS << "  assert(0 && \"Unknown LLVM intrinsic function!\");\n";
   OS << "#endif\n\n";
 }