Commit a086b913 by Jim Stichnoth

Subzero: Remove the GlobalContext::GlobalDeclarations vector.

Elements were added to this vector, but never inspected, so it is essentially a useless field. Plus, the removal allows us to remove a couple of friend declarations. BUG=none R=kschimpf@google.com Review URL: https://codereview.chromium.org/814163004
parent e4a8f400
......@@ -851,7 +851,7 @@ void Converter::installGlobalDeclarations(Module *Mod) {
Converter.convertToIceType(FuncType->getParamType(I)));
}
FunctionDeclaration *IceFunc = FunctionDeclaration::create(
Ctx, Signature, Func.getCallingConv(), Func.getLinkage(), Func.empty());
Signature, Func.getCallingConv(), Func.getLinkage(), Func.empty());
IceFunc->setName(Func.getName());
GlobalDeclarationMap[&Func] = IceFunc;
}
......@@ -860,7 +860,7 @@ void Converter::installGlobalDeclarations(Module *Mod) {
E = Mod->global_end();
I != E; ++I) {
const GlobalVariable *GV = I;
VariableDeclaration *Var = VariableDeclaration::create(Ctx);
VariableDeclaration *Var = VariableDeclaration::create();
Var->setName(GV->getName());
Var->setAlignment(GV->getAlignment());
Var->setIsConstant(GV->isConstant());
......
......@@ -314,7 +314,6 @@ IceString GlobalContext::mangleName(const IceString &Name) const {
}
GlobalContext::~GlobalContext() {
llvm::DeleteContainerPointers(GlobalDeclarations);
llvm::DeleteContainerPointers(AllThreadContexts);
}
......@@ -448,29 +447,6 @@ ConstantList GlobalContext::getConstantPool(Type Ty) {
llvm_unreachable("Unknown type");
}
// No locking because only the bitcode parser thread calls it.
// TODO(stichnot,kschimpf): GlobalContext::GlobalDeclarations actually
// seems to be unused. If so, remove that field and this method.
FunctionDeclaration *
GlobalContext::newFunctionDeclaration(const FuncSigType *Signature,
unsigned CallingConv, unsigned Linkage,
bool IsProto) {
FunctionDeclaration *Func = new FunctionDeclaration(
*Signature, static_cast<llvm::CallingConv::ID>(CallingConv),
static_cast<llvm::GlobalValue::LinkageTypes>(Linkage), IsProto);
GlobalDeclarations.push_back(Func);
return Func;
}
// No locking because only the bitcode parser thread calls it.
// TODO(stichnot,kschimpf): GlobalContext::GlobalDeclarations actually
// seems to be unused. If so, remove that field and this method.
VariableDeclaration *GlobalContext::newVariableDeclaration() {
VariableDeclaration *Var = new VariableDeclaration();
GlobalDeclarations.push_back(Var);
return Var;
}
TimerStackIdT GlobalContext::newTimerStackID(const IceString &Name) {
if (!ALLOW_DUMP)
return 0;
......
......@@ -158,17 +158,6 @@ public:
// getConstantPool() returns a copy of the constant pool for
// constants of a given type.
ConstantList getConstantPool(Type Ty);
// Returns a new function declaration, allocated in an internal
// memory pool. Ownership of the function is maintained by this
// class instance.
FunctionDeclaration *newFunctionDeclaration(const FuncSigType *Signature,
unsigned CallingConv,
unsigned Linkage, bool IsProto);
// Returns a new global variable declaration, allocated in an
// internal memory pool. Ownership of the function is maintained by
// this class instance.
VariableDeclaration *newVariableDeclaration();
const ClFlags &getFlags() const { return Flags; }
......@@ -268,7 +257,6 @@ private:
std::unique_ptr<ELFObjectWriter> ObjectWriter;
CodeStats StatsCumulative;
std::vector<TimerStack> Timers;
std::vector<GlobalDeclaration *> GlobalDeclarations;
LockedPtr<ArenaAllocator<>> getAllocator() {
return LockedPtr<ArenaAllocator<>>(&Allocator, &AllocLock);
......
......@@ -60,12 +60,10 @@ void dumpCallingConv(Ice::Ostream &, llvm::CallingConv::ID CallingConv) {
namespace Ice {
FunctionDeclaration *
FunctionDeclaration::create(GlobalContext *Ctx, const FuncSigType &Signature,
llvm::CallingConv::ID CallingConv,
llvm::GlobalValue::LinkageTypes Linkage,
bool IsProto) {
return Ctx->newFunctionDeclaration(&Signature, CallingConv, Linkage, IsProto);
FunctionDeclaration *FunctionDeclaration::create(
const FuncSigType &Signature, llvm::CallingConv::ID CallingConv,
llvm::GlobalValue::LinkageTypes Linkage, bool IsProto) {
return new FunctionDeclaration(Signature, CallingConv, Linkage, IsProto);
}
void FunctionDeclaration::dumpType(Ostream &Stream) const {
......@@ -94,8 +92,8 @@ void FunctionDeclaration::dump(GlobalContext *Ctx, Ostream &Stream) const {
Stream << ")";
}
VariableDeclaration *VariableDeclaration::create(GlobalContext *Ctx) {
return Ctx->newVariableDeclaration();
VariableDeclaration *VariableDeclaration::create() {
return new VariableDeclaration();
}
VariableDeclaration::~VariableDeclaration() {
......
......@@ -91,11 +91,9 @@ protected:
class FunctionDeclaration : public GlobalDeclaration {
FunctionDeclaration(const FunctionDeclaration &) = delete;
FunctionDeclaration &operator=(const FunctionDeclaration &) = delete;
friend class GlobalContext;
public:
static FunctionDeclaration *create(GlobalContext *Ctx,
const FuncSigType &Signature,
static FunctionDeclaration *create(const FuncSigType &Signature,
llvm::CallingConv::ID CallingConv,
llvm::GlobalValue::LinkageTypes Linkage,
bool IsProto);
......@@ -129,10 +127,6 @@ private:
class VariableDeclaration : public GlobalDeclaration {
VariableDeclaration(const VariableDeclaration &) = delete;
VariableDeclaration &operator=(const VariableDeclaration &) = delete;
friend class GlobalContext;
// TODO(kschimpf) Factor out allocation of initializers into the
// global context, so that memory allocation/collection can be
// optimized.
public:
/// Base class for a global variable initializer.
class Initializer {
......@@ -248,7 +242,7 @@ public:
/// Models the list of initializers.
typedef std::vector<Initializer *> InitializerListType;
static VariableDeclaration *create(GlobalContext *Ctx);
static VariableDeclaration *create();
~VariableDeclaration() final;
const InitializerListType &getInitializers() const { return Initializers; }
......
......@@ -334,9 +334,8 @@ public:
/// Creates Count global variable declarations.
void CreateGlobalVariables(size_t Count) {
assert(VariableDeclarations.empty());
Ice::GlobalContext *Context = getTranslator().getContext();
for (size_t i = 0; i < Count; ++i) {
VariableDeclarations.push_back(Ice::VariableDeclaration::create(Context));
VariableDeclarations.push_back(Ice::VariableDeclaration::create());
}
}
......@@ -846,8 +845,7 @@ public:
: BlockParserBaseClass(BlockID, EnclosingParser),
Timer(Ice::TimerStack::TT_parseGlobals, getTranslator().getContext()),
InitializersNeeded(0), NextGlobalID(0),
DummyGlobalVar(
Ice::VariableDeclaration::create(getTranslator().getContext())),
DummyGlobalVar(Ice::VariableDeclaration::create()),
CurGlobalVar(DummyGlobalVar) {}
~GlobalsParser() final {}
......@@ -2929,8 +2927,7 @@ void ModuleParser::ProcessRecord() {
return;
}
Ice::FunctionDeclaration *Func = Ice::FunctionDeclaration::create(
getTranslator().getContext(), Signature, CallingConv, Linkage,
Values[2] == 0);
Signature, CallingConv, Linkage, Values[2] == 0);
if (Values[2] == 0)
Context->setNextValueIDAsImplementedFunction();
Context->setNextFunctionID(Func);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment