[PATCH] D15346: Fix the order of destructors in LibLTOCodeGenerator
Steven Wu via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 8 19:48:33 PST 2015
Thanks Rafael for reviewing the change! I couldn't find a clean way to link against libLTO for testing in llvm repo. This might need to be fixed. I have some internal ld64 test case covering this for now.
Steven
> On Dec 8, 2015, at 7:41 PM, Steven Wu <stevenwu at apple.com> wrote:
>
> This revision was automatically updated to reflect the committed changes.
> Closed by commit rL255092: Fix the order of destructors in LibLTOCodeGenerator (authored by steven_wu).
>
> Changed prior to commit:
> http://reviews.llvm.org/D15346?vs=42212&id=42263#toc
>
> Repository:
> rL LLVM
>
> http://reviews.llvm.org/D15346
>
> Files:
> llvm/trunk/include/llvm/LTO/LTOCodeGenerator.h
> llvm/trunk/tools/lto/lto.cpp
>
> Index: llvm/trunk/tools/lto/lto.cpp
> ===================================================================
> --- llvm/trunk/tools/lto/lto.cpp
> +++ llvm/trunk/tools/lto/lto.cpp
> @@ -124,6 +124,10 @@
> : 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: llvm/trunk/include/llvm/LTO/LTOCodeGenerator.h
> ===================================================================
> --- llvm/trunk/include/llvm/LTO/LTOCodeGenerator.h
> +++ llvm/trunk/include/llvm/LTO/LTOCodeGenerator.h
> @@ -148,6 +148,8 @@
>
> LLVMContext &getContext() { return Context; }
>
> + void resetMergedModule() { MergedModule.reset(); }
> +
> private:
> void initializeLTOPasses();
>
>
>
> <D15346.42263.patch>
More information about the llvm-commits
mailing list