From 667b6a8f41f3d6b723479803e03c3dc5e688df0d Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Tue, 25 Oct 2016 02:54:08 +0000 Subject: [PATCH] IR: Deduplicate getParent() functions on derived classes of GlobalValue into the base class. NFCI. llvm-svn: 285050 --- include/llvm/IR/Function.h | 2 -- include/llvm/IR/GlobalAlias.h | 2 -- include/llvm/IR/GlobalIFunc.h | 2 -- include/llvm/IR/GlobalValue.h | 6 ++++++ include/llvm/IR/GlobalVariable.h | 2 -- lib/IR/Function.cpp | 4 ---- lib/IR/Globals.cpp | 12 ------------ 7 files changed, 6 insertions(+), 24 deletions(-) diff --git a/include/llvm/IR/Function.h b/include/llvm/IR/Function.h index 57b328c39c7..e6e26c89f2f 100644 --- a/include/llvm/IR/Function.h +++ b/include/llvm/IR/Function.h @@ -74,8 +74,6 @@ private: friend class SymbolTableListTraits; - void setParent(Module *parent); - /// hasLazyArguments/CheckLazyArguments - The argument list of a function is /// built on demand, so that the list isn't allocated until the first client /// needs it. The hasLazyArguments predicate returns true if the arg list diff --git a/include/llvm/IR/GlobalAlias.h b/include/llvm/IR/GlobalAlias.h index 3ae3e4a001e..3727c10faa7 100644 --- a/include/llvm/IR/GlobalAlias.h +++ b/include/llvm/IR/GlobalAlias.h @@ -30,8 +30,6 @@ class GlobalAlias : public GlobalIndirectSymbol, void operator=(const GlobalAlias &) = delete; GlobalAlias(const GlobalAlias &) = delete; - void setParent(Module *parent); - GlobalAlias(Type *Ty, unsigned AddressSpace, LinkageTypes Linkage, const Twine &Name, Constant *Aliasee, Module *Parent); diff --git a/include/llvm/IR/GlobalIFunc.h b/include/llvm/IR/GlobalIFunc.h index 0cbe882c58d..afe6b3d2c35 100644 --- a/include/llvm/IR/GlobalIFunc.h +++ b/include/llvm/IR/GlobalIFunc.h @@ -35,8 +35,6 @@ class GlobalIFunc final : public GlobalIndirectSymbol, void operator=(const GlobalIFunc &) = delete; GlobalIFunc(const GlobalIFunc &) = delete; - void setParent(Module *parent); - GlobalIFunc(Type *Ty, unsigned AddressSpace, LinkageTypes Linkage, const Twine &Name, Constant *Resolver, Module *Parent); diff --git a/include/llvm/IR/GlobalValue.h b/include/llvm/IR/GlobalValue.h index bd7cacc3248..2b7bb783d30 100644 --- a/include/llvm/IR/GlobalValue.h +++ b/include/llvm/IR/GlobalValue.h @@ -140,6 +140,12 @@ protected: } Module *Parent; // The containing module. + + // Used by SymbolTableListTraits. + void setParent(Module *parent) { + Parent = parent; + } + public: enum ThreadLocalMode { NotThreadLocal = 0, diff --git a/include/llvm/IR/GlobalVariable.h b/include/llvm/IR/GlobalVariable.h index d49660b9d31..3787f030e08 100644 --- a/include/llvm/IR/GlobalVariable.h +++ b/include/llvm/IR/GlobalVariable.h @@ -38,8 +38,6 @@ class GlobalVariable : public GlobalObject, public ilist_node { void operator=(const GlobalVariable &) = delete; GlobalVariable(const GlobalVariable &) = delete; - void setParent(Module *parent); - bool isConstantGlobal : 1; // Is this a global constant? bool isExternallyInitializedConstant : 1; // Is this a global whose value // can change from its initial diff --git a/lib/IR/Function.cpp b/lib/IR/Function.cpp index e1b4d4af457..d5ecd92524d 100644 --- a/lib/IR/Function.cpp +++ b/lib/IR/Function.cpp @@ -330,10 +330,6 @@ bool Function::arg_empty() const { return getFunctionType()->getNumParams() == 0; } -void Function::setParent(Module *parent) { - Parent = parent; -} - // dropAllReferences() - This function causes all the subinstructions to "let // go" of all references that they are maintaining. This allows one to // 'delete' a whole class at a time, even though there may be circular diff --git a/lib/IR/Globals.cpp b/lib/IR/Globals.cpp index 1e4f0b4935f..58fc25a1d18 100644 --- a/lib/IR/Globals.cpp +++ b/lib/IR/Globals.cpp @@ -265,10 +265,6 @@ GlobalVariable::GlobalVariable(Module &M, Type *Ty, bool constant, M.getGlobalList().push_back(this); } -void GlobalVariable::setParent(Module *parent) { - Parent = parent; -} - void GlobalVariable::removeFromParent() { getParent()->getGlobalList().remove(getIterator()); } @@ -367,10 +363,6 @@ GlobalAlias *GlobalAlias::create(const Twine &Name, GlobalValue *Aliasee) { return create(Aliasee->getLinkage(), Name, Aliasee); } -void GlobalAlias::setParent(Module *parent) { - Parent = parent; -} - void GlobalAlias::removeFromParent() { getParent()->getAliasList().remove(getIterator()); } @@ -404,10 +396,6 @@ GlobalIFunc *GlobalIFunc::create(Type *Ty, unsigned AddressSpace, return new GlobalIFunc(Ty, AddressSpace, Link, Name, Resolver, ParentModule); } -void GlobalIFunc::setParent(Module *parent) { - Parent = parent; -} - void GlobalIFunc::removeFromParent() { getParent()->getIFuncList().remove(getIterator()); }