summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/Function.cpp
diff options
context:
space:
mode:
authorJustin Lebar <jlebar@google.com>2016-12-28 22:59:45 +0000
committerJustin Lebar <jlebar@google.com>2016-12-28 22:59:45 +0000
commit291abd3ebb7ec8c9e2c3e28ca44222f822fb43fe (patch)
treec325fea6bda847980adbbac44ef682ef7efeb7f3 /llvm/lib/IR/Function.cpp
parente98f9258349aeb8414a556326aeee8ba94a7c839 (diff)
downloadbcm5719-llvm-291abd3ebb7ec8c9e2c3e28ca44222f822fb43fe.tar.gz
bcm5719-llvm-291abd3ebb7ec8c9e2c3e28ca44222f822fb43fe.zip
Speed up Function::isIntrinsic() by adding a bit to GlobalValue. NFC
Summary: Previously isIntrinsic() called getName(). This involves a hashtable lookup, so is nontrivially expensive. And isIntrinsic() is called frequently, particularly by dyn_cast<IntrinsicInstr>. This patch steals a bit of IntID and uses that to store whether or not getName() starts with "llvm." Reviewers: bogner, arsenm, joker-eph Subscribers: sanjoy, llvm-commits Differential Revision: https://reviews.llvm.org/D22949 llvm-svn: 290691
Diffstat (limited to 'llvm/lib/IR/Function.cpp')
-rw-r--r--llvm/lib/IR/Function.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp
index b87c85e44a8..05419aa3d2b 100644
--- a/llvm/lib/IR/Function.cpp
+++ b/llvm/lib/IR/Function.cpp
@@ -270,6 +270,7 @@ Function::Function(FunctionType *Ty, LinkageTypes Linkage, const Twine &name,
if (ParentModule)
ParentModule->getFunctionList().push_back(this);
+ HasLLVMReservedName = getName().startswith("llvm.");
// Ensure intrinsics have the right parameter attributes.
// Note, the IntID field will have been set in Value::setName if this function
// name is a valid intrinsic ID.
@@ -500,12 +501,14 @@ Intrinsic::ID Function::lookupIntrinsicID(StringRef Name) {
}
void Function::recalculateIntrinsicID() {
- const ValueName *ValName = this->getValueName();
- if (!ValName || !isIntrinsic()) {
+ StringRef Name = getName();
+ if (!Name.startswith("llvm.")) {
+ HasLLVMReservedName = false;
IntID = Intrinsic::not_intrinsic;
return;
}
- IntID = lookupIntrinsicID(ValName->getKey());
+ HasLLVMReservedName = true;
+ IntID = lookupIntrinsicID(Name);
}
/// Returns a stable mangling for the type specified for use in the name
OpenPOWER on IntegriCloud