[PATCH] D72818: [GlobalsModRef] Add invalidate method

Alina Sbirlea via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 16 09:54:06 PST 2020


asbirlea updated this revision to Diff 238534.
asbirlea added a comment.

Add comment explaining invalidate rational.
GlobalsAA is stateless and is preserved,  unless it's explicitly invalidated.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72818/new/

https://reviews.llvm.org/D72818

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


Index: llvm/lib/Analysis/GlobalsModRef.cpp
===================================================================
--- llvm/lib/Analysis/GlobalsModRef.cpp
+++ llvm/lib/Analysis/GlobalsModRef.cpp
@@ -810,6 +810,14 @@
   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.
Index: llvm/include/llvm/Analysis/GlobalsModRef.h
===================================================================
--- llvm/include/llvm/Analysis/GlobalsModRef.h
+++ llvm/include/llvm/Analysis/GlobalsModRef.h
@@ -83,6 +83,9 @@
   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,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72818.238534.patch
Type: text/x-patch
Size: 1341 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200116/e5256236/attachment.bin>


More information about the llvm-commits mailing list