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

llvm-svn: 267764

clang/lib/CodeGen/BackendUtil.cpp

index 148c0a0..6958679 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);