summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Wu <stevenwu@apple.com>2015-12-09 03:37:51 +0000
committerSteven Wu <stevenwu@apple.com>2015-12-09 03:37:51 +0000
commitb5104b58841ad7701412f52db04aeccfe91308b1 (patch)
tree8fc3ba765d4e0540837023a6e106f40b7dfc7876
parent13e6f311afbb8a3cc17754d4b204cba2fb894241 (diff)
downloadbcm5719-llvm-b5104b58841ad7701412f52db04aeccfe91308b1.tar.gz
bcm5719-llvm-b5104b58841ad7701412f52db04aeccfe91308b1.zip
Fix the order of destructors in LibLTOCodeGenerator
Summary: 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. Reviewers: rafael, dexonsmith Subscribers: llvm-commits, joker.eph Differential Revision: http://reviews.llvm.org/D15346 llvm-svn: 255092
-rw-r--r--llvm/include/llvm/LTO/LTOCodeGenerator.h2
-rw-r--r--llvm/tools/lto/lto.cpp4
2 files changed, 6 insertions, 0 deletions
diff --git a/llvm/include/llvm/LTO/LTOCodeGenerator.h b/llvm/include/llvm/LTO/LTOCodeGenerator.h
index 876defbdcd3..8a79e6044f5 100644
--- a/llvm/include/llvm/LTO/LTOCodeGenerator.h
+++ b/llvm/include/llvm/LTO/LTOCodeGenerator.h
@@ -148,6 +148,8 @@ struct LTOCodeGenerator {
LLVMContext &getContext() { return Context; }
+ void resetMergedModule() { MergedModule.reset(); }
+
private:
void initializeLTOPasses();
diff --git a/llvm/tools/lto/lto.cpp b/llvm/tools/lto/lto.cpp
index d13de57e830..d8f99c050a3 100644
--- a/llvm/tools/lto/lto.cpp
+++ b/llvm/tools/lto/lto.cpp
@@ -124,6 +124,10 @@ struct LibLTOCodeGenerator : LTOCodeGenerator {
: 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;
};
OpenPOWER on IntegriCloud