diff options
author | Chris Lattner <sabre@nondot.org> | 2008-08-15 15:16:50 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-08-15 15:16:50 +0000 |
commit | 3b12ab451924a356c190b23def44744573abe871 (patch) | |
tree | daeee2f146d5d9c495fb8070904a34d618f3422c /include | |
parent | 21066541ae22608106fa980bd90f9f6cc7cc8037 (diff) | |
download | external_llvm-3b12ab451924a356c190b23def44744573abe871.zip external_llvm-3b12ab451924a356c190b23def44744573abe871.tar.gz external_llvm-3b12ab451924a356c190b23def44744573abe871.tar.bz2 |
Inline the fastpath of PATypeHolder::get(). This is a small speedup in
instcombine among other things.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54814 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/Type.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/include/llvm/Type.h b/include/llvm/Type.h index fe3c392..5bcb654 100644 --- a/include/llvm/Type.h +++ b/include/llvm/Type.h @@ -392,6 +392,17 @@ inline void PATypeHandle::removeUser() { // Define inline methods for PATypeHolder. +/// get - This implements the forwarding part of the union-find algorithm for +/// abstract types. Before every access to the Type*, we check to see if the +/// type we are pointing to is forwarding to a new type. If so, we drop our +/// reference to the type. +/// +inline Type* PATypeHolder::get() const { + const Type *NewTy = Ty->getForwardedType(); + if (!NewTy) return const_cast<Type*>(Ty); + return *const_cast<PATypeHolder*>(this) = NewTy; +} + inline void PATypeHolder::addRef() { assert(Ty && "Type Holder has a null type!"); if (Ty->isAbstract()) |