From: Justin Lebar Date: Wed, 27 Apr 2016 19:12:56 +0000 (+0000) Subject: Call TargetMachine::addEarlyAsPossiblePasses from BackendUtil. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=69ffd3e5e14eb3a205ce32d9b0bec4d94a4d6928;p=clang Call TargetMachine::addEarlyAsPossiblePasses from BackendUtil. Summary: As of D18614, TargetMachine exposes a hook to add a set of passes that should be run as early as possible. Invoke this hook from clang when setting up the pass manager. Reviewers: chandlerc Subscribers: rnk, cfe-commits, tra Differential Revision: http://reviews.llvm.org/D18617 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@267764 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/BackendUtil.cpp b/lib/CodeGen/BackendUtil.cpp index 148c0a09f9..6958679de5 100644 --- a/lib/CodeGen/BackendUtil.cpp +++ b/lib/CodeGen/BackendUtil.cpp @@ -354,6 +354,14 @@ void EmitAssemblyHelper::CreatePasses(ModuleSummaryIndex *ModuleSummary) { return; } + // Add target-specific passes that need to run as early as possible. + if (TM) + PMBuilder.addExtension( + PassManagerBuilder::EP_EarlyAsPossible, + [&](const PassManagerBuilder &, legacy::PassManagerBase &PM) { + TM->addEarlyAsPossiblePasses(PM); + }); + PMBuilder.addExtension(PassManagerBuilder::EP_EarlyAsPossible, addAddDiscriminatorsPass);