diff options
author | Jeffrey Yasskin <jyasskin@google.com> | 2010-02-11 06:41:30 +0000 |
---|---|---|
committer | Jeffrey Yasskin <jyasskin@google.com> | 2010-02-11 06:41:30 +0000 |
commit | 9233b15d01ca62445bfc638f782243988c672e01 (patch) | |
tree | d6835dc476828ac488e8066c9f1bb6528be60d60 /lib | |
parent | 8c5ad3a5da7419af4d31963c3824836b5da52478 (diff) | |
download | external_llvm-9233b15d01ca62445bfc638f782243988c672e01.zip external_llvm-9233b15d01ca62445bfc638f782243988c672e01.tar.gz external_llvm-9233b15d01ca62445bfc638f782243988c672e01.tar.bz2 |
Fix some of the memcheck errors found in the JIT unittests.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95856 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/VMCore/LLVMContextImpl.h | 13 | ||||
-rw-r--r-- | lib/VMCore/Type.cpp | 25 |
2 files changed, 12 insertions, 26 deletions
diff --git a/lib/VMCore/LLVMContextImpl.h b/lib/VMCore/LLVMContextImpl.h index ccca789..f7f4860 100644 --- a/lib/VMCore/LLVMContextImpl.h +++ b/lib/VMCore/LLVMContextImpl.h @@ -164,7 +164,10 @@ public: // Opaque types are not structurally uniqued, so don't use TypeMap. typedef SmallPtrSet<const OpaqueType*, 8> OpaqueTypesTy; OpaqueTypesTy OpaqueTypes; - + + /// Used as an abstract type that will never be resolved. + OpaqueType *const AlwaysOpaqueTy; + /// ValueHandles - This map keeps track of all of the value handles that are /// watching a Value*. The Value::HasValueHandle bit is used to know @@ -196,7 +199,12 @@ public: Int8Ty(C, 8), Int16Ty(C, 16), Int32Ty(C, 32), - Int64Ty(C, 64) { } + Int64Ty(C, 64), + AlwaysOpaqueTy(new OpaqueType(C)) { + // Make sure the AlwaysOpaqueTy stays alive as long as the Context. + AlwaysOpaqueTy->addRef(); + OpaqueTypes.insert(AlwaysOpaqueTy); + } ~LLVMContextImpl() { ExprConstants.freeConstants(); @@ -217,6 +225,7 @@ public: delete I->second; } MDNodeSet.clear(); + AlwaysOpaqueTy->dropRef(); for (OpaqueTypesTy::iterator I = OpaqueTypes.begin(), E = OpaqueTypes.end(); I != E; ++I) { (*I)->AbstractTypeUsers.clear(); diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp index 044de4f..cf85198 100644 --- a/lib/VMCore/Type.cpp +++ b/lib/VMCore/Type.cpp @@ -507,30 +507,7 @@ void DerivedType::dropAllTypeUses() { if (NumContainedTys != 0) { // The type must stay abstract. To do this, we insert a pointer to a type // that will never get resolved, thus will always be abstract. - static Type *AlwaysOpaqueTy = 0; - static PATypeHolder* Holder = 0; - Type *tmp = AlwaysOpaqueTy; - if (llvm_is_multithreaded()) { - sys::MemoryFence(); - if (!tmp) { - llvm_acquire_global_lock(); - tmp = AlwaysOpaqueTy; - if (!tmp) { - tmp = OpaqueType::get(getContext()); - PATypeHolder* tmp2 = new PATypeHolder(tmp); - sys::MemoryFence(); - AlwaysOpaqueTy = tmp; - Holder = tmp2; - } - - llvm_release_global_lock(); - } - } else if (!AlwaysOpaqueTy) { - AlwaysOpaqueTy = OpaqueType::get(getContext()); - Holder = new PATypeHolder(AlwaysOpaqueTy); - } - - ContainedTys[0] = AlwaysOpaqueTy; + ContainedTys[0] = getContext().pImpl->AlwaysOpaqueTy; // Change the rest of the types to be Int32Ty's. It doesn't matter what we // pick so long as it doesn't point back to this type. We choose something |