[llvm] 93a636d - [IR] Lift attribute handling for assume bundles into CallBase

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 25 13:15:48 PDT 2021


Author: Nikita Popov
Date: 2021-03-25T21:15:39+01:00
New Revision: 93a636d9f6385543a1c77506880a08e10c50792f

URL: https://github.com/llvm/llvm-project/commit/93a636d9f6385543a1c77506880a08e10c50792f
DIFF: https://github.com/llvm/llvm-project/commit/93a636d9f6385543a1c77506880a08e10c50792f.diff

LOG: [IR] Lift attribute handling for assume bundles into CallBase

Rather than special-casing assume in BasicAA getModRefBehavior(),
do this one level higher, in the attribute handling of CallBase.

For assumes with operand bundles, the inaccessiblememonly attribute
applies regardless of operand bundles.

Added: 
    

Modified: 
    llvm/include/llvm/IR/InstrTypes.h
    llvm/lib/Analysis/BasicAliasAnalysis.cpp
    llvm/lib/IR/Instructions.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/IR/InstrTypes.h b/llvm/include/llvm/IR/InstrTypes.h
index 5c1d2bdd296e..86e86c454d8f 100644
--- a/llvm/include/llvm/IR/InstrTypes.h
+++ b/llvm/include/llvm/IR/InstrTypes.h
@@ -2013,12 +2013,7 @@ class CallBase : public Instruction {
 
   /// Return true if this operand bundle user has operand bundles that
   /// may read from the heap.
-  bool hasReadingOperandBundles() const {
-    // Implementation note: this is a conservative implementation of operand
-    // bundle semantics, where *any* operand bundle forces a callsite to be at
-    // least readonly.
-    return hasOperandBundles();
-  }
+  bool hasReadingOperandBundles() const;
 
   /// Return true if this operand bundle user has operand bundles that
   /// may write to the heap.

diff  --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
index 65117d82a81c..acf7bef3aeb0 100644
--- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
@@ -683,11 +683,6 @@ FunctionModRefBehavior BasicAAResult::getModRefBehavior(const CallBase *Call) {
     // Can't do better than this.
     return FMRB_DoesNotAccessMemory;
 
-  // The assume intrinsic can have operand bundles, but still only accesses
-  // inaccessible memory in that case (to maintain control dependencies).
-  if (isIntrinsicCall(Call, Intrinsic::assume))
-    return FMRB_OnlyAccessesInaccessibleMem;
-
   FunctionModRefBehavior Min = FMRB_UnknownModRefBehavior;
 
   // If the callsite knows it only reads memory, don't return worse

diff  --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index 6666d74ecabb..15567e94cb2e 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/lib/IR/Instructions.cpp
@@ -466,6 +466,13 @@ CallBase *CallBase::removeOperandBundle(CallBase *CB, uint32_t ID,
   return CreateNew ? Create(CB, Bundles, InsertPt) : CB;
 }
 
+bool CallBase::hasReadingOperandBundles() const {
+  // Implementation note: this is a conservative implementation of operand
+  // bundle semantics, where *any* non-assume operand bundle forces a callsite
+  // to be at least readonly.
+  return hasOperandBundles() && getIntrinsicID() != Intrinsic::assume;
+}
+
 //===----------------------------------------------------------------------===//
 //                        CallInst Implementation
 //===----------------------------------------------------------------------===//


        


More information about the llvm-commits mailing list