summaryrefslogtreecommitdiffstats
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
commitb99f80dea7f87d38b55434f2bd64aabea6793a2f (patch)
tree5526f67cdbb2e003007e08ce2340b97c51e64197
parent7be70e85287e5b6f8acd38faff28895ddf58ca4f (diff)
downloadbcm5719-llvm-b99f80dea7f87d38b55434f2bd64aabea6793a2f.tar.gz
bcm5719-llvm-b99f80dea7f87d38b55434f2bd64aabea6793a2f.zip
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().
llvm-svn: 170602
-rw-r--r--llvm/include/llvm/Function.h2
-rw-r--r--llvm/include/llvm/IntrinsicInst.h2
-rw-r--r--llvm/lib/VMCore/Function.cpp6
3 files changed, 3 insertions, 7 deletions
diff --git a/llvm/include/llvm/Function.h b/llvm/include/llvm/Function.h
index ce7ae2646bf..2f555e89d8e 100644
--- a/llvm/include/llvm/Function.h
+++ b/llvm/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/llvm/include/llvm/IntrinsicInst.h b/llvm/include/llvm/IntrinsicInst.h
index d5d27e6998f..41e79e9ee3e 100644
--- a/llvm/include/llvm/IntrinsicInst.h
+++ b/llvm/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/llvm/lib/VMCore/Function.cpp b/llvm/lib/VMCore/Function.cpp
index cd3b663ac8d..5ff088e7f56 100644
--- a/llvm/lib/VMCore/Function.cpp
+++ b/llvm/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
OpenPOWER on IntegriCloud