[PATCH] D15346: Fix the order of destructors in LibLTOCodeGenerator
Steven Wu via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 8 13:32:12 PST 2015
steven_wu created this revision.
steven_wu added reviewers: rafael, dexonsmith.
steven_wu added a subscriber: llvm-commits.
Herald added a subscriber: joker.eph.
The order of destructors in LTOCodeGenerator gets changed in r254696.
It is possible for LTOCodeGenerator to have a MergedModule created in
the OwnedContext, in which case the module must be destructed before
the context.
http://reviews.llvm.org/D15346
Files:
include/llvm/LTO/LTOCodeGenerator.h
tools/lto/lto.cpp
Index: tools/lto/lto.cpp
===================================================================
--- tools/lto/lto.cpp
+++ tools/lto/lto.cpp
@@ -124,6 +124,11 @@
: LTOCodeGenerator(*Context), OwnedContext(std::move(Context)) {
setDiagnosticHandler(handleLibLTODiagnostic, nullptr); }
+ // Reset the module first in case MergedModule is created in OwnedContext.
+ // Module must be destructed before its context gets destructed.
+ ~LibLTOCodeGenerator() {
+ resetMergedModule(); }
+
std::unique_ptr<MemoryBuffer> NativeObjectFile;
std::unique_ptr<LLVMContext> OwnedContext;
};
Index: include/llvm/LTO/LTOCodeGenerator.h
===================================================================
--- include/llvm/LTO/LTOCodeGenerator.h
+++ include/llvm/LTO/LTOCodeGenerator.h
@@ -148,6 +148,8 @@
LLVMContext &getContext() { return Context; }
+ void resetMergedModule() { MergedModule.reset(); }
+
private:
void initializeLTOPasses();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15346.42212.patch
Type: text/x-patch
Size: 962 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151208/9a2ae7ce/attachment.bin>
More information about the llvm-commits
mailing list