[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
This commit is contained in:
Arthur Eubanks 2021-10-06 14:32:08 -07:00
parent 59441c7329
commit 259390de9a
2 changed files with 11 additions and 2 deletions

View File

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

View File

@ -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
}