[FuncAttrs] Always preserve FunctionAnalysisManagerCGSCCProxy
authorArthur Eubanks <aeubanks@google.com>
Tue, 20 Apr 2021 22:04:41 +0000 (15:04 -0700)
committerArthur Eubanks <aeubanks@google.com>
Tue, 20 Apr 2021 23:37:45 +0000 (16:37 -0700)
FunctionAnalysisManagerCGSCCProxy should not be preserved if any of its
keys may be invalid. Since we are not removing/adding functions in
FuncAttrs, it's fine to preserve it.

Reviewed By: asbirlea

Differential Revision: https://reviews.llvm.org/D100893

llvm/lib/Transforms/IPO/FunctionAttrs.cpp

index 64966bd..8f80a61 100644 (file)
@@ -1632,8 +1632,12 @@ PreservedAnalyses PostOrderFunctionAttrsPass::run(LazyCallGraph::SCC &C,
     Functions.push_back(&N.getFunction());
   }
 
-  if (deriveAttrsInPostOrder(Functions, AARGetter))
-    return PreservedAnalyses::none();
+  if (deriveAttrsInPostOrder(Functions, AARGetter)) {
+    // We have not changed the call graph or removed/added functions.
+    PreservedAnalyses PA;
+    PA.preserve<FunctionAnalysisManagerCGSCCProxy>();
+    return PA;
+  }
 
   return PreservedAnalyses::all();
 }