[PATCH] D21737: [PATCH] [CodeGen] Insert TargetLibraryInfoWrapperPass before anything else.

Marcin Kościelnicki via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 22 12:13:35 PST 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL287688: [CodeGen] Insert TargetLibraryInfoWrapperPass before anything else. (authored by koriakin).

Changed prior to commit:
  https://reviews.llvm.org/D21737?vs=75550&id=78917#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D21737

Files:
  cfe/trunk/lib/CodeGen/BackendUtil.cpp


Index: cfe/trunk/lib/CodeGen/BackendUtil.cpp
===================================================================
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp
@@ -298,9 +298,13 @@
 
   PassManagerBuilderWrapper PMBuilder(CodeGenOpts, LangOpts);
 
-  // Figure out TargetLibraryInfo.
+  // Figure out TargetLibraryInfo.  This needs to be added to MPM and FPM
+  // manually (and not via PMBuilder), since some passes (eg. InstrProfiling)
+  // are inserted before PMBuilder ones - they'd get the default-constructed
+  // TLI with an unknown target otherwise.
   Triple TargetTriple(TheModule->getTargetTriple());
-  PMBuilder.LibraryInfo = createTLII(TargetTriple, CodeGenOpts);
+  std::unique_ptr<TargetLibraryInfoImpl> TLII(
+      createTLII(TargetTriple, CodeGenOpts));
 
   switch (Inlining) {
   case CodeGenOptions::NoInlining:
@@ -333,6 +337,8 @@
   PMBuilder.PrepareForLTO = CodeGenOpts.PrepareForLTO;
   PMBuilder.RerollLoops = CodeGenOpts.RerollLoops;
 
+  MPM.add(new TargetLibraryInfoWrapperPass(*TLII));
+
   // Add target-specific passes that need to run as early as possible.
   if (TM)
     PMBuilder.addExtension(
@@ -416,6 +422,7 @@
   }
 
   // Set up the per-function pass manager.
+  FPM.add(new TargetLibraryInfoWrapperPass(*TLII));
   if (CodeGenOpts.VerifyModule)
     FPM.add(createVerifierPass());
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21737.78917.patch
Type: text/x-patch
Size: 1365 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161122/cda0ba9b/attachment.bin>


More information about the cfe-commits mailing list