[llvm] 259390d - [LCG] Don't skip invalidation of LazyCallGraph if CFG analyses are preserved

Arthur Eubanks via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 11 13:34:42 PDT 2021


Author: Arthur Eubanks
Date: 2021-10-11T13:30:47-07:00
New Revision: 259390de9af659e2432c5b2af041ec6576c1b26d

URL: https://github.com/llvm/llvm-project/commit/259390de9af659e2432c5b2af041ec6576c1b26d
DIFF: https://github.com/llvm/llvm-project/commit/259390de9af659e2432c5b2af041ec6576c1b26d.diff

LOG: [LCG] Don't skip invalidation of LazyCallGraph if CFG analyses are preserved

The CFG being changed and the overall call graph are not related, we can introduce/remove calls without changing the CFG.

Resolves one of the issues in PR51946.

Reviewed By: asbirlea

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

Added: 
    llvm/test/Analysis/LazyCallGraph/invalidate.ll

Modified: 
    llvm/lib/Analysis/LazyCallGraph.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/LazyCallGraph.cpp b/llvm/lib/Analysis/LazyCallGraph.cpp
index 8f87552fca1fe..8170c32a2d157 100644
--- a/llvm/lib/Analysis/LazyCallGraph.cpp
+++ b/llvm/lib/Analysis/LazyCallGraph.cpp
@@ -220,8 +220,7 @@ bool LazyCallGraph::invalidate(Module &, const PreservedAnalyses &PA,
   // Check whether the analysis, all analyses on functions, or the function's
   // CFG have been preserved.
   auto PAC = PA.getChecker<llvm::LazyCallGraphAnalysis>();
-  return !(PAC.preserved() || PAC.preservedSet<AllAnalysesOn<Module>>() ||
-           PAC.preservedSet<CFGAnalyses>());
+  return !(PAC.preserved() || PAC.preservedSet<AllAnalysesOn<Module>>());
 }
 
 LazyCallGraph &LazyCallGraph::operator=(LazyCallGraph &&G) {

diff  --git a/llvm/test/Analysis/LazyCallGraph/invalidate.ll b/llvm/test/Analysis/LazyCallGraph/invalidate.ll
new file mode 100644
index 0000000000000..b2f421086d3cf
--- /dev/null
+++ b/llvm/test/Analysis/LazyCallGraph/invalidate.ll
@@ -0,0 +1,10 @@
+; Make sure we invalidate lcg even when preserving domtree
+; RUN: opt -passes='require<lcg>,function(instcombine)' -debug-pass-manager -disable-output < %s 2>&1 | FileCheck %s
+
+; CHECK: Invalidating {{.*}} LazyCallGraphAnalysis
+
+define void @f() {
+lbl:
+  %a = add i32 1, 2
+  unreachable
+}


        


More information about the llvm-commits mailing list