llvm.org GIT mirror llvm / 2db15e2
For PR1328: 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 Reid Spencer 13 years ago
3 changed file(s) with 5 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
102102 /// The particular intrinsic functions which correspond to this value are
103103 /// defined in llvm/Intrinsics.h.
104104 ///
105 unsigned getIntrinsicID() const;
105 unsigned getIntrinsicID(bool noAssert = false) const;
106106 bool isIntrinsic() const { return getIntrinsicID() != 0; }
107107
108108 /// getCallingConv()/setCallingConv(uint) - These method get and set the
223223 /// particular intrinsic functions which correspond to this value are defined in
224224 /// llvm/Intrinsics.h.
225225 ///
226 unsigned Function::getIntrinsicID() const {
226 unsigned Function::getIntrinsicID(bool noAssert) const {
227227 const ValueName *ValName = this->getValueName();
228228 unsigned Len = ValName->getKeyLength();
229229 const char *Name = ValName->getKeyData();
230230
231 if (Len < 5 || Name[4] != '.' || Name[0] != 'l' || Name[1] != 'l'
231 if (Len <= 5 || Name[4] != '.' || Name[0] != 'l' || Name[1] != 'l'
232232 || Name[2] != 'v' || Name[3] != 'm')
233233 return 0; // All intrinsics start with 'llvm.'
234234
235 assert(Len != 5 && "'llvm.' is an invalid intrinsic name!");
235 assert((Len != 5 || noAssert) && "'llvm.' is an invalid intrinsic name!");
236236
237237 #define GET_FUNCTION_RECOGNIZER
238238 #include "llvm/Intrinsics.gen"
239239 #undef GET_FUNCTION_RECOGNIZER
240 assert(noAssert && "Invalid LLVM intrinsic name");
240241 return 0;
241242 }
242243
102102 << Ints[I->second].EnumName << ";\n";
103103 }
104104 OS << " }\n";
105 OS << " // The 'llvm.' namespace is reserved!\n";
106 OS << " assert(0 && \"Unknown LLVM intrinsic function!\");\n";
107105 OS << "#endif\n\n";
108106 }
109107