Reapply r64300:
authorNick Lewycky <nicholas@mxc.ca>
Fri, 13 Feb 2009 07:15:53 +0000 (07:15 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Fri, 13 Feb 2009 07:15:53 +0000 (07:15 +0000)
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.

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

lib/Analysis/IPA/CallGraphSCCPass.cpp
test/Transforms/SimplifyLibCalls/2009-02-11-NotInitialized.ll

index b8343cf4ce8c39a9515aa9f2dfafc0c983ee904a..3880d0a10bb675c28ec64f76beec36c9f9c0b2ba 100644 (file)
@@ -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<CallGraphSCCPass *>(P)) 
+    if (CallGraphSCCPass *CGSP = dynamic_cast<CallGraphSCCPass *>(P)) {
       Changed |= CGSP->doInitialization(CG);
+    } else {
+      FPPassManager *FP = dynamic_cast<FPPassManager *>(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<CallGraphSCCPass *>(P)) 
+    if (CallGraphSCCPass *CGSP = dynamic_cast<CallGraphSCCPass *>(P)) {
       Changed |= CGSP->doFinalization(CG);
+    } else {
+      FPPassManager *FP = dynamic_cast<FPPassManager *>(P);
+      assert (FP && "Invalid CGPassManager member");
+      Changed |= FP->doFinalization(CG.getModule());
+    }
   }
   return Changed;
 }
index 41ab1d145fb87da7c09126f82226b9527d86404d..551a2bb6b9904022359cef61f6965749fdd8c834 100644 (file)
@@ -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: