[GlobalsModRef] Add invalidate method
authorAlina Sbirlea <asbirlea@google.com>
Wed, 15 Jan 2020 22:10:37 +0000 (14:10 -0800)
committerAlina Sbirlea <asbirlea@google.com>
Fri, 17 Jan 2020 18:33:54 +0000 (10:33 -0800)
Summary: Add invalidate method to GlobalsAA.

Reviewers: tejohnson, chandlerc

Subscribers: hiraditya, sanjoy.google, llvm-commits

Tags: #llvm

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

llvm/include/llvm/Analysis/GlobalsModRef.h
llvm/lib/Analysis/GlobalsModRef.cpp

index fa5b16cf95eb7fe5555d6714279fdbb777b2fd2b..54cc0d4af62947ade09081da33f7003051a49748 100644 (file)
@@ -83,6 +83,9 @@ public:
   GlobalsAAResult(GlobalsAAResult &&Arg);
   ~GlobalsAAResult();
 
+  bool invalidate(Module &M, const PreservedAnalyses &PA,
+                  ModuleAnalysisManager::Invalidator &);
+
   static GlobalsAAResult
   analyzeModule(Module &M,
                 std::function<const TargetLibraryInfo &(Function &F)> GetTLI,
index 11005c403c1bf910c421ff41eacb13d08be75efc..a281626505a32ce1607cbf7bf9ecbc4780e2aed2 100644 (file)
@@ -810,6 +810,14 @@ bool GlobalsAAResult::isNonEscapingGlobalNoAlias(const GlobalValue *GV,
   return true;
 }
 
+bool GlobalsAAResult::invalidate(Module &, const PreservedAnalyses &PA,
+                                 ModuleAnalysisManager::Invalidator &) {
+  // Check whether the analysis has been explicitly invalidated. Otherwise, it's
+  // stateless and remains preserved.
+  auto PAC = PA.getChecker<GlobalsAA>();
+  return !PAC.preservedWhenStateless();
+}
+
 /// alias - If one of the pointers is to a global that we are tracking, and the
 /// other is some random pointer, we know there cannot be an alias, because the
 /// address of the global isn't taken.