diff options
author | Marcin Koscielnicki <koriakin@0x04.net> | 2016-11-22 20:03:35 +0000 |
---|---|---|
committer | Marcin Koscielnicki <koriakin@0x04.net> | 2016-11-22 20:03:35 +0000 |
commit | 9a063e7c02328968b69ee40981175e52f50bde79 (patch) | |
tree | ee0ee9d1dc29bc871f4ce5b89d403809fa8ae34f /clang/lib/CodeGen | |
parent | 3028189ee393a8cb8a6e5c96cb5e9c580b338759 (diff) | |
download | bcm5719-llvm-9a063e7c02328968b69ee40981175e52f50bde79.tar.gz bcm5719-llvm-9a063e7c02328968b69ee40981175e52f50bde79.zip |
[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
llvm-svn: 287688
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r-- | clang/lib/CodeGen/BackendUtil.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index ec790e411e0..87937c057be 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -298,9 +298,13 @@ void EmitAssemblyHelper::CreatePasses(legacy::PassManager &MPM, 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(legacy::PassManager &MPM, 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(legacy::PassManager &MPM, } // Set up the per-function pass manager. + FPM.add(new TargetLibraryInfoWrapperPass(*TLII)); if (CodeGenOpts.VerifyModule) FPM.add(createVerifierPass()); |