summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/Function.cpp
diff options
context:
space:
mode:
authorJustin Lebar <jlebar@google.com>2016-07-27 23:46:57 +0000
committerJustin Lebar <jlebar@google.com>2016-07-27 23:46:57 +0000
commit45bcdcbefbfda867965fec755391f6ad0925f74a (patch)
tree8037c44903747af63d7a16a777685dd8dafbcd6d /llvm/lib/IR/Function.cpp
parentff5ce639deb23595b4c4c9b995d6d6d47dda64fb (diff)
downloadbcm5719-llvm-45bcdcbefbfda867965fec755391f6ad0925f74a.tar.gz
bcm5719-llvm-45bcdcbefbfda867965fec755391f6ad0925f74a.zip
Don't invoke getName() from Function::isIntrinsic().
Summary: getName() involves a hashtable lookup, so is expensive given how frequently isIntrinsic() is called. (In particular, many users cast to IntrinsicInstr or one of its subclasses before calling getIntrinsicID().) This has an incidental functional change: Before, isIntrinsic() would return true for any function whose name started with "llvm.", even if it wasn't properly an intrinsic. The new behavior seems more correct to me, because it's strange to say that isIntrinsic() is true, but getIntrinsicId() returns "not an intrinsic". Some callers want the old behavior -- they want to know whether the caller is a recognized intrinsic, or might be one in some other version of LLVM. For them, we added Function::hasLLVMReservedName(), which checks whether the name starts with "llvm.". This change is good for a 1.5% e2e speedup compiling a large Eigen benchmark. Reviewers: bogner Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D22065 llvm-svn: 276942
Diffstat (limited to 'llvm/lib/IR/Function.cpp')
-rw-r--r--llvm/lib/IR/Function.cpp9
1 files changed, 3 insertions, 6 deletions
diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp
index e1223d0d033..d9c59241ddf 100644
--- a/llvm/lib/IR/Function.cpp
+++ b/llvm/lib/IR/Function.cpp
@@ -488,9 +488,7 @@ static ArrayRef<const char *> findTargetSubtable(StringRef Name) {
/// \brief This does the actual lookup of an intrinsic ID which
/// matches the given function name.
-static Intrinsic::ID lookupIntrinsicID(const ValueName *ValName) {
- StringRef Name = ValName->getKey();
-
+static Intrinsic::ID lookupIntrinsicID(StringRef Name) {
ArrayRef<const char *> NameTable = findTargetSubtable(Name);
int Idx = Intrinsic::lookupLLVMIntrinsicByName(NameTable, Name);
if (Idx == -1)
@@ -508,12 +506,11 @@ static Intrinsic::ID lookupIntrinsicID(const ValueName *ValName) {
}
void Function::recalculateIntrinsicID() {
- const ValueName *ValName = this->getValueName();
- if (!ValName || !isIntrinsic()) {
+ if (!hasLLVMReservedName()) {
IntID = Intrinsic::not_intrinsic;
return;
}
- IntID = lookupIntrinsicID(ValName);
+ IntID = lookupIntrinsicID(getName());
}
/// Returns a stable mangling for the type specified for use in the name
OpenPOWER on IntegriCloud