Delay context construction to when/if it is needed in gold plugin (NFC)
authorTeresa Johnson <tejohnson@google.com>
Wed, 9 Dec 2015 19:49:40 +0000 (19:49 +0000)
committerTeresa Johnson <tejohnson@google.com>
Wed, 9 Dec 2015 19:49:40 +0000 (19:49 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255146 91177308-0d34-0410-b5e6-96231b3b80d8

tools/gold/gold-plugin.cpp

index 016dca5238229bcf4f739fcfbdeb1edd55c42103..08ff45d45ebb8724eadee641c432ed47897f27f4 100644 (file)
@@ -900,9 +900,6 @@ static ld_plugin_status allSymbolsReadHook(raw_fd_ostream *ApiFile) {
   if (Modules.empty())
     return LDPS_OK;
 
-  LLVMContext Context;
-  Context.setDiagnosticHandler(diagnosticHandlerForContext, nullptr, true);
-
   // If we are doing ThinLTO compilation, simply build the combined
   // function index/summary and emit it. We don't need to parse the modules
   // and link them in this case.
@@ -937,6 +934,9 @@ static ld_plugin_status allSymbolsReadHook(raw_fd_ostream *ApiFile) {
     exit(0);
   }
 
+  LLVMContext Context;
+  Context.setDiagnosticHandler(diagnosticHandlerForContext, nullptr, true);
+
   std::unique_ptr<Module> Combined(new Module("ld-temp.o", Context));
   Linker L(*Combined, diagnosticHandler);