[llvm] 4a579ab - [GlobalsModRef] Don't override getModRefBehavior() for CallBase

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 7 01:35:52 PDT 2022


Author: Nikita Popov
Date: 2022-07-07T10:35:44+02:00
New Revision: 4a579abd9f95bf9fda920759aced3874d04c5b9e

URL: https://github.com/llvm/llvm-project/commit/4a579abd9f95bf9fda920759aced3874d04c5b9e
DIFF: https://github.com/llvm/llvm-project/commit/4a579abd9f95bf9fda920759aced3874d04c5b9e.diff

LOG: [GlobalsModRef] Don't override getModRefBehavior() for CallBase

BasicAA will already call getModRefBehavior() on the Function of
the CallBase if there are no operand bundles. This happens through
getBestAAResults(), i.e. it is a recursive call that will query
other AA providers, not just the BasicAA implementation.

As such, there is no need to reimplement the same functionality
in GlobalsModRef, a combination of BasicAA and GlobalsModRef already
handles it. This does mean that this no longer works under
-disable-basic-aa, but that's a testing only option.

Added: 
    

Modified: 
    llvm/include/llvm/Analysis/GlobalsModRef.h
    llvm/lib/Analysis/GlobalsModRef.cpp
    llvm/test/Analysis/GlobalsModRef/purecse.ll

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Analysis/GlobalsModRef.h b/llvm/include/llvm/Analysis/GlobalsModRef.h
index 4d8ed10bb18ea..62095a1d6ad2c 100644
--- a/llvm/include/llvm/Analysis/GlobalsModRef.h
+++ b/llvm/include/llvm/Analysis/GlobalsModRef.h
@@ -102,16 +102,12 @@ class GlobalsAAResult : public AAResultBase<GlobalsAAResult> {
   ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc,
                            AAQueryInfo &AAQI);
 
+  using AAResultBase::getModRefBehavior;
   /// getModRefBehavior - Return the behavior of the specified function if
   /// called from the specified call site.  The call site may be null in which
   /// case the most generic behavior of this function should be returned.
   FunctionModRefBehavior getModRefBehavior(const Function *F);
 
-  /// getModRefBehavior - Return the behavior of the specified function if
-  /// called from the specified call site.  The call site may be null in which
-  /// case the most generic behavior of this function should be returned.
-  FunctionModRefBehavior getModRefBehavior(const CallBase *Call);
-
 private:
   FunctionInfo *getFunctionInfo(const Function *F);
 

diff  --git a/llvm/lib/Analysis/GlobalsModRef.cpp b/llvm/lib/Analysis/GlobalsModRef.cpp
index e82d2fae93562..db6eae0d962af 100644
--- a/llvm/lib/Analysis/GlobalsModRef.cpp
+++ b/llvm/lib/Analysis/GlobalsModRef.cpp
@@ -256,22 +256,6 @@ FunctionModRefBehavior GlobalsAAResult::getModRefBehavior(const Function *F) {
   return FunctionModRefBehavior(AAResultBase::getModRefBehavior(F) & Min);
 }
 
-FunctionModRefBehavior
-GlobalsAAResult::getModRefBehavior(const CallBase *Call) {
-  FunctionModRefBehavior Min = FMRB_UnknownModRefBehavior;
-
-  if (!Call->hasOperandBundles())
-    if (const Function *F = Call->getCalledFunction())
-      if (FunctionInfo *FI = getFunctionInfo(F)) {
-        if (!isModOrRefSet(FI->getModRefInfo()))
-          Min = FMRB_DoesNotAccessMemory;
-        else if (!isModSet(FI->getModRefInfo()))
-          Min = FMRB_OnlyReadsMemory;
-      }
-
-  return FunctionModRefBehavior(AAResultBase::getModRefBehavior(Call) & Min);
-}
-
 /// Returns the function info for the function, or null if we don't have
 /// anything useful to say about it.
 GlobalsAAResult::FunctionInfo *

diff  --git a/llvm/test/Analysis/GlobalsModRef/purecse.ll b/llvm/test/Analysis/GlobalsModRef/purecse.ll
index f98148d5b46d9..6b6cd77df1fa2 100644
--- a/llvm/test/Analysis/GlobalsModRef/purecse.ll
+++ b/llvm/test/Analysis/GlobalsModRef/purecse.ll
@@ -1,5 +1,5 @@
 ; Test that pure functions are cse'd away
-; RUN: opt < %s -disable-basic-aa -globals-aa -gvn -instcombine -S | FileCheck %s
+; RUN: opt < %s -globals-aa -gvn -instcombine -S | FileCheck %s
 
 define i32 @pure(i32 %X) {
         %Y = add i32 %X, 1              ; <i32> [#uses=1]


        


More information about the llvm-commits mailing list