llvm.org GIT mirror llvm / 1208ef5
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255092 91177308-0d34-0410-b5e6-96231b3b80d8 Steven Wu 3 years ago
2 changed file(s) with 6 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
147147
148148 LLVMContext &getContext() { return Context; }
149149
150 void resetMergedModule() { MergedModule.reset(); }
151
150152 private:
151153 void initializeLTOPasses();
152154
123123 : LTOCodeGenerator(*Context), OwnedContext(std::move(Context)) {
124124 setDiagnosticHandler(handleLibLTODiagnostic, nullptr); }
125125
126 // Reset the module first in case MergedModule is created in OwnedContext.
127 // Module must be destructed before its context gets destructed.
128 ~LibLTOCodeGenerator() { resetMergedModule(); }
129
126130 std::unique_ptr NativeObjectFile;
127131 std::unique_ptr OwnedContext;
128132 };