diff --git a/include/llvm/IR/PassManager.h b/include/llvm/IR/PassManager.h index a57a5020b8d..56fd2a075e6 100644 --- a/include/llvm/IR/PassManager.h +++ b/include/llvm/IR/PassManager.h @@ -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 diff --git a/test/Other/new-pass-manager.ll b/test/Other/new-pass-manager.ll index a1bffe4d63d..fb84e787a0a 100644 --- a/test/Other/new-pass-manager.ll +++ b/test/Other/new-pass-manager.ll @@ -290,6 +290,16 @@ ; 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' \ +; 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()