aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2009-10-19 20:11:52 +0000
committerOwen Anderson <resistor@mac.com>2009-10-19 20:11:52 +0000
commitee99626c6bd31b4c0eea7de52945f514d7b2b0c6 (patch)
tree69d6271ccc19ebf9a2746992d4f83d84e4eafc47 /lib
parentfd73ff4241505512fbaba4781c019338774893a7 (diff)
downloadexternal_llvm-ee99626c6bd31b4c0eea7de52945f514d7b2b0c6.zip
external_llvm-ee99626c6bd31b4c0eea7de52945f514d7b2b0c6.tar.gz
external_llvm-ee99626c6bd31b4c0eea7de52945f514d7b2b0c6.tar.bz2
Banish ConstantsLock. It's serving no purpose other than slowing things down
at the moment. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84529 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/VMCore/Constants.cpp57
-rw-r--r--lib/VMCore/LLVMContextImpl.h1
-rw-r--r--lib/VMCore/Metadata.cpp24
3 files changed, 22 insertions, 60 deletions
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp
index 529c455..02c3352 100644
--- a/lib/VMCore/Constants.cpp
+++ b/lib/VMCore/Constants.cpp
@@ -232,7 +232,6 @@ ConstantInt::ConstantInt(const IntegerType *Ty, const APInt& V)
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::getTrue(LLVMContext &Context) {
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 @@ ConstantInt *ConstantInt::get(LLVMContext &Context, const APInt& V) {
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 @@ ConstantFP* ConstantFP::get(LLVMContext &Context, const APFloat& V) {
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 @@ void ConstantArray::replaceUsesOfWithOnConstant(Value *From, Value *To,
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 @@ void ConstantStruct::replaceUsesOfWithOnConstant(Value *From, Value *To,
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);
diff --git a/lib/VMCore/LLVMContextImpl.h b/lib/VMCore/LLVMContextImpl.h
index 83888c3..58e8870 100644
--- a/lib/VMCore/LLVMContextImpl.h
+++ b/lib/VMCore/LLVMContextImpl.h
@@ -96,7 +96,6 @@ struct DenseMapAPFloatKeyInfo {
class LLVMContextImpl {
public:
- sys::SmartRWMutex<true> ConstantsLock;
typedef DenseMap<DenseMapAPIntKeyInfo::KeyTy, ConstantInt*,
DenseMapAPIntKeyInfo> IntMapTy;
IntMapTy IntConstants;
diff --git a/lib/VMCore/Metadata.cpp b/lib/VMCore/Metadata.cpp
index 0528e48..0434c6d 100644
--- a/lib/VMCore/Metadata.cpp
+++ b/lib/VMCore/Metadata.cpp
@@ -52,7 +52,6 @@ void MetadataBase::resizeOperands(unsigned NumOps) {
//
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 @@ MDNode *MDNode::get(LLVMContext &Context, Value*const* Vals, unsigned NumVals) {
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 @@ void MDNode::dropAllReferences() {
MDNode::~MDNode() {
{
LLVMContextImpl *pImpl = getType()->getContext().pImpl;
- sys::SmartScopedWriter<true> Writer(pImpl->ConstantsLock);
pImpl->MDNodeSet.RemoveNode(this);
}
dropAllReferences();
@@ -147,10 +143,7 @@ void MDNode::replaceElement(Value *From, Value *To) {
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 @@ void MDNode::replaceElement(Value *From, Value *To) {
// 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 @@ void MDNode::replaceElement(Value *From, Value *To) {
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);
}
}