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

Marcin Koƛcielnicki via cfe-commits cfe-commits at lists.llvm.org
Sun Jun 26 14:16:06 PDT 2016

koriakin created this revision.
koriakin added a reviewer: asl.
koriakin added a subscriber: cfe-commits.
koriakin set the repository for this revision to rL LLVM.

Currently, TargetLibraryInfoWrapperPass is inserted by PMBuilder.
However, some passes are inserted manually before the PMBuilder
ones - if any of them happens to use TargetLibraryInfoWrapperPass,
it'll get a default-constructed one, with an unknown target triple.
This happens to InstrProfiling in D21736, breaking it.




Index: lib/CodeGen/BackendUtil.cpp
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -329,7 +329,8 @@
   // Figure out TargetLibraryInfo.
   Triple TargetTriple(TheModule->getTargetTriple());
-  PMBuilder.LibraryInfo = createTLII(TargetTriple, CodeGenOpts);
+  std::unique_ptr<TargetLibraryInfoImpl> TLII(
+      createTLII(TargetTriple, CodeGenOpts));
   switch (Inlining) {
   case CodeGenOptions::NoInlining:
@@ -364,6 +365,7 @@
   PMBuilder.RerollLoops = CodeGenOpts.RerollLoops;
   legacy::PassManager *MPM = getPerModulePasses();
+  MPM->add(new TargetLibraryInfoWrapperPass(*TLII));
   // If we are performing a ThinLTO importing compile, invoke the LTO
   // pipeline and pass down the in-memory module summary index.
@@ -454,6 +456,7 @@
   // Set up the per-function pass manager.
   legacy::FunctionPassManager *FPM = getPerFunctionPasses();
+  FPM->add(new TargetLibraryInfoWrapperPass(*TLII));
   if (CodeGenOpts.VerifyModule)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21737.61914.patch
Type: text/x-patch
Size: 1073 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160626/c34e9a15/attachment-0001.bin>

More information about the cfe-commits mailing list