[PATCH] D102295: [FunctionAttr][Attributor][nosync] Remove redundant check

Nicolai Hähnle via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 11 17:42:41 PDT 2021


nhaehnle created this revision.
nhaehnle added reviewers: reames, jdoerfert.
Herald added subscribers: okura, kuter, uenoku, hiraditya.
Herald added a reviewer: uenoku.
Herald added a reviewer: homerdin.
nhaehnle requested review of this revision.
Herald added a reviewer: sstefan1.
Herald added a reviewer: baziotis.
Herald added a subscriber: bbn.
Herald added a project: LLVM.

Memory intrinsics (memset and friends) carry the `nosync` attribute, and
the check via Instruction::isVolatile already checks for volatility, so
the explicit check for MemIntrinsics is redundant.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102295

Files:
  llvm/lib/Transforms/IPO/AttributorAttributes.cpp
  llvm/lib/Transforms/IPO/FunctionAttrs.cpp


Index: llvm/lib/Transforms/IPO/FunctionAttrs.cpp
===================================================================
--- llvm/lib/Transforms/IPO/FunctionAttrs.cpp
+++ llvm/lib/Transforms/IPO/FunctionAttrs.cpp
@@ -1516,13 +1516,6 @@
   if (CB->hasFnAttr(Attribute::NoSync))
     return false;
 
-  // Non volatile memset/memcpy/memmoves are nosync
-  // NOTE: Only intrinsics with volatile flags should be handled here.  All
-  // others should be marked in Intrinsics.td.
-  if (auto *MI = dyn_cast<MemIntrinsic>(&I))
-    if (!MI->isVolatile())
-      return false;
-
   // Speculatively assume in SCC.
   if (Function *Callee = CB->getCalledFunction())
     if (SCCNodes.contains(Callee))
Index: llvm/lib/Transforms/IPO/AttributorAttributes.cpp
===================================================================
--- llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -1281,9 +1281,6 @@
   /// atomic. In other words, if an atomic instruction does not have unordered
   /// or monotonic ordering
   static bool isNonRelaxedAtomic(Instruction *I);
-
-  /// Helper function specific for intrinsics which are potentially volatile
-  static bool isNoSyncIntrinsic(Instruction *I);
 };
 
 bool AANoSyncImpl::isNonRelaxedAtomic(Instruction *I) {
@@ -1319,15 +1316,6 @@
           Ordering != AtomicOrdering::Monotonic);
 }
 
-/// Return true if this intrinsic is nosync.  This is only used for intrinsics
-/// which would be nosync except that they have a volatile flag.  All other
-/// intrinsics are simply annotated with the nosync attribute in Intrinsics.td.
-bool AANoSyncImpl::isNoSyncIntrinsic(Instruction *I) {
-  if (auto *MI = dyn_cast<MemIntrinsic>(I))
-    return !MI->isVolatile();
-  return false;
-}
-
 ChangeStatus AANoSyncImpl::updateImpl(Attributor &A) {
 
   auto CheckRWInstForNoSync = [&](Instruction &I) {
@@ -1337,9 +1325,6 @@
       if (CB->hasFnAttr(Attribute::NoSync))
         return true;
 
-      if (isNoSyncIntrinsic(&I))
-        return true;
-
       const auto &NoSyncAA = A.getAAFor<AANoSync>(
           *this, IRPosition::callsite_function(*CB), DepClassTy::REQUIRED);
       return NoSyncAA.isAssumedNoSync();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102295.344617.patch
Type: text/x-patch
Size: 2198 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210512/78f6366f/attachment.bin>


More information about the llvm-commits mailing list