[llvm] 46ed933 - [IR] Remove some unnecessary cleanup in Module's dtor, and use a unique_ptr to simplify some
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 17 17:34:07 PST 2020
Author: David Blaikie
Date: 2020-01-17T17:30:24-08:00
New Revision: 46ed93315fceec4c8c3cd3defada501a55eb96e2
URL: https://github.com/llvm/llvm-project/commit/46ed93315fceec4c8c3cd3defada501a55eb96e2
DIFF: https://github.com/llvm/llvm-project/commit/46ed93315fceec4c8c3cd3defada501a55eb96e2.diff
LOG: [IR] Remove some unnecessary cleanup in Module's dtor, and use a unique_ptr to simplify some
Follow on from D72812, based on Mehdi Amini's feedback.
Added:
Modified:
llvm/include/llvm/IR/Module.h
llvm/lib/IR/Module.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/Module.h b/llvm/include/llvm/IR/Module.h
index 46485847bdca..bdc1ea932561 100644
--- a/llvm/include/llvm/IR/Module.h
+++ b/llvm/include/llvm/IR/Module.h
@@ -177,7 +177,7 @@ class Module {
IFuncListType IFuncList; ///< The IFuncs in the module
NamedMDListType NamedMDList; ///< The named metadata in the module
std::string GlobalScopeAsm; ///< Inline Asm at global scope.
- ValueSymbolTable *ValSymTab; ///< Symbol table for values
+ std::unique_ptr<ValueSymbolTable> ValSymTab; ///< Symbol table for values
ComdatSymTabType ComdatSymTab; ///< Symbol table for COMDATs
std::unique_ptr<MemoryBuffer>
OwnedMemoryBuffer; ///< Memory buffer directly owned by this
diff --git a/llvm/lib/IR/Module.cpp b/llvm/lib/IR/Module.cpp
index 8ddbffcde868..eb23b125a65a 100644
--- a/llvm/lib/IR/Module.cpp
+++ b/llvm/lib/IR/Module.cpp
@@ -71,8 +71,8 @@ template class llvm::SymbolTableListTraits<GlobalIFunc>;
//
Module::Module(StringRef MID, LLVMContext &C)
- : Context(C), Materializer(), ModuleID(MID), SourceFileName(MID), DL("") {
- ValSymTab = new ValueSymbolTable();
+ : Context(C), ValSymTab(std::make_unique<ValueSymbolTable>()),
+ Materializer(), ModuleID(MID), SourceFileName(MID), DL("") {
Context.addModule(this);
}
@@ -83,9 +83,6 @@ Module::~Module() {
FunctionList.clear();
AliasList.clear();
IFuncList.clear();
- NamedMDList.clear();
- NamedMDSymTab.clear();
- delete ValSymTab;
}
std::unique_ptr<RandomNumberGenerator> Module::createRNG(const Pass* P) const {
More information about the llvm-commits
mailing list