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) { ...@@ -851,7 +851,7 @@ void Converter::installGlobalDeclarations(Module *Mod) {
Converter.convertToIceType(FuncType->getParamType(I))); Converter.convertToIceType(FuncType->getParamType(I)));
} }
FunctionDeclaration *IceFunc = FunctionDeclaration::create( FunctionDeclaration *IceFunc = FunctionDeclaration::create(
Ctx, Signature, Func.getCallingConv(), Func.getLinkage(), Func.empty()); Signature, Func.getCallingConv(), Func.getLinkage(), Func.empty());
IceFunc->setName(Func.getName()); IceFunc->setName(Func.getName());
GlobalDeclarationMap[&Func] = IceFunc; GlobalDeclarationMap[&Func] = IceFunc;
} }
...@@ -860,7 +860,7 @@ void Converter::installGlobalDeclarations(Module *Mod) { ...@@ -860,7 +860,7 @@ void Converter::installGlobalDeclarations(Module *Mod) {
E = Mod->global_end(); E = Mod->global_end();
I != E; ++I) { I != E; ++I) {
const GlobalVariable *GV = I; const GlobalVariable *GV = I;
VariableDeclaration *Var = VariableDeclaration::create(Ctx); VariableDeclaration *Var = VariableDeclaration::create();
Var->setName(GV->getName()); Var->setName(GV->getName());
Var->setAlignment(GV->getAlignment()); Var->setAlignment(GV->getAlignment());
Var->setIsConstant(GV->isConstant()); Var->setIsConstant(GV->isConstant());
......
...@@ -314,7 +314,6 @@ IceString GlobalContext::mangleName(const IceString &Name) const { ...@@ -314,7 +314,6 @@ IceString GlobalContext::mangleName(const IceString &Name) const {
} }
GlobalContext::~GlobalContext() { GlobalContext::~GlobalContext() {
llvm::DeleteContainerPointers(GlobalDeclarations);
llvm::DeleteContainerPointers(AllThreadContexts); llvm::DeleteContainerPointers(AllThreadContexts);
} }
...@@ -448,29 +447,6 @@ ConstantList GlobalContext::getConstantPool(Type Ty) { ...@@ -448,29 +447,6 @@ ConstantList GlobalContext::getConstantPool(Type Ty) {
llvm_unreachable("Unknown type"); 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) { TimerStackIdT GlobalContext::newTimerStackID(const IceString &Name) {
if (!ALLOW_DUMP) if (!ALLOW_DUMP)
return 0; return 0;
......
...@@ -158,17 +158,6 @@ public: ...@@ -158,17 +158,6 @@ public:
// getConstantPool() returns a copy of the constant pool for // getConstantPool() returns a copy of the constant pool for
// constants of a given type. // constants of a given type.
ConstantList getConstantPool(Type Ty); 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; } const ClFlags &getFlags() const { return Flags; }
...@@ -268,7 +257,6 @@ private: ...@@ -268,7 +257,6 @@ private:
std::unique_ptr<ELFObjectWriter> ObjectWriter; std::unique_ptr<ELFObjectWriter> ObjectWriter;
CodeStats StatsCumulative; CodeStats StatsCumulative;
std::vector<TimerStack> Timers; std::vector<TimerStack> Timers;
std::vector<GlobalDeclaration *> GlobalDeclarations;
LockedPtr<ArenaAllocator<>> getAllocator() { LockedPtr<ArenaAllocator<>> getAllocator() {
return LockedPtr<ArenaAllocator<>>(&Allocator, &AllocLock); return LockedPtr<ArenaAllocator<>>(&Allocator, &AllocLock);
......
...@@ -60,12 +60,10 @@ void dumpCallingConv(Ice::Ostream &, llvm::CallingConv::ID CallingConv) { ...@@ -60,12 +60,10 @@ void dumpCallingConv(Ice::Ostream &, llvm::CallingConv::ID CallingConv) {
namespace Ice { namespace Ice {
FunctionDeclaration * FunctionDeclaration *FunctionDeclaration::create(
FunctionDeclaration::create(GlobalContext *Ctx, const FuncSigType &Signature, const FuncSigType &Signature, llvm::CallingConv::ID CallingConv,
llvm::CallingConv::ID CallingConv, llvm::GlobalValue::LinkageTypes Linkage, bool IsProto) {
llvm::GlobalValue::LinkageTypes Linkage, return new FunctionDeclaration(Signature, CallingConv, Linkage, IsProto);
bool IsProto) {
return Ctx->newFunctionDeclaration(&Signature, CallingConv, Linkage, IsProto);
} }
void FunctionDeclaration::dumpType(Ostream &Stream) const { void FunctionDeclaration::dumpType(Ostream &Stream) const {
...@@ -94,8 +92,8 @@ void FunctionDeclaration::dump(GlobalContext *Ctx, Ostream &Stream) const { ...@@ -94,8 +92,8 @@ void FunctionDeclaration::dump(GlobalContext *Ctx, Ostream &Stream) const {
Stream << ")"; Stream << ")";
} }
VariableDeclaration *VariableDeclaration::create(GlobalContext *Ctx) { VariableDeclaration *VariableDeclaration::create() {
return Ctx->newVariableDeclaration(); return new VariableDeclaration();
} }
VariableDeclaration::~VariableDeclaration() { VariableDeclaration::~VariableDeclaration() {
......
...@@ -91,11 +91,9 @@ protected: ...@@ -91,11 +91,9 @@ protected:
class FunctionDeclaration : public GlobalDeclaration { class FunctionDeclaration : public GlobalDeclaration {
FunctionDeclaration(const FunctionDeclaration &) = delete; FunctionDeclaration(const FunctionDeclaration &) = delete;
FunctionDeclaration &operator=(const FunctionDeclaration &) = delete; FunctionDeclaration &operator=(const FunctionDeclaration &) = delete;
friend class GlobalContext;
public: public:
static FunctionDeclaration *create(GlobalContext *Ctx, static FunctionDeclaration *create(const FuncSigType &Signature,
const FuncSigType &Signature,
llvm::CallingConv::ID CallingConv, llvm::CallingConv::ID CallingConv,
llvm::GlobalValue::LinkageTypes Linkage, llvm::GlobalValue::LinkageTypes Linkage,
bool IsProto); bool IsProto);
...@@ -129,10 +127,6 @@ private: ...@@ -129,10 +127,6 @@ private:
class VariableDeclaration : public GlobalDeclaration { class VariableDeclaration : public GlobalDeclaration {
VariableDeclaration(const VariableDeclaration &) = delete; VariableDeclaration(const VariableDeclaration &) = delete;
VariableDeclaration &operator=(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: public:
/// Base class for a global variable initializer. /// Base class for a global variable initializer.
class Initializer { class Initializer {
...@@ -248,7 +242,7 @@ public: ...@@ -248,7 +242,7 @@ public:
/// Models the list of initializers. /// Models the list of initializers.
typedef std::vector<Initializer *> InitializerListType; typedef std::vector<Initializer *> InitializerListType;
static VariableDeclaration *create(GlobalContext *Ctx); static VariableDeclaration *create();
~VariableDeclaration() final; ~VariableDeclaration() final;
const InitializerListType &getInitializers() const { return Initializers; } const InitializerListType &getInitializers() const { return Initializers; }
......
...@@ -334,9 +334,8 @@ public: ...@@ -334,9 +334,8 @@ public:
/// Creates Count global variable declarations. /// Creates Count global variable declarations.
void CreateGlobalVariables(size_t Count) { void CreateGlobalVariables(size_t Count) {
assert(VariableDeclarations.empty()); assert(VariableDeclarations.empty());
Ice::GlobalContext *Context = getTranslator().getContext();
for (size_t i = 0; i < Count; ++i) { 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: ...@@ -846,8 +845,7 @@ public:
: BlockParserBaseClass(BlockID, EnclosingParser), : BlockParserBaseClass(BlockID, EnclosingParser),
Timer(Ice::TimerStack::TT_parseGlobals, getTranslator().getContext()), Timer(Ice::TimerStack::TT_parseGlobals, getTranslator().getContext()),
InitializersNeeded(0), NextGlobalID(0), InitializersNeeded(0), NextGlobalID(0),
DummyGlobalVar( DummyGlobalVar(Ice::VariableDeclaration::create()),
Ice::VariableDeclaration::create(getTranslator().getContext())),
CurGlobalVar(DummyGlobalVar) {} CurGlobalVar(DummyGlobalVar) {}
~GlobalsParser() final {} ~GlobalsParser() final {}
...@@ -2929,8 +2927,7 @@ void ModuleParser::ProcessRecord() { ...@@ -2929,8 +2927,7 @@ void ModuleParser::ProcessRecord() {
return; return;
} }
Ice::FunctionDeclaration *Func = Ice::FunctionDeclaration::create( Ice::FunctionDeclaration *Func = Ice::FunctionDeclaration::create(
getTranslator().getContext(), Signature, CallingConv, Linkage, Signature, CallingConv, Linkage, Values[2] == 0);
Values[2] == 0);
if (Values[2] == 0) if (Values[2] == 0)
Context->setNextValueIDAsImplementedFunction(); Context->setNextValueIDAsImplementedFunction();
Context->setNextFunctionID(Func); 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