[PATCH] D60162: [ThinLTO] Support TargetLibraryInfoImpl in the backend

Teresa Johnson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 2 16:08:51 PDT 2019


tejohnson created this revision.
tejohnson added a reviewer: pcc.
Herald added subscribers: dang, dexonsmith, steven_wu, inglorion, mehdi_amini.
Herald added a project: LLVM.
tejohnson added a child revision: D60163: [ThinLTO] Handle -fno-builtin* options for distributed backends.

This prepares for a clang change to pass down a TargetLibraryInfoImpl to
the ThinLTO backend to support handling -fno-builtin* options passed to
distributed backend clang invocations.

Note we cannot easily add this support for in-process (linker spawned)
ThinLTO backend threads since it will require additional work to figure
out how to pass down the -fno-builtin* options to the linker via the
clang driver. That can be added in the future if needed, and will then
use this same handling.


Repository:
  rL LLVM

https://reviews.llvm.org/D60162

Files:
  include/llvm/LTO/Config.h
  lib/LTO/LTOBackend.cpp


Index: lib/LTO/LTOBackend.cpp
===================================================================
--- lib/LTO/LTOBackend.cpp
+++ lib/LTO/LTOBackend.cpp
@@ -179,6 +179,11 @@
   // Register the AA manager first so that our version is the one used.
   FAM.registerPass([&] { return std::move(AA); });
 
+  if (Conf.TLII) {
+    FAM.registerPass([&] { return TargetLibraryAnalysis(*Conf.TLII); });
+    MAM.registerPass([&] { return TargetLibraryAnalysis(*Conf.TLII); });
+  }
+
   // Register all the basic analyses with the managers.
   PB.registerModuleAnalyses(MAM);
   PB.registerCGSCCAnalyses(CGAM);
@@ -268,7 +273,11 @@
   passes.add(createTargetTransformInfoWrapperPass(TM->getTargetIRAnalysis()));
 
   PassManagerBuilder PMB;
-  PMB.LibraryInfo = new TargetLibraryInfoImpl(Triple(TM->getTargetTriple()));
+  if (Conf.TLII)
+    // The PassManagerBuilder destructor deletes the LibraryInfo.
+    PMB.LibraryInfo = Conf.TLII.release();
+  else
+    PMB.LibraryInfo = new TargetLibraryInfoImpl(Triple(TM->getTargetTriple()));
   PMB.Inliner = createFunctionInliningPass();
   PMB.ExportSummary = ExportSummary;
   PMB.ImportSummary = ImportSummary;
Index: include/llvm/LTO/Config.h
===================================================================
--- include/llvm/LTO/Config.h
+++ include/llvm/LTO/Config.h
@@ -14,6 +14,7 @@
 #ifndef LLVM_LTO_CONFIG_H
 #define LLVM_LTO_CONFIG_H
 
+#include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/IR/DiagnosticInfo.h"
 #include "llvm/Support/CodeGen.h"
 #include "llvm/Target/TargetMachine.h"
@@ -44,6 +45,7 @@
   TargetMachine::CodeGenFileType CGFileType = TargetMachine::CGFT_ObjectFile;
   unsigned OptLevel = 2;
   bool DisableVerify = false;
+  std::unique_ptr<TargetLibraryInfoImpl> TLII;
 
   /// Use the new pass manager
   bool UseNewPM = false;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60162.193385.patch
Type: text/x-patch
Size: 1807 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190402/a8902542/attachment.bin>


More information about the llvm-commits mailing list