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
diff --git a/src/IceConverter.cpp b/src/IceConverter.cpp
index 72f5a5a..325fda8 100644
--- a/src/IceConverter.cpp
+++ b/src/IceConverter.cpp
@@ -851,7 +851,7 @@
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 @@
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());
diff --git a/src/IceGlobalContext.cpp b/src/IceGlobalContext.cpp
index 2b143f7..74dfb9e 100644
--- a/src/IceGlobalContext.cpp
+++ b/src/IceGlobalContext.cpp
@@ -314,7 +314,6 @@
}
GlobalContext::~GlobalContext() {
- llvm::DeleteContainerPointers(GlobalDeclarations);
llvm::DeleteContainerPointers(AllThreadContexts);
}
@@ -448,29 +447,6 @@
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;
diff --git a/src/IceGlobalContext.h b/src/IceGlobalContext.h
index ab9c814..751147e 100644
--- a/src/IceGlobalContext.h
+++ b/src/IceGlobalContext.h
@@ -158,17 +158,6 @@
// 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 @@
std::unique_ptr<ELFObjectWriter> ObjectWriter;
CodeStats StatsCumulative;
std::vector<TimerStack> Timers;
- std::vector<GlobalDeclaration *> GlobalDeclarations;
LockedPtr<ArenaAllocator<>> getAllocator() {
return LockedPtr<ArenaAllocator<>>(&Allocator, &AllocLock);
diff --git a/src/IceGlobalInits.cpp b/src/IceGlobalInits.cpp
index 6cf78aa..4f209f8 100644
--- a/src/IceGlobalInits.cpp
+++ b/src/IceGlobalInits.cpp
@@ -60,12 +60,10 @@
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 @@
Stream << ")";
}
-VariableDeclaration *VariableDeclaration::create(GlobalContext *Ctx) {
- return Ctx->newVariableDeclaration();
+VariableDeclaration *VariableDeclaration::create() {
+ return new VariableDeclaration();
}
VariableDeclaration::~VariableDeclaration() {
diff --git a/src/IceGlobalInits.h b/src/IceGlobalInits.h
index 082be3c..0d560a1 100644
--- a/src/IceGlobalInits.h
+++ b/src/IceGlobalInits.h
@@ -91,11 +91,9 @@
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 @@
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 @@
/// 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; }
diff --git a/src/PNaClTranslator.cpp b/src/PNaClTranslator.cpp
index a405d8b..33dda4b 100644
--- a/src/PNaClTranslator.cpp
+++ b/src/PNaClTranslator.cpp
@@ -334,9 +334,8 @@
/// 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 @@
: 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 @@
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);