[llvm-commits] [llvm] r84529 - in /llvm/trunk/lib/VMCore: Constants.cpp LLVMContextImpl.h Metadata.cpp
Chris Lattner
clattner at apple.com
Mon Oct 19 13:25:39 PDT 2009
On Oct 19, 2009, at 1:11 PM, Owen Anderson wrote:
> Author: resistor
> Date: Mon Oct 19 15:11:52 2009
> New Revision: 84529
>
> URL: http://llvm.org/viewvc/llvm-project?rev=84529&view=rev
> Log:
> Banish ConstantsLock. It's serving no purpose other than slowing
> things down
> at the moment.
Thanks Owen!
-Chris
>
> Modified:
> llvm/trunk/lib/VMCore/Constants.cpp
> llvm/trunk/lib/VMCore/LLVMContextImpl.h
> llvm/trunk/lib/VMCore/Metadata.cpp
>
> Modified: llvm/trunk/lib/VMCore/Constants.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=84529&r1=84528&r2=84529&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/lib/VMCore/Constants.cpp (original)
> +++ llvm/trunk/lib/VMCore/Constants.cpp Mon Oct 19 15:11:52 2009
> @@ -232,7 +232,6 @@
>
> ConstantInt* ConstantInt::getTrue(LLVMContext &Context) {
> LLVMContextImpl *pImpl = Context.pImpl;
> - sys::SmartScopedWriter<true>(pImpl->ConstantsLock);
> if (pImpl->TheTrueVal)
> return pImpl->TheTrueVal;
> else
> @@ -242,7 +241,6 @@
>
> ConstantInt* ConstantInt::getFalse(LLVMContext &Context) {
> LLVMContextImpl *pImpl = Context.pImpl;
> - sys::SmartScopedWriter<true>(pImpl->ConstantsLock);
> if (pImpl->TheFalseVal)
> return pImpl->TheFalseVal;
> else
> @@ -261,22 +259,9 @@
> const IntegerType *ITy = IntegerType::get(Context, V.getBitWidth());
> // get an existing value or the insertion position
> DenseMapAPIntKeyInfo::KeyTy Key(V, ITy);
> -
> - Context.pImpl->ConstantsLock.reader_acquire();
> ConstantInt *&Slot = Context.pImpl->IntConstants[Key];
> - Context.pImpl->ConstantsLock.reader_release();
> -
> - if (!Slot) {
> - sys::SmartScopedWriter<true> Writer(Context.pImpl-
> >ConstantsLock);
> - ConstantInt *&NewSlot = Context.pImpl->IntConstants[Key];
> - if (!Slot) {
> - NewSlot = new ConstantInt(ITy, V);
> - }
> -
> - return NewSlot;
> - } else {
> - return Slot;
> - }
> + if (!Slot) Slot = new ConstantInt(ITy, V);
> + return Slot;
> }
>
> Constant* ConstantInt::get(const Type* Ty, uint64_t V, bool
> isSigned) {
> @@ -405,32 +390,24 @@
>
> LLVMContextImpl* pImpl = Context.pImpl;
>
> - pImpl->ConstantsLock.reader_acquire();
> ConstantFP *&Slot = pImpl->FPConstants[Key];
> - pImpl->ConstantsLock.reader_release();
>
> if (!Slot) {
> - sys::SmartScopedWriter<true> Writer(pImpl->ConstantsLock);
> - ConstantFP *&NewSlot = pImpl->FPConstants[Key];
> - if (!NewSlot) {
> - const Type *Ty;
> - if (&V.getSemantics() == &APFloat::IEEEsingle)
> - Ty = Type::getFloatTy(Context);
> - else if (&V.getSemantics() == &APFloat::IEEEdouble)
> - Ty = Type::getDoubleTy(Context);
> - else if (&V.getSemantics() == &APFloat::x87DoubleExtended)
> - Ty = Type::getX86_FP80Ty(Context);
> - else if (&V.getSemantics() == &APFloat::IEEEquad)
> - Ty = Type::getFP128Ty(Context);
> - else {
> - assert(&V.getSemantics() == &APFloat::PPCDoubleDouble &&
> - "Unknown FP format");
> - Ty = Type::getPPC_FP128Ty(Context);
> - }
> - NewSlot = new ConstantFP(Ty, V);
> + const Type *Ty;
> + if (&V.getSemantics() == &APFloat::IEEEsingle)
> + Ty = Type::getFloatTy(Context);
> + else if (&V.getSemantics() == &APFloat::IEEEdouble)
> + Ty = Type::getDoubleTy(Context);
> + else if (&V.getSemantics() == &APFloat::x87DoubleExtended)
> + Ty = Type::getX86_FP80Ty(Context);
> + else if (&V.getSemantics() == &APFloat::IEEEquad)
> + Ty = Type::getFP128Ty(Context);
> + else {
> + assert(&V.getSemantics() == &APFloat::PPCDoubleDouble &&
> + "Unknown FP format");
> + Ty = Type::getPPC_FP128Ty(Context);
> }
> -
> - return NewSlot;
> + Slot = new ConstantFP(Ty, V);
> }
>
> return Slot;
> @@ -1908,7 +1885,6 @@
> Replacement = ConstantAggregateZero::get(getType());
> } else {
> // Check to see if we have this array type already.
> - sys::SmartScopedWriter<true> Writer(pImpl->ConstantsLock);
> bool Exists;
> LLVMContextImpl::ArrayConstantsTy::MapTy::iterator I =
> pImpl->ArrayConstants.InsertOrGetItem(Lookup, Exists);
> @@ -1987,7 +1963,6 @@
> Replacement = ConstantAggregateZero::get(getType());
> } else {
> // Check to see if we have this array type already.
> - sys::SmartScopedWriter<true> Writer(pImpl->ConstantsLock);
> bool Exists;
> LLVMContextImpl::StructConstantsTy::MapTy::iterator I =
> pImpl->StructConstants.InsertOrGetItem(Lookup, Exists);
>
> Modified: llvm/trunk/lib/VMCore/LLVMContextImpl.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/LLVMContextImpl.h?rev=84529&r1=84528&r2=84529&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/lib/VMCore/LLVMContextImpl.h (original)
> +++ llvm/trunk/lib/VMCore/LLVMContextImpl.h Mon Oct 19 15:11:52 2009
> @@ -96,7 +96,6 @@
>
> class LLVMContextImpl {
> public:
> - sys::SmartRWMutex<true> ConstantsLock;
> typedef DenseMap<DenseMapAPIntKeyInfo::KeyTy, ConstantInt*,
> DenseMapAPIntKeyInfo> IntMapTy;
> IntMapTy IntConstants;
>
> Modified: llvm/trunk/lib/VMCore/Metadata.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Metadata.cpp?rev=84529&r1=84528&r2=84529&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/lib/VMCore/Metadata.cpp (original)
> +++ llvm/trunk/lib/VMCore/Metadata.cpp Mon Oct 19 15:11:52 2009
> @@ -52,7 +52,6 @@
> //
> MDString *MDString::get(LLVMContext &Context, const StringRef &Str) {
> LLVMContextImpl *pImpl = Context.pImpl;
> - sys::SmartScopedWriter<true> Writer(pImpl->ConstantsLock);
> StringMapEntry<MDString *> &Entry =
> pImpl->MDStringCache.GetOrCreateValue(Str);
> MDString *&S = Entry.getValue();
> @@ -93,12 +92,10 @@
> void *InsertPoint;
> MDNode *N;
> {
> - sys::SmartScopedReader<true> Reader(pImpl->ConstantsLock);
> N = pImpl->MDNodeSet.FindNodeOrInsertPos(ID, InsertPoint);
> }
> if (N) return N;
>
> - sys::SmartScopedWriter<true> Writer(pImpl->ConstantsLock);
> N = pImpl->MDNodeSet.FindNodeOrInsertPos(ID, InsertPoint);
> if (!N) {
> // InsertPoint will have been set by the FindNodeOrInsertPos call.
> @@ -118,7 +115,6 @@
> MDNode::~MDNode() {
> {
> LLVMContextImpl *pImpl = getType()->getContext().pImpl;
> - sys::SmartScopedWriter<true> Writer(pImpl->ConstantsLock);
> pImpl->MDNodeSet.RemoveNode(this);
> }
> dropAllReferences();
> @@ -147,10 +143,7 @@
> return;
>
> // Remove "this" from the context map.
> - {
> - sys::SmartScopedWriter<true> Writer(pImpl->ConstantsLock);
> - pImpl->MDNodeSet.RemoveNode(this);
> - }
> + pImpl->MDNodeSet.RemoveNode(this);
>
> // MDNode only lists metadata elements in operand list, because
> MDNode
> // used by MDNode is considered a valid use. However on the side,
> MDNode
> @@ -186,10 +179,8 @@
> // node with updated "this" node.
> FoldingSetNodeID ID;
> Profile(ID);
> - pImpl->ConstantsLock.reader_acquire();
> void *InsertPoint;
> MDNode *N = pImpl->MDNodeSet.FindNodeOrInsertPos(ID, InsertPoint);
> - pImpl->ConstantsLock.reader_release();
>
> if (N) {
> N->replaceAllUsesWith(this);
> @@ -197,14 +188,11 @@
> N = 0;
> }
>
> - {
> - sys::SmartScopedWriter<true> Writer(pImpl->ConstantsLock);
> - N = pImpl->MDNodeSet.FindNodeOrInsertPos(ID, InsertPoint);
> - if (!N) {
> - // InsertPoint will have been set by the FindNodeOrInsertPos
> call.
> - N = this;
> - pImpl->MDNodeSet.InsertNode(N, InsertPoint);
> - }
> + N = pImpl->MDNodeSet.FindNodeOrInsertPos(ID, InsertPoint);
> + if (!N) {
> + // InsertPoint will have been set by the FindNodeOrInsertPos
> call.
> + N = this;
> + pImpl->MDNodeSet.InsertNode(N, InsertPoint);
> }
> }
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list