Refactor isIntrinsic() to be quicker, and change classof() (and thus, isa<IntrinsicIn...
authorMichael Ilseman <milseman@apple.com>
Wed, 19 Dec 2012 23:17:20 +0000 (23:17 +0000)
committerMichael Ilseman <milseman@apple.com>
Wed, 19 Dec 2012 23:17:20 +0000 (23:17 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170602 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Function.h
include/llvm/IntrinsicInst.h
lib/VMCore/Function.cpp

index ce7ae2646bf87eb2fc52748604984b4ca105f855..2f555e89d8e478c3e8c242b8738058f2d2c19b52 100644 (file)
@@ -147,7 +147,7 @@ public:
   /// defined in llvm/Intrinsics.h.
   ///
   unsigned getIntrinsicID() const LLVM_READONLY;
-  bool isIntrinsic() const { return getIntrinsicID() != 0; }
+  bool isIntrinsic() const { return getName().startswith("llvm."); }
 
   /// getCallingConv()/setCallingConv(CC) - These method get and set the
   /// calling convention of this function.  The enum values for the known
index d5d27e6998fc05819bdfa2a8f94a8f403bcca69e..41e79e9ee3e67f600c367de0e7f32023d687e06b 100644 (file)
@@ -47,7 +47,7 @@ namespace llvm {
     // Methods for support type inquiry through isa, cast, and dyn_cast:
     static inline bool classof(const CallInst *I) {
       if (const Function *CF = I->getCalledFunction())
-        return CF->getIntrinsicID() != 0;
+        return CF->isIntrinsic();
       return false;
     }
     static inline bool classof(const Value *V) {
index cd3b663ac8d39bb74bc772b0a52f29ba83dd24f5..5ff088e7f5697979ea1e71d4761209f42eacbcd1 100644 (file)
@@ -326,15 +326,11 @@ void Function::copyAttributesFrom(const GlobalValue *Src) {
 ///
 unsigned Function::getIntrinsicID() const {
   const ValueName *ValName = this->getValueName();
-  if (!ValName)
+  if (!ValName || !isIntrinsic())
     return 0;
   unsigned Len = ValName->getKeyLength();
   const char *Name = ValName->getKeyData();
 
-  if (Len < 5 || Name[4] != '.' || Name[0] != 'l' || Name[1] != 'l'
-      || Name[2] != 'v' || Name[3] != 'm')
-    return 0;  // All intrinsics start with 'llvm.'
-
 #define GET_FUNCTION_RECOGNIZER
 #include "llvm/Intrinsics.gen"
 #undef GET_FUNCTION_RECOGNIZER