mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-18 10:24:45 +00:00
bump pointer allocate LLVM IR types, since they are never deallocated.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135248 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -91,20 +91,4 @@ LLVMContextImpl::~LLVMContextImpl() {
|
|||||||
"Destroying all MDNodes didn't empty the Context's sets.");
|
"Destroying all MDNodes didn't empty the Context's sets.");
|
||||||
// Destroy MDStrings.
|
// Destroy MDStrings.
|
||||||
DeleteContainerSeconds(MDStringCache);
|
DeleteContainerSeconds(MDStringCache);
|
||||||
|
|
||||||
// Destroy types.
|
|
||||||
DeleteContainerSeconds(IntegerTypes);
|
|
||||||
DeleteContainerSeconds(FunctionTypes);
|
|
||||||
DeleteContainerSeconds(AnonStructTypes);
|
|
||||||
DeleteContainerSeconds(ArrayTypes);
|
|
||||||
DeleteContainerSeconds(VectorTypes);
|
|
||||||
DeleteContainerSeconds(PointerTypes);
|
|
||||||
DeleteContainerSeconds(ASPointerTypes);
|
|
||||||
|
|
||||||
for (StringMap<StructType *>::iterator I = NamedStructTypes.begin(),
|
|
||||||
E = NamedStructTypes.end(); I != E; ++I)
|
|
||||||
delete I->getValue();
|
|
||||||
for (SmallPtrSet<StructType*, 16>::iterator I = EmptyNamedStructTypes.begin(),
|
|
||||||
E = EmptyNamedStructTypes.end(); I != E; ++I)
|
|
||||||
delete *I;
|
|
||||||
}
|
}
|
||||||
|
@@ -173,13 +173,17 @@ public:
|
|||||||
Type X86_FP80Ty, FP128Ty, PPC_FP128Ty, X86_MMXTy;
|
Type X86_FP80Ty, FP128Ty, PPC_FP128Ty, X86_MMXTy;
|
||||||
IntegerType Int1Ty, Int8Ty, Int16Ty, Int32Ty, Int64Ty;
|
IntegerType Int1Ty, Int8Ty, Int16Ty, Int32Ty, Int64Ty;
|
||||||
|
|
||||||
|
|
||||||
|
/// TypeAllocator - All dynamically allocated types are allocated from this.
|
||||||
|
/// They live forever until the context is torn down.
|
||||||
|
BumpPtrAllocator TypeAllocator;
|
||||||
|
|
||||||
DenseMap<unsigned, IntegerType*> IntegerTypes;
|
DenseMap<unsigned, IntegerType*> IntegerTypes;
|
||||||
|
|
||||||
// TODO: Optimize FunctionTypes/AnonStructTypes!
|
// TODO: Optimize FunctionTypes/AnonStructTypes!
|
||||||
std::map<std::vector<Type*>, FunctionType*> FunctionTypes;
|
std::map<std::vector<Type*>, FunctionType*> FunctionTypes;
|
||||||
std::map<std::vector<Type*>, StructType*> AnonStructTypes;
|
std::map<std::vector<Type*>, StructType*> AnonStructTypes;
|
||||||
StringMap<StructType*> NamedStructTypes;
|
StringMap<StructType*> NamedStructTypes;
|
||||||
SmallPtrSet<StructType*, 16> EmptyNamedStructTypes;
|
|
||||||
unsigned NamedStructTypesUniqueID;
|
unsigned NamedStructTypesUniqueID;
|
||||||
|
|
||||||
DenseMap<std::pair<Type *, uint64_t>, ArrayType*> ArrayTypes;
|
DenseMap<std::pair<Type *, uint64_t>, ArrayType*> ArrayTypes;
|
||||||
|
@@ -288,7 +288,7 @@ IntegerType *IntegerType::get(LLVMContext &C, unsigned NumBits) {
|
|||||||
IntegerType *&Entry = C.pImpl->IntegerTypes[NumBits];
|
IntegerType *&Entry = C.pImpl->IntegerTypes[NumBits];
|
||||||
|
|
||||||
if (Entry == 0)
|
if (Entry == 0)
|
||||||
Entry = new IntegerType(C, NumBits);
|
Entry = new (C.pImpl->TypeAllocator) IntegerType(C, NumBits);
|
||||||
|
|
||||||
return Entry;
|
return Entry;
|
||||||
}
|
}
|
||||||
@@ -337,11 +337,13 @@ FunctionType *FunctionType::get(const Type *ReturnType,
|
|||||||
if (isVarArg)
|
if (isVarArg)
|
||||||
Key.push_back(0);
|
Key.push_back(0);
|
||||||
|
|
||||||
FunctionType *&FT = ReturnType->getContext().pImpl->FunctionTypes[Key];
|
LLVMContextImpl *pImpl = ReturnType->getContext().pImpl;
|
||||||
|
FunctionType *&FT = pImpl->FunctionTypes[Key];
|
||||||
|
|
||||||
if (FT == 0) {
|
if (FT == 0) {
|
||||||
FT = (FunctionType*) operator new(sizeof(FunctionType) +
|
FT = (FunctionType*) pImpl->TypeAllocator.
|
||||||
sizeof(Type*)*(Params.size()+1));
|
Allocate(sizeof(FunctionType) + sizeof(Type*)*(Params.size()+1),
|
||||||
|
AlignOf<FunctionType>::Alignment);
|
||||||
new (FT) FunctionType(ReturnType, Params, isVarArg);
|
new (FT) FunctionType(ReturnType, Params, isVarArg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -386,11 +388,10 @@ StructType *StructType::get(LLVMContext &Context, ArrayRef<Type*> ETypes,
|
|||||||
Key.push_back(0);
|
Key.push_back(0);
|
||||||
|
|
||||||
StructType *&ST = Context.pImpl->AnonStructTypes[Key];
|
StructType *&ST = Context.pImpl->AnonStructTypes[Key];
|
||||||
|
|
||||||
if (ST) return ST;
|
if (ST) return ST;
|
||||||
|
|
||||||
// Value not found. Create a new type!
|
// Value not found. Create a new type!
|
||||||
ST = new StructType(Context);
|
ST = new (Context.pImpl->TypeAllocator) StructType(Context);
|
||||||
ST->setSubclassData(SCDB_IsAnonymous); // Anonymous struct.
|
ST->setSubclassData(SCDB_IsAnonymous); // Anonymous struct.
|
||||||
ST->setBody(ETypes, isPacked);
|
ST->setBody(ETypes, isPacked);
|
||||||
return ST;
|
return ST;
|
||||||
@@ -403,7 +404,8 @@ void StructType::setBody(ArrayRef<Type*> Elements, bool isPacked) {
|
|||||||
if (isPacked)
|
if (isPacked)
|
||||||
setSubclassData(getSubclassData() | SCDB_Packed);
|
setSubclassData(getSubclassData() | SCDB_Packed);
|
||||||
|
|
||||||
Type **Elts = new Type*[Elements.size()];
|
Type **Elts = getContext().pImpl->
|
||||||
|
TypeAllocator.Allocate<Type*>(Elements.size());
|
||||||
memcpy(Elts, Elements.data(), sizeof(Elements[0])*Elements.size());
|
memcpy(Elts, Elements.data(), sizeof(Elements[0])*Elements.size());
|
||||||
|
|
||||||
ContainedTys = Elts;
|
ContainedTys = Elts;
|
||||||
@@ -411,11 +413,9 @@ void StructType::setBody(ArrayRef<Type*> Elements, bool isPacked) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
StructType *StructType::createNamed(LLVMContext &Context, StringRef Name) {
|
StructType *StructType::createNamed(LLVMContext &Context, StringRef Name) {
|
||||||
StructType *ST = new StructType(Context);
|
StructType *ST = new (Context.pImpl->TypeAllocator) StructType(Context);
|
||||||
if (!Name.empty())
|
if (!Name.empty())
|
||||||
ST->setName(Name);
|
ST->setName(Name);
|
||||||
else
|
|
||||||
Context.pImpl->EmptyNamedStructTypes.insert(ST);
|
|
||||||
return ST;
|
return ST;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -426,16 +426,11 @@ void StructType::setName(StringRef Name) {
|
|||||||
if (SymbolTableEntry) {
|
if (SymbolTableEntry) {
|
||||||
getContext().pImpl->NamedStructTypes.erase(getName());
|
getContext().pImpl->NamedStructTypes.erase(getName());
|
||||||
SymbolTableEntry = 0;
|
SymbolTableEntry = 0;
|
||||||
} else {
|
|
||||||
getContext().pImpl->EmptyNamedStructTypes.erase(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this is just removing the name, we're done.
|
// If this is just removing the name, we're done.
|
||||||
if (Name.empty()) {
|
if (Name.empty())
|
||||||
// Keep track of types with no names so we can free them.
|
|
||||||
getContext().pImpl->EmptyNamedStructTypes.insert(this);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
// Look up the entry for the name.
|
// Look up the entry for the name.
|
||||||
StringMapEntry<StructType*> *Entry =
|
StringMapEntry<StructType*> *Entry =
|
||||||
@@ -614,11 +609,12 @@ ArrayType *ArrayType::get(const Type *elementType, uint64_t NumElements) {
|
|||||||
Type *ElementType = const_cast<Type*>(elementType);
|
Type *ElementType = const_cast<Type*>(elementType);
|
||||||
assert(isValidElementType(ElementType) && "Invalid type for array element!");
|
assert(isValidElementType(ElementType) && "Invalid type for array element!");
|
||||||
|
|
||||||
ArrayType *&Entry = ElementType->getContext().pImpl
|
LLVMContextImpl *pImpl = ElementType->getContext().pImpl;
|
||||||
->ArrayTypes[std::make_pair(ElementType, NumElements)];
|
ArrayType *&Entry =
|
||||||
|
pImpl->ArrayTypes[std::make_pair(ElementType, NumElements)];
|
||||||
|
|
||||||
if (Entry == 0)
|
if (Entry == 0)
|
||||||
Entry = new ArrayType(ElementType, NumElements);
|
Entry = new (pImpl->TypeAllocator) ArrayType(ElementType, NumElements);
|
||||||
return Entry;
|
return Entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -642,11 +638,12 @@ VectorType *VectorType::get(const Type *elementType, unsigned NumElements) {
|
|||||||
assert(isValidElementType(ElementType) &&
|
assert(isValidElementType(ElementType) &&
|
||||||
"Elements of a VectorType must be a primitive type");
|
"Elements of a VectorType must be a primitive type");
|
||||||
|
|
||||||
|
LLVMContextImpl *pImpl = ElementType->getContext().pImpl;
|
||||||
VectorType *&Entry = ElementType->getContext().pImpl
|
VectorType *&Entry = ElementType->getContext().pImpl
|
||||||
->VectorTypes[std::make_pair(ElementType, NumElements)];
|
->VectorTypes[std::make_pair(ElementType, NumElements)];
|
||||||
|
|
||||||
if (Entry == 0)
|
if (Entry == 0)
|
||||||
Entry = new VectorType(ElementType, NumElements);
|
Entry = new (pImpl->TypeAllocator) VectorType(ElementType, NumElements);
|
||||||
return Entry;
|
return Entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -670,7 +667,7 @@ PointerType *PointerType::get(const Type *eltTy, unsigned AddressSpace) {
|
|||||||
: CImpl->ASPointerTypes[std::make_pair(EltTy, AddressSpace)];
|
: CImpl->ASPointerTypes[std::make_pair(EltTy, AddressSpace)];
|
||||||
|
|
||||||
if (Entry == 0)
|
if (Entry == 0)
|
||||||
Entry = new PointerType(EltTy, AddressSpace);
|
Entry = new (CImpl->TypeAllocator) PointerType(EltTy, AddressSpace);
|
||||||
return Entry;
|
return Entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user