Implement Function::getIntrinsicID without it needing to call Value::getName,
which allocates a string. This speeds up instcombine on 447.dealII by 5%.
llvm-svn: 34318
diff --git a/llvm/lib/VMCore/Function.cpp b/llvm/lib/VMCore/Function.cpp
index fcbf73f..8aa0caa 100644
--- a/llvm/lib/VMCore/Function.cpp
+++ b/llvm/lib/VMCore/Function.cpp
@@ -160,12 +160,15 @@
/// llvm/Intrinsics.h.
///
unsigned Function::getIntrinsicID() const {
- const std::string& Name = this->getName();
- if (Name.size() < 5 || Name[4] != '.' || Name[0] != 'l' || Name[1] != 'l'
+ const ValueName *ValName = this->getValueName();
+ 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.'
- assert(Name.size() != 5 && "'llvm.' is an invalid intrinsic name!");
+ assert(Len != 5 && "'llvm.' is an invalid intrinsic name!");
#define GET_FUNCTION_RECOGNIZER
#include "llvm/Intrinsics.gen"