]> granicus.if.org Git - clang/commitdiff
Call TargetMachine::addEarlyAsPossiblePasses from BackendUtil.
authorJustin Lebar <jlebar@google.com>
Wed, 27 Apr 2016 19:12:56 +0000 (19:12 +0000)
committerJustin Lebar <jlebar@google.com>
Wed, 27 Apr 2016 19:12:56 +0000 (19:12 +0000)
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

lib/CodeGen/BackendUtil.cpp

index 148c0a09f9eb98769f922b87d5ece488b8b1688d..6958679de5d69dc5adec101fa602de5991855339 100644 (file)
@@ -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);