diff options
author | Pete Cooper <peter_cooper@apple.com> | 2015-05-19 00:24:26 +0000 |
---|---|---|
committer | Pete Cooper <peter_cooper@apple.com> | 2015-05-19 00:24:26 +0000 |
commit | a7c0c18c4d473c6ad4bdd01b78b196622869b156 (patch) | |
tree | 3c2fc6bd8c51b1ce70985360d1e64f4d63fb341f /llvm/lib/IR/Function.cpp | |
parent | 212411356911f46df9e17331c0197f1cef7bc625 (diff) | |
download | bcm5719-llvm-a7c0c18c4d473c6ad4bdd01b78b196622869b156.tar.gz bcm5719-llvm-a7c0c18c4d473c6ad4bdd01b78b196622869b156.zip |
Store intrinsic ID by value in Function instead of a string lookup. NFC.
On 64-bit targets, Function has 4-bytes of padding in its struct layout.
This uses the space for the intrinsic ID. It is set and recalculated whenever the function name is set. This is similar to the current behavior which clears the function from the intrinsic ID cache when its renamed.
The intrinsic cache itself is removed as the only purpose was to speedup calls to getIntrinsicID() which now just reading the new field in the struct.
Reviewed by Duncan. http://reviews.llvm.org/D9836
llvm-svn: 237642
Diffstat (limited to 'llvm/lib/IR/Function.cpp')
-rw-r--r-- | llvm/lib/IR/Function.cpp | 35 |
1 files changed, 9 insertions, 26 deletions
diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp index 71e07ea04cb..cbba2ee90a1 100644 --- a/llvm/lib/IR/Function.cpp +++ b/llvm/lib/IR/Function.cpp @@ -266,9 +266,10 @@ Function::Function(FunctionType *Ty, LinkageTypes Linkage, const Twine &name, ParentModule->getFunctionList().push_back(this); // Ensure intrinsics have the right parameter attributes. - if (unsigned IID = getIntrinsicID()) - setAttributes(Intrinsic::getAttributes(getContext(), Intrinsic::ID(IID))); - + // Note, the IntID field will have been set in Value::setName if this function + // name is a valid intrinsic ID. + if (IntID) + setAttributes(Intrinsic::getAttributes(getContext(), IntID)); } Function::~Function() { @@ -280,10 +281,6 @@ Function::~Function() { // Remove the function from the on-the-side GC table. clearGC(); - - // Remove the intrinsicID from the Cache. - if (getValueName() && isIntrinsic()) - getContext().pImpl->IntrinsicIDCache.erase(this); } void Function::BuildLazyArguments() const { @@ -446,27 +443,13 @@ static Intrinsic::ID lookupIntrinsicID(const ValueName *ValName) { return Intrinsic::not_intrinsic; } -/// getIntrinsicID - This method returns the ID number of the specified -/// function, or Intrinsic::not_intrinsic if the function is not an -/// intrinsic, or if the pointer is null. This value is always defined to be -/// zero to allow easy checking for whether a function is intrinsic or not. The -/// particular intrinsic functions which correspond to this value are defined in -/// llvm/Intrinsics.h. Results are cached in the LLVM context, subsequent -/// requests for the same ID return results much faster from the cache. -/// -unsigned Function::getIntrinsicID() const { +void Function::recalculateIntrinsicID() { const ValueName *ValName = this->getValueName(); - if (!ValName || !isIntrinsic()) - return 0; - - LLVMContextImpl::IntrinsicIDCacheTy &IntrinsicIDCache = - getContext().pImpl->IntrinsicIDCache; - if (!IntrinsicIDCache.count(this)) { - unsigned Id = lookupIntrinsicID(ValName); - IntrinsicIDCache[this]=Id; - return Id; + if (!ValName || !isIntrinsic()) { + IntID = Intrinsic::not_intrinsic; + return; } - return IntrinsicIDCache[this]; + IntID = lookupIntrinsicID(ValName); } /// Returns a stable mangling for the type specified for use in the name |