r287688 - [CodeGen] Insert TargetLibraryInfoWrapperPass before anything else.
Marcin Koscielnicki via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 22 12:03:36 PST 2016
Author: koriakin
Date: Tue Nov 22 14:03:35 2016
New Revision: 287688
URL: http://llvm.org/viewvc/llvm-project?rev=287688&view=rev
Log:
[CodeGen] Insert TargetLibraryInfoWrapperPass before anything else.
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.
Differential Revision: http://reviews.llvm.org/D21737
Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp
Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=287688&r1=287687&r2=287688&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Tue Nov 22 14:03:35 2016
@@ -298,9 +298,13 @@ void EmitAssemblyHelper::CreatePasses(le
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 @@ void EmitAssemblyHelper::CreatePasses(le
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 @@ void EmitAssemblyHelper::CreatePasses(le
}
// Set up the per-function pass manager.
+ FPM.add(new TargetLibraryInfoWrapperPass(*TLII));
if (CodeGenOpts.VerifyModule)
FPM.add(createVerifierPass());
More information about the cfe-commits
mailing list