mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
IR: Give the TypeAllocator a more generic name and start using it for section names as well. NFCI.
This prepares us to start using it for partition names. llvm-svn: 361922
This commit is contained in:
parent
52a449e72d
commit
979e0e3ffd
@ -192,9 +192,8 @@ void GlobalObject::setSection(StringRef S) {
|
|||||||
|
|
||||||
// Get or create a stable section name string and put it in the table in the
|
// Get or create a stable section name string and put it in the table in the
|
||||||
// context.
|
// context.
|
||||||
if (!S.empty()) {
|
if (!S.empty())
|
||||||
S = getContext().pImpl->SectionStrings.insert(S).first->first();
|
S = getContext().pImpl->Saver.save(S);
|
||||||
}
|
|
||||||
getContext().pImpl->GlobalObjectSections[this] = S;
|
getContext().pImpl->GlobalObjectSections[this] = S;
|
||||||
|
|
||||||
// Update the HasSectionHashEntryBit. Setting the section to the empty string
|
// Update the HasSectionHashEntryBit. Setting the section to the empty string
|
||||||
|
@ -30,7 +30,6 @@
|
|||||||
#include "llvm/ADT/SmallVector.h"
|
#include "llvm/ADT/SmallVector.h"
|
||||||
#include "llvm/ADT/StringMap.h"
|
#include "llvm/ADT/StringMap.h"
|
||||||
#include "llvm/ADT/StringRef.h"
|
#include "llvm/ADT/StringRef.h"
|
||||||
#include "llvm/ADT/StringSet.h"
|
|
||||||
#include "llvm/BinaryFormat/Dwarf.h"
|
#include "llvm/BinaryFormat/Dwarf.h"
|
||||||
#include "llvm/IR/Constants.h"
|
#include "llvm/IR/Constants.h"
|
||||||
#include "llvm/IR/DebugInfoMetadata.h"
|
#include "llvm/IR/DebugInfoMetadata.h"
|
||||||
@ -41,6 +40,7 @@
|
|||||||
#include "llvm/IR/TrackingMDRef.h"
|
#include "llvm/IR/TrackingMDRef.h"
|
||||||
#include "llvm/Support/Allocator.h"
|
#include "llvm/Support/Allocator.h"
|
||||||
#include "llvm/Support/Casting.h"
|
#include "llvm/Support/Casting.h"
|
||||||
|
#include "llvm/Support/StringSaver.h"
|
||||||
#include "llvm/Support/YAMLTraits.h"
|
#include "llvm/Support/YAMLTraits.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
@ -1321,9 +1321,8 @@ public:
|
|||||||
Type X86_FP80Ty, FP128Ty, PPC_FP128Ty, X86_MMXTy;
|
Type X86_FP80Ty, FP128Ty, PPC_FP128Ty, X86_MMXTy;
|
||||||
IntegerType Int1Ty, Int8Ty, Int16Ty, Int32Ty, Int64Ty, Int128Ty;
|
IntegerType Int1Ty, Int8Ty, Int16Ty, Int32Ty, Int64Ty, Int128Ty;
|
||||||
|
|
||||||
/// TypeAllocator - All dynamically allocated types are allocated from this.
|
BumpPtrAllocator Alloc;
|
||||||
/// They live forever until the context is torn down.
|
UniqueStringSaver Saver{Alloc};
|
||||||
BumpPtrAllocator TypeAllocator;
|
|
||||||
|
|
||||||
DenseMap<unsigned, IntegerType*> IntegerTypes;
|
DenseMap<unsigned, IntegerType*> IntegerTypes;
|
||||||
|
|
||||||
@ -1357,9 +1356,6 @@ public:
|
|||||||
/// Collection of per-GlobalObject sections used in this context.
|
/// Collection of per-GlobalObject sections used in this context.
|
||||||
DenseMap<const GlobalObject *, StringRef> GlobalObjectSections;
|
DenseMap<const GlobalObject *, StringRef> GlobalObjectSections;
|
||||||
|
|
||||||
/// Stable collection of section strings.
|
|
||||||
StringSet<> SectionStrings;
|
|
||||||
|
|
||||||
/// DiscriminatorTable - This table maps file:line locations to an
|
/// DiscriminatorTable - This table maps file:line locations to an
|
||||||
/// integer representing the next DWARF path discriminator to assign to
|
/// integer representing the next DWARF path discriminator to assign to
|
||||||
/// instructions in different blocks at the same location.
|
/// instructions in different blocks at the same location.
|
||||||
|
@ -255,7 +255,7 @@ IntegerType *IntegerType::get(LLVMContext &C, unsigned NumBits) {
|
|||||||
IntegerType *&Entry = C.pImpl->IntegerTypes[NumBits];
|
IntegerType *&Entry = C.pImpl->IntegerTypes[NumBits];
|
||||||
|
|
||||||
if (!Entry)
|
if (!Entry)
|
||||||
Entry = new (C.pImpl->TypeAllocator) IntegerType(C, NumBits);
|
Entry = new (C.pImpl->Alloc) IntegerType(C, NumBits);
|
||||||
|
|
||||||
return Entry;
|
return Entry;
|
||||||
}
|
}
|
||||||
@ -307,7 +307,7 @@ FunctionType *FunctionType::get(Type *ReturnType,
|
|||||||
if (Insertion.second) {
|
if (Insertion.second) {
|
||||||
// The function type was not found. Allocate one and update FunctionTypes
|
// The function type was not found. Allocate one and update FunctionTypes
|
||||||
// in-place.
|
// in-place.
|
||||||
FT = (FunctionType *)pImpl->TypeAllocator.Allocate(
|
FT = (FunctionType *)pImpl->Alloc.Allocate(
|
||||||
sizeof(FunctionType) + sizeof(Type *) * (Params.size() + 1),
|
sizeof(FunctionType) + sizeof(Type *) * (Params.size() + 1),
|
||||||
alignof(FunctionType));
|
alignof(FunctionType));
|
||||||
new (FT) FunctionType(ReturnType, Params, isVarArg);
|
new (FT) FunctionType(ReturnType, Params, isVarArg);
|
||||||
@ -353,7 +353,7 @@ StructType *StructType::get(LLVMContext &Context, ArrayRef<Type*> ETypes,
|
|||||||
if (Insertion.second) {
|
if (Insertion.second) {
|
||||||
// The struct type was not found. Allocate one and update AnonStructTypes
|
// The struct type was not found. Allocate one and update AnonStructTypes
|
||||||
// in-place.
|
// in-place.
|
||||||
ST = new (Context.pImpl->TypeAllocator) StructType(Context);
|
ST = new (Context.pImpl->Alloc) StructType(Context);
|
||||||
ST->setSubclassData(SCDB_IsLiteral); // Literal struct.
|
ST->setSubclassData(SCDB_IsLiteral); // Literal struct.
|
||||||
ST->setBody(ETypes, isPacked);
|
ST->setBody(ETypes, isPacked);
|
||||||
*Insertion.first = ST;
|
*Insertion.first = ST;
|
||||||
@ -379,7 +379,7 @@ void StructType::setBody(ArrayRef<Type*> Elements, bool isPacked) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ContainedTys = Elements.copy(getContext().pImpl->TypeAllocator).data();
|
ContainedTys = Elements.copy(getContext().pImpl->Alloc).data();
|
||||||
}
|
}
|
||||||
|
|
||||||
void StructType::setName(StringRef Name) {
|
void StructType::setName(StringRef Name) {
|
||||||
@ -434,7 +434,7 @@ void StructType::setName(StringRef Name) {
|
|||||||
// StructType Helper functions.
|
// StructType Helper functions.
|
||||||
|
|
||||||
StructType *StructType::create(LLVMContext &Context, StringRef Name) {
|
StructType *StructType::create(LLVMContext &Context, StringRef Name) {
|
||||||
StructType *ST = new (Context.pImpl->TypeAllocator) StructType(Context);
|
StructType *ST = new (Context.pImpl->Alloc) StructType(Context);
|
||||||
if (!Name.empty())
|
if (!Name.empty())
|
||||||
ST->setName(Name);
|
ST->setName(Name);
|
||||||
return ST;
|
return ST;
|
||||||
@ -585,7 +585,7 @@ ArrayType *ArrayType::get(Type *ElementType, uint64_t NumElements) {
|
|||||||
pImpl->ArrayTypes[std::make_pair(ElementType, NumElements)];
|
pImpl->ArrayTypes[std::make_pair(ElementType, NumElements)];
|
||||||
|
|
||||||
if (!Entry)
|
if (!Entry)
|
||||||
Entry = new (pImpl->TypeAllocator) ArrayType(ElementType, NumElements);
|
Entry = new (pImpl->Alloc) ArrayType(ElementType, NumElements);
|
||||||
return Entry;
|
return Entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -613,7 +613,7 @@ VectorType *VectorType::get(Type *ElementType, unsigned NumElements) {
|
|||||||
->VectorTypes[std::make_pair(ElementType, NumElements)];
|
->VectorTypes[std::make_pair(ElementType, NumElements)];
|
||||||
|
|
||||||
if (!Entry)
|
if (!Entry)
|
||||||
Entry = new (pImpl->TypeAllocator) VectorType(ElementType, NumElements);
|
Entry = new (pImpl->Alloc) VectorType(ElementType, NumElements);
|
||||||
return Entry;
|
return Entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -637,7 +637,7 @@ PointerType *PointerType::get(Type *EltTy, unsigned AddressSpace) {
|
|||||||
: CImpl->ASPointerTypes[std::make_pair(EltTy, AddressSpace)];
|
: CImpl->ASPointerTypes[std::make_pair(EltTy, AddressSpace)];
|
||||||
|
|
||||||
if (!Entry)
|
if (!Entry)
|
||||||
Entry = new (CImpl->TypeAllocator) PointerType(EltTy, AddressSpace);
|
Entry = new (CImpl->Alloc) PointerType(EltTy, AddressSpace);
|
||||||
return Entry;
|
return Entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user