llvm.org GIT mirror llvm / 402fb0d
Merging r247461: ------------------------------------------------------------------------ r247461 | Yunzhong_Gao | 2015-09-11 16:01:53 -0400 (Fri, 11 Sep 2015) | 4 lines Add a non-exiting diagnostic handler for LTO. This is in order to give LTO clients a chance to do some clean-up before terminating the process. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_37@252774 91177308-0d34-0410-b5e6-96231b3b80d8 Tom Stellard 3 years ago
3 changed file(s) with 27 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
6262 #endif
6363 }
6464
65 static void handleLTODiagnostic(const DiagnosticInfo &DI) {
66 DiagnosticPrinterRawOStream DP(errs());
67 DI.print(DP);
68 errs() << "\n";
69 }
70
6571 LTOCodeGenerator::LTOCodeGenerator()
66 : Context(getGlobalContext()), IRLinker(new Module("ld-temp.o", Context)) {
72 : Context(getGlobalContext()), IRLinker(new Module("ld-temp.o", Context),
73 handleLTODiagnostic) {
6774 initializeLTOPasses();
6875 }
6976
7077 LTOCodeGenerator::LTOCodeGenerator(std::unique_ptr Context)
7178 : OwnedContext(std::move(Context)), Context(*OwnedContext),
72 IRLinker(new Module("ld-temp.o", *OwnedContext)) {
79 IRLinker(new Module("ld-temp.o", *OwnedContext), handleLTODiagnostic) {
7380 initializeLTOPasses();
7481 }
7582
0 ; LTO default diagnostic handler should be non-exiting.
1 ; This test verifies that after addModule() encounters an error, the diagnostic
2 ; handler does not call exit(1) and instead returns to the caller of addModule.
3
4 ; RUN: llvm-as <%s >%t1
5 ; RUN: llvm-as <%s >%t2
6 ; RUN: not llvm-lto -o /dev/null %t1 %t2 2>&1 | FileCheck %s
7
8 target triple = "x86_64-unknown-linux-gnu"
9
10 ; CHECK: Linking globals named 'goodboy': symbol multiply defined!
11 ; CHECK: llvm-lto{{.*}}: error adding file
12 @goodboy = global i32 3203383023, align 4 ; 0xbeefbeef
213213 if (SetMergedModule && i == BaseArg) {
214214 // Transfer ownership to the code generator.
215215 CodeGen.setModule(Module.release());
216 } else if (!CodeGen.addModule(Module.get()))
217 return 1;
216 } else if (!CodeGen.addModule(Module.get())) {
217 // Print a message here so that we know addModule() did not abort.
218 errs() << argv[0] << ": error adding file '" << InputFilenames[i] << "'\n";
219 return 1;
220 }
218221
219222 unsigned NumSyms = LTOMod->getSymbolCount();
220223 for (unsigned I = 0; I < NumSyms; ++I) {