mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
IR: Extract out getUniqued(), NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226498 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
518025f8a1
commit
1c588db19b
@ -604,19 +604,23 @@ void UniquableMDNode::eraseFromStore() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class T, class InfoT>
|
||||||
|
static T *getUniqued(DenseSet<T *, InfoT> &Store,
|
||||||
|
const typename InfoT::KeyTy &Key) {
|
||||||
|
auto I = Store.find_as(Key);
|
||||||
|
return I == Store.end() ? nullptr : *I;
|
||||||
|
}
|
||||||
|
|
||||||
MDTuple *MDTuple::getImpl(LLVMContext &Context, ArrayRef<Metadata *> MDs,
|
MDTuple *MDTuple::getImpl(LLVMContext &Context, ArrayRef<Metadata *> MDs,
|
||||||
StorageType Storage, bool ShouldCreate) {
|
StorageType Storage, bool ShouldCreate) {
|
||||||
unsigned Hash = 0;
|
unsigned Hash = 0;
|
||||||
if (Storage == Uniqued) {
|
if (Storage == Uniqued) {
|
||||||
MDTupleInfo::KeyTy Key(MDs);
|
MDTupleInfo::KeyTy Key(MDs);
|
||||||
Hash = Key.Hash;
|
if (auto *N = getUniqued(Context.pImpl->MDTuples, Key))
|
||||||
|
return N;
|
||||||
auto &Store = Context.pImpl->MDTuples;
|
|
||||||
auto I = Store.find_as(Key);
|
|
||||||
if (I != Store.end())
|
|
||||||
return *I;
|
|
||||||
if (!ShouldCreate)
|
if (!ShouldCreate)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
Hash = Key.Hash;
|
||||||
} else {
|
} else {
|
||||||
assert(ShouldCreate && "Expected non-uniqued nodes to always be created");
|
assert(ShouldCreate && "Expected non-uniqued nodes to always be created");
|
||||||
}
|
}
|
||||||
@ -639,15 +643,12 @@ MDTuple *MDTuple::getImpl(LLVMContext &Context, ArrayRef<Metadata *> MDs,
|
|||||||
|
|
||||||
MDTuple *MDTuple::uniquifyImpl() {
|
MDTuple *MDTuple::uniquifyImpl() {
|
||||||
recalculateHash();
|
recalculateHash();
|
||||||
MDTupleInfo::KeyTy Key(this);
|
|
||||||
|
|
||||||
auto &Store = getContext().pImpl->MDTuples;
|
auto &Store = getContext().pImpl->MDTuples;
|
||||||
auto I = Store.find_as(Key);
|
if (MDTuple *N = getUniqued(Store, this))
|
||||||
if (I == Store.end()) {
|
return N;
|
||||||
Store.insert(this);
|
|
||||||
return this;
|
Store.insert(this);
|
||||||
}
|
return this;
|
||||||
return *I;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MDTuple::eraseFromStoreImpl() { getContext().pImpl->MDTuples.erase(this); }
|
void MDTuple::eraseFromStoreImpl() { getContext().pImpl->MDTuples.erase(this); }
|
||||||
@ -687,12 +688,10 @@ MDLocation *MDLocation::getImpl(LLVMContext &Context, unsigned Line,
|
|||||||
adjustColumn(Column);
|
adjustColumn(Column);
|
||||||
|
|
||||||
if (Storage == Uniqued) {
|
if (Storage == Uniqued) {
|
||||||
MDLocationInfo::KeyTy Key(Line, Column, Scope, InlinedAt);
|
if (auto *N = getUniqued(
|
||||||
|
Context.pImpl->MDLocations,
|
||||||
auto &Store = Context.pImpl->MDLocations;
|
MDLocationInfo::KeyTy(Line, Column, Scope, InlinedAt)))
|
||||||
auto I = Store.find_as(Key);
|
return N;
|
||||||
if (I != Store.end())
|
|
||||||
return *I;
|
|
||||||
if (!ShouldCreate)
|
if (!ShouldCreate)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
} else {
|
} else {
|
||||||
@ -720,15 +719,12 @@ MDLocation *MDLocation::getImpl(LLVMContext &Context, unsigned Line,
|
|||||||
}
|
}
|
||||||
|
|
||||||
MDLocation *MDLocation::uniquifyImpl() {
|
MDLocation *MDLocation::uniquifyImpl() {
|
||||||
MDLocationInfo::KeyTy Key(this);
|
|
||||||
|
|
||||||
auto &Store = getContext().pImpl->MDLocations;
|
auto &Store = getContext().pImpl->MDLocations;
|
||||||
auto I = Store.find_as(Key);
|
if (MDLocation *N = getUniqued(Store, this))
|
||||||
if (I == Store.end()) {
|
return N;
|
||||||
Store.insert(this);
|
|
||||||
return this;
|
Store.insert(this);
|
||||||
}
|
return this;
|
||||||
return *I;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MDLocation::eraseFromStoreImpl() {
|
void MDLocation::eraseFromStoreImpl() {
|
||||||
|
Loading…
Reference in New Issue
Block a user