From 259390de9af659e2432c5b2af041ec6576c1b26d Mon Sep 17 00:00:00 2001 From: Arthur Eubanks Date: Wed, 6 Oct 2021 14:32:08 -0700 Subject: [PATCH] [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 --- llvm/lib/Analysis/LazyCallGraph.cpp | 3 +-- llvm/test/Analysis/LazyCallGraph/invalidate.ll | 10 ++++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 llvm/test/Analysis/LazyCallGraph/invalidate.ll diff --git a/llvm/lib/Analysis/LazyCallGraph.cpp b/llvm/lib/Analysis/LazyCallGraph.cpp index 8f87552fca1f..8170c32a2d15 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(); - return !(PAC.preserved() || PAC.preservedSet>() || - PAC.preservedSet()); + return !(PAC.preserved() || PAC.preservedSet>()); } 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 000000000000..b2f421086d3c --- /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,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 +}