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. Repository: rL LLVM http://reviews.llvm.org/D21737 Files: lib/CodeGen/BackendUtil.cpp 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) FPM->add(createVerifierPass());
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) FPM->add(createVerifierPass());
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits