aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Ilseman <milseman@apple.com>2012-12-19 23:17:20 +0000
committerMichael Ilseman <milseman@apple.com>2012-12-19 23:17:20 +0000
commitf846f16c92590379e900d01812e828e83b759cee (patch)
tree44b01d6f2d2da35339c228a018261d963da819d1
parent18e7211068c9d2c6204512f9c468ee179818a4b6 (diff)
downloadexternal_llvm-f846f16c92590379e900d01812e828e83b759cee.zip
external_llvm-f846f16c92590379e900d01812e828e83b759cee.tar.gz
external_llvm-f846f16c92590379e900d01812e828e83b759cee.tar.bz2
Refactor isIntrinsic() to be quicker, and change classof() (and thus, isa<IntrinsicInst>()) to use it. This decreases the number of occurrences of the slow-path string matching performed by getIntrinsicID().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170602 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/Function.h2
-rw-r--r--include/llvm/IntrinsicInst.h2
-rw-r--r--lib/VMCore/Function.cpp6
3 files changed, 3 insertions, 7 deletions
diff --git a/include/llvm/Function.h b/include/llvm/Function.h
index ce7ae26..2f555e8 100644
--- a/include/llvm/Function.h
+++ b/include/llvm/Function.h
@@ -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
diff --git a/include/llvm/IntrinsicInst.h b/include/llvm/IntrinsicInst.h
index d5d27e6..41e79e9 100644
--- a/include/llvm/IntrinsicInst.h
+++ b/include/llvm/IntrinsicInst.h
@@ -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) {
diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp
index cd3b663..5ff088e 100644
--- a/lib/VMCore/Function.cpp
+++ b/lib/VMCore/Function.cpp
@@ -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