diff options
author | Jeffrey Yasskin <jyasskin@google.com> | 2010-03-13 20:09:55 +0000 |
---|---|---|
committer | Jeffrey Yasskin <jyasskin@google.com> | 2010-03-13 20:09:55 +0000 |
commit | 0374d7feb0b76a95dbea79b66ac57badf7fc2e09 (patch) | |
tree | a4cbe0f7c6362dc517902f9d38e3c67345bd6e45 /llvm/lib | |
parent | 84189ab22b89360ed910fb9cf57fcd8f71b55246 (diff) | |
download | bcm5719-llvm-0374d7feb0b76a95dbea79b66ac57badf7fc2e09.tar.gz bcm5719-llvm-0374d7feb0b76a95dbea79b66ac57badf7fc2e09.zip |
Allow types that have been forwarded to to be freed.
Tested: make check-lit && valgrind --dsymutil=yes --leak-check=full unittests/ExecutionEngine/JIT/Debug/JITTests
llvm-svn: 98447
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/VMCore/Type.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/llvm/lib/VMCore/Type.cpp b/llvm/lib/VMCore/Type.cpp index 9b2c2cab81f..2a0cfa8470e 100644 --- a/llvm/lib/VMCore/Type.cpp +++ b/llvm/lib/VMCore/Type.cpp @@ -87,6 +87,11 @@ void Type::destroy() const { pImpl->OpaqueTypes.erase(opaque_this); } + if (ForwardType && ForwardType->isAbstract()) { + ForwardType->dropRef(); + ForwardType = NULL; + } + // For all the other type subclasses, there is either no contained types or // just one (all Sequentials). For Sequentials, the PATypeHandle is not // allocated past the type object, its included directly in the SequentialType @@ -254,10 +259,12 @@ const Type *Type::getForwardedTypeInternal() const { // Yes, it is forwarded again. First thing, add the reference to the new // forward type. if (RealForwardedType->isAbstract()) - cast<DerivedType>(RealForwardedType)->addRef(); + RealForwardedType->addRef(); // Now drop the old reference. This could cause ForwardType to get deleted. - cast<DerivedType>(ForwardType)->dropRef(); + // ForwardType must be abstract because only abstract types can have their own + // ForwardTypes. + ForwardType->dropRef(); // Return the updated type. ForwardType = RealForwardedType; @@ -1142,8 +1149,8 @@ void DerivedType::unlockedRefineAbstractTypeTo(const Type *NewType) { // Any PATypeHolders referring to this type will now automatically forward to // the type we are resolved to. ForwardType = NewType; - if (NewType->isAbstract()) - cast<DerivedType>(NewType)->addRef(); + if (ForwardType->isAbstract()) + ForwardType->addRef(); // Add a self use of the current type so that we don't delete ourself until // after the function exits. |