mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-01 12:24:24 +00:00
IR: Simplify uniquifyImpl(), NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226518 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -956,9 +956,6 @@ public:
|
|||||||
static bool classof(const Metadata *MD) {
|
static bool classof(const Metadata *MD) {
|
||||||
return MD->getMetadataID() == MDTupleKind;
|
return MD->getMetadataID() == MDTupleKind;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
|
||||||
MDTuple *uniquifyImpl();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
MDTuple *MDNode::get(LLVMContext &Context, ArrayRef<Metadata *> MDs) {
|
MDTuple *MDNode::get(LLVMContext &Context, ArrayRef<Metadata *> MDs) {
|
||||||
@ -1033,9 +1030,6 @@ public:
|
|||||||
static bool classof(const Metadata *MD) {
|
static bool classof(const Metadata *MD) {
|
||||||
return MD->getMetadataID() == MDLocationKind;
|
return MD->getMetadataID() == MDLocationKind;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
|
||||||
MDLocation *uniquifyImpl();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@ -614,13 +614,39 @@ void UniquableMDNode::deleteAsSubclass() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T, class InfoT>
|
||||||
|
static T *uniquifyImpl(T *N, DenseSet<T *, InfoT> &Store) {
|
||||||
|
if (T *U = getUniqued(Store, N))
|
||||||
|
return U;
|
||||||
|
|
||||||
|
Store.insert(N);
|
||||||
|
return N;
|
||||||
|
}
|
||||||
|
|
||||||
UniquableMDNode *UniquableMDNode::uniquify() {
|
UniquableMDNode *UniquableMDNode::uniquify() {
|
||||||
|
// Recalculate hash, if necessary.
|
||||||
|
switch (getMetadataID()) {
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
case MDTupleKind:
|
||||||
|
cast<MDTuple>(this)->recalculateHash();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try to insert into uniquing store.
|
||||||
switch (getMetadataID()) {
|
switch (getMetadataID()) {
|
||||||
default:
|
default:
|
||||||
llvm_unreachable("Invalid subclass of UniquableMDNode");
|
llvm_unreachable("Invalid subclass of UniquableMDNode");
|
||||||
#define HANDLE_UNIQUABLE_LEAF(CLASS) \
|
#define HANDLE_UNIQUABLE_LEAF(CLASS) \
|
||||||
case CLASS##Kind: \
|
case CLASS##Kind: \
|
||||||
return cast<CLASS>(this)->uniquifyImpl();
|
return uniquifyImpl(cast<CLASS>(this), getContext().pImpl->CLASS##s);
|
||||||
#include "llvm/IR/Metadata.def"
|
#include "llvm/IR/Metadata.def"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -637,13 +663,6 @@ 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T, class StoreT>
|
template <class T, class StoreT>
|
||||||
T *UniquableMDNode::storeImpl(T *N, StorageType Storage, StoreT &Store) {
|
T *UniquableMDNode::storeImpl(T *N, StorageType Storage, StoreT &Store) {
|
||||||
switch (Storage) {
|
switch (Storage) {
|
||||||
@ -677,16 +696,6 @@ MDTuple *MDTuple::getImpl(LLVMContext &Context, ArrayRef<Metadata *> MDs,
|
|||||||
Storage, Context.pImpl->MDTuples);
|
Storage, Context.pImpl->MDTuples);
|
||||||
}
|
}
|
||||||
|
|
||||||
MDTuple *MDTuple::uniquifyImpl() {
|
|
||||||
recalculateHash();
|
|
||||||
auto &Store = getContext().pImpl->MDTuples;
|
|
||||||
if (MDTuple *N = getUniqued(Store, this))
|
|
||||||
return N;
|
|
||||||
|
|
||||||
Store.insert(this);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
MDLocation::MDLocation(LLVMContext &C, StorageType Storage, unsigned Line,
|
MDLocation::MDLocation(LLVMContext &C, StorageType Storage, unsigned Line,
|
||||||
unsigned Column, ArrayRef<Metadata *> MDs)
|
unsigned Column, ArrayRef<Metadata *> MDs)
|
||||||
: UniquableMDNode(C, MDLocationKind, Storage, MDs) {
|
: UniquableMDNode(C, MDLocationKind, Storage, MDs) {
|
||||||
@ -741,15 +750,6 @@ MDLocation *MDLocation::getImpl(LLVMContext &Context, unsigned Line,
|
|||||||
Storage, Context.pImpl->MDLocations);
|
Storage, Context.pImpl->MDLocations);
|
||||||
}
|
}
|
||||||
|
|
||||||
MDLocation *MDLocation::uniquifyImpl() {
|
|
||||||
auto &Store = getContext().pImpl->MDLocations;
|
|
||||||
if (MDLocation *N = getUniqued(Store, this))
|
|
||||||
return N;
|
|
||||||
|
|
||||||
Store.insert(this);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MDNode::deleteTemporary(MDNode *N) {
|
void MDNode::deleteTemporary(MDNode *N) {
|
||||||
assert(N->isTemporary() && "Expected temporary node");
|
assert(N->isTemporary() && "Expected temporary node");
|
||||||
cast<UniquableMDNode>(N)->deleteAsSubclass();
|
cast<UniquableMDNode>(N)->deleteAsSubclass();
|
||||||
|
Reference in New Issue
Block a user