[llvm-branch-commits] [llvm-branch] r252774 - Merging r247461:

Tom Stellard via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Nov 11 10:41:49 PST 2015


Author: tstellar
Date: Wed Nov 11 12:41:49 2015
New Revision: 252774

URL: http://llvm.org/viewvc/llvm-project?rev=252774&view=rev
Log:
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.

------------------------------------------------------------------------

Added:
    llvm/branches/release_37/test/LTO/X86/diagnostic-handler-noexit.ll
Modified:
    llvm/branches/release_37/lib/LTO/LTOCodeGenerator.cpp
    llvm/branches/release_37/tools/llvm-lto/llvm-lto.cpp

Modified: llvm/branches/release_37/lib/LTO/LTOCodeGenerator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_37/lib/LTO/LTOCodeGenerator.cpp?rev=252774&r1=252773&r2=252774&view=diff
==============================================================================
--- llvm/branches/release_37/lib/LTO/LTOCodeGenerator.cpp (original)
+++ llvm/branches/release_37/lib/LTO/LTOCodeGenerator.cpp Wed Nov 11 12:41:49 2015
@@ -63,14 +63,21 @@ const char* LTOCodeGenerator::getVersion
 #endif
 }
 
+static void handleLTODiagnostic(const DiagnosticInfo &DI) {
+  DiagnosticPrinterRawOStream DP(errs());
+  DI.print(DP);
+  errs() << "\n";
+}
+
 LTOCodeGenerator::LTOCodeGenerator()
-    : Context(getGlobalContext()), IRLinker(new Module("ld-temp.o", Context)) {
+    : Context(getGlobalContext()), IRLinker(new Module("ld-temp.o", Context),
+                                            handleLTODiagnostic) {
   initializeLTOPasses();
 }
 
 LTOCodeGenerator::LTOCodeGenerator(std::unique_ptr<LLVMContext> Context)
     : OwnedContext(std::move(Context)), Context(*OwnedContext),
-      IRLinker(new Module("ld-temp.o", *OwnedContext)) {
+      IRLinker(new Module("ld-temp.o", *OwnedContext), handleLTODiagnostic) {
   initializeLTOPasses();
 }
 

Added: llvm/branches/release_37/test/LTO/X86/diagnostic-handler-noexit.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_37/test/LTO/X86/diagnostic-handler-noexit.ll?rev=252774&view=auto
==============================================================================
--- llvm/branches/release_37/test/LTO/X86/diagnostic-handler-noexit.ll (added)
+++ llvm/branches/release_37/test/LTO/X86/diagnostic-handler-noexit.ll Wed Nov 11 12:41:49 2015
@@ -0,0 +1,13 @@
+; LTO default diagnostic handler should be non-exiting.
+; This test verifies that after addModule() encounters an error, the diagnostic
+; handler does not call exit(1) and instead returns to the caller of addModule.
+
+; RUN: llvm-as <%s >%t1
+; RUN: llvm-as <%s >%t2
+; RUN: not llvm-lto -o /dev/null %t1 %t2 2>&1 | FileCheck %s
+
+target triple = "x86_64-unknown-linux-gnu"
+
+; CHECK: Linking globals named 'goodboy': symbol multiply defined!
+; CHECK: llvm-lto{{.*}}: error adding file
+ at goodboy = global i32 3203383023, align 4    ; 0xbeefbeef

Modified: llvm/branches/release_37/tools/llvm-lto/llvm-lto.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_37/tools/llvm-lto/llvm-lto.cpp?rev=252774&r1=252773&r2=252774&view=diff
==============================================================================
--- llvm/branches/release_37/tools/llvm-lto/llvm-lto.cpp (original)
+++ llvm/branches/release_37/tools/llvm-lto/llvm-lto.cpp Wed Nov 11 12:41:49 2015
@@ -214,8 +214,11 @@ int main(int argc, char **argv) {
     if (SetMergedModule && i == BaseArg) {
       // Transfer ownership to the code generator.
       CodeGen.setModule(Module.release());
-    } else if (!CodeGen.addModule(Module.get()))
+    } else if (!CodeGen.addModule(Module.get())) {
+      // Print a message here so that we know addModule() did not abort.
+      errs() << argv[0] << ": error adding file '" << InputFilenames[i] << "'\n";
       return 1;
+    }
 
     unsigned NumSyms = LTOMod->getSymbolCount();
     for (unsigned I = 0; I < NumSyms; ++I) {




More information about the llvm-branch-commits mailing list