[llvm-commits] [llvm] r170602 - in /llvm/trunk: include/llvm/Function.h include/llvm/IntrinsicInst.h lib/VMCore/Function.cpp
Michael Ilseman
milseman at apple.com
Wed Dec 19 15:17:20 PST 2012
Author: milseman
Date: Wed Dec 19 17:17:20 2012
New Revision: 170602
URL: http://llvm.org/viewvc/llvm-project?rev=170602&view=rev
Log:
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().
Modified:
llvm/trunk/include/llvm/Function.h
llvm/trunk/include/llvm/IntrinsicInst.h
llvm/trunk/lib/VMCore/Function.cpp
Modified: llvm/trunk/include/llvm/Function.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Function.h?rev=170602&r1=170601&r2=170602&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Function.h (original)
+++ llvm/trunk/include/llvm/Function.h Wed Dec 19 17:17:20 2012
@@ -147,7 +147,7 @@
/// 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
Modified: llvm/trunk/include/llvm/IntrinsicInst.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IntrinsicInst.h?rev=170602&r1=170601&r2=170602&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IntrinsicInst.h (original)
+++ llvm/trunk/include/llvm/IntrinsicInst.h Wed Dec 19 17:17:20 2012
@@ -47,7 +47,7 @@
// 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) {
Modified: llvm/trunk/lib/VMCore/Function.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Function.cpp?rev=170602&r1=170601&r2=170602&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Function.cpp (original)
+++ llvm/trunk/lib/VMCore/Function.cpp Wed Dec 19 17:17:20 2012
@@ -326,15 +326,11 @@
///
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
More information about the llvm-commits
mailing list