[PM] Teach the module-to-function adaptor to not run function passes
authorChandler Carruth <chandlerc@gmail.com>
Sun, 1 Feb 2015 10:47:25 +0000 (10:47 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Sun, 1 Feb 2015 10:47:25 +0000 (10:47 +0000)
over declarations.

This is both quite unproductive and causes things to crash, for example
domtree would just assert.

I've added a declaration and a domtree run to the basic high-level tests
for the new pass manager.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@227724 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/IR/PassManager.h
test/Other/new-pass-manager.ll

index a57a5020b8d4c27a075740770cb54338c94f4b6f..56fd2a075e62cad4e8a2ef5cc9b1b8f661c3079e 100644 (file)
@@ -783,6 +783,9 @@ public:
 
     PreservedAnalyses PA = PreservedAnalyses::all();
     for (Function &F : M) {
+      if (F.isDeclaration())
+        continue;
+
       PreservedAnalyses PassPA = Pass.run(F, FAM);
 
       // We know that the function pass couldn't have invalidated any other
index a1bffe4d63d346e92bf3330c6e27dad0b6404b77..fb84e787a0abf4d18d326196e7fc3d4996675765 100644 (file)
 ; CHECK-TIRA-NOT: Running analysis: TargetIRAnalysis
 ; CHECK-TIRA: Finished pass manager
 
+; RUN: opt -disable-output -disable-verify -debug-pass-manager %s 2>&1 \
+; RUN:     -passes='require<domtree>' \
+; RUN:     | FileCheck %s --check-prefix=CHECK-DT
+; CHECK-DT: Starting pass manager
+; CHECK-DT: Running pass: RequireAnalysisPass
+; CHECK-DT: Running analysis: DominatorTreeAnalysis
+; CHECK-DT: Finished pass manager
+
 define void @foo() {
   ret void
 }
+
+declare void @bar()