non-exiting diagnostic handler for LTO code generator
Peter Collingbourne via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 9 17:11:21 PDT 2015
This also seems correct to me.
A minor point: if we do this, we should be consistent between the constructor
that takes a context and the constructor that uses the global context.
This also won't apply cleanly after r245891, but the fix is trivial.
Other than that, LGTM with the caveats others have mentioned.
Peter
On Wed, Sep 09, 2015 at 03:01:26AM +0000, Gao, Yunzhong 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();
> }
--
Peter
More information about the llvm-commits
mailing list