non-exiting diagnostic handler for LTO code generator
Rafael EspĂndola via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 9 05:33:46 PDT 2015
I think the included patch is correct. You should be able to write a
test for it with llvm-lto, no?
On 8 September 2015 at 23:01, Gao, Yunzhong
<yunzhong_gao at playstation.sony.com> wrote:
> Hi Rafael, Duncan, Peter,
>
> With r220732, when calling the Linker::Linker(Module *M) constructor, the
> default
>
> diagnostic handler is set to use LLVMContext::diagnose().
> Linker::Linker(Module *M)
>
> is the constructor called by LTOCodeGenerator::LTOCodeGenerator()
> constructor. This
>
> change is somewhat problematic for our LTO client, because we use a wrapper
>
> executable to relay communications with the LTO library.
> LLVMContext::diagnose()
>
> calls exit(1) on errors, which causes the wrapper executable to exit before
> the
>
> linker gets a chance to do any clean-up. I was wondering whether the
>
> LTOCodeGenerator is now expected to provide a non-exiting diagnostic handler
> (like
>
> below), and whether/how the other LTO clients are affected (or not). Any
> advice?
>
> Thanks,
>
> - Gao
>
>
>
> diff --git a/llvm/lib/LTO/LTOCodeGenerator.cpp
> b/llvm/lib/LTO/LTOCodeGenerator.c
>
> index c7a50bc..20ab4a2 100644
>
> --- a/llvm/lib/LTO/LTOCodeGenerator.cpp
>
> +++ b/llvm/lib/LTO/LTOCodeGenerator.cpp
>
> @@ -75,7 +75,12 @@ const char* LTOCodeGenerator::getVersionString() {
>
> }
>
>
>
> LTOCodeGenerator::LTOCodeGenerator()
>
> - : Context(getGlobalContext()), IRLinker(new Module("ld-temp.o",
> Context)) {
>
> + : Context(getGlobalContext()), IRLinker(new Module("ld-temp.o",
> Context),
>
> + [&](const DiagnosticInfo &DI) {
>
> + DiagnosticPrinterRawOStream DP(errs());
>
> + DI.print(DP);
>
> + errs() << "\n";
>
> + }) {
>
> initializeLTOPasses();
>
> }
More information about the llvm-commits
mailing list