From 260e80bd906292183c83f866ba5e1b3be7af25a4 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Fri, 13 Feb 2009 07:15:53 +0000 Subject: [PATCH] Reapply r64300: Make sure the SCC pass manager initializes any contained function pass managers. Without this, simplify-libcalls would add nocapture attributes when run on its own, but not when run as part of -std-compile-opts or similar. llvm-svn: 64443 --- lib/Analysis/IPA/CallGraphSCCPass.cpp | 14 ++++++++++++-- .../SimplifyLibCalls/2009-02-11-NotInitialized.ll | 4 ++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/Analysis/IPA/CallGraphSCCPass.cpp b/lib/Analysis/IPA/CallGraphSCCPass.cpp index b8343cf4ce8..3880d0a10bb 100644 --- a/lib/Analysis/IPA/CallGraphSCCPass.cpp +++ b/lib/Analysis/IPA/CallGraphSCCPass.cpp @@ -135,8 +135,13 @@ bool CGPassManager::doInitialization(CallGraph &CG) { bool Changed = false; for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) { Pass *P = getContainedPass(Index); - if (CallGraphSCCPass *CGSP = dynamic_cast(P)) + if (CallGraphSCCPass *CGSP = dynamic_cast(P)) { Changed |= CGSP->doInitialization(CG); + } else { + FPPassManager *FP = dynamic_cast(P); + assert (FP && "Invalid CGPassManager member"); + Changed |= FP->doInitialization(CG.getModule()); + } } return Changed; } @@ -146,8 +151,13 @@ bool CGPassManager::doFinalization(CallGraph &CG) { bool Changed = false; for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) { Pass *P = getContainedPass(Index); - if (CallGraphSCCPass *CGSP = dynamic_cast(P)) + if (CallGraphSCCPass *CGSP = dynamic_cast(P)) { Changed |= CGSP->doFinalization(CG); + } else { + FPPassManager *FP = dynamic_cast(P); + assert (FP && "Invalid CGPassManager member"); + Changed |= FP->doFinalization(CG.getModule()); + } } return Changed; } diff --git a/test/Transforms/SimplifyLibCalls/2009-02-11-NotInitialized.ll b/test/Transforms/SimplifyLibCalls/2009-02-11-NotInitialized.ll index 41ab1d145fb..551a2bb6b99 100644 --- a/test/Transforms/SimplifyLibCalls/2009-02-11-NotInitialized.ll +++ b/test/Transforms/SimplifyLibCalls/2009-02-11-NotInitialized.ll @@ -1,7 +1,7 @@ -; RUN: llvm-as < %s | opt -std-compile-opts | llvm-dis | grep nocapture | count 2 +; RUN: llvm-as < %s | opt -inline -simplify-libcalls -functionattrs | \ +; RUN: llvm-dis | grep nocapture | count 2 ; Check that nocapture attributes are added when run after an SCC pass. ; PR3520 -; XFAIL: * define i32 @use(i8* %x) nounwind readonly { entry: