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/Value.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/Value.cpp')
-rw-r--r-- | llvm/lib/IR/Value.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/llvm/lib/IR/Value.cpp b/llvm/lib/IR/Value.cpp index 18f6b1e9c35..fd0ed31ccc6 100644 --- a/llvm/lib/IR/Value.cpp +++ b/llvm/lib/IR/Value.cpp @@ -166,7 +166,7 @@ StringRef Value::getName() const { return getValueName()->getKey(); } -void Value::setName(const Twine &NewName) { +void Value::setNameImpl(const Twine &NewName) { // Fast path for common IRBuilder case of setName("") when there is no name. if (NewName.isTriviallyEmpty() && !hasName()) return; @@ -187,9 +187,6 @@ void Value::setName(const Twine &NewName) { if (getSymTab(this, ST)) return; // Cannot set a name on this value (e.g. constant). - if (Function *F = dyn_cast<Function>(this)) - getContext().pImpl->IntrinsicIDCache.erase(F); - if (!ST) { // No symbol table to update? Just do the change. if (NameRef.empty()) { // Free the name for this value. @@ -222,6 +219,12 @@ void Value::setName(const Twine &NewName) { setValueName(ST->createValueName(NameRef, this)); } +void Value::setName(const Twine &NewName) { + setNameImpl(NewName); + if (Function *F = dyn_cast<Function>(this)) + F->recalculateIntrinsicID(); +} + void Value::takeName(Value *V) { ValueSymbolTable *ST = nullptr; // If this value has a name, drop it. |