[llvm] 8e596f7 - [Attributor] Cleanup intrinsic handling in nosync inference [mostly NFC]
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 1 11:50:08 PDT 2021
Author: Philip Reames
Date: 2021-04-01T11:49:59-07:00
New Revision: 8e596f7e27b47a4bf7c0890214a89b5e60a01b77
URL: https://github.com/llvm/llvm-project/commit/8e596f7e27b47a4bf7c0890214a89b5e60a01b77
DIFF: https://github.com/llvm/llvm-project/commit/8e596f7e27b47a4bf7c0890214a89b5e60a01b77.diff
LOG: [Attributor] Cleanup intrinsic handling in nosync inference [mostly NFC]
Mostly stylistic adjustment, but the old code didn't handle the memcpy.inline intrinsic. By using the matcher class, we now do.
Added:
Modified:
llvm/lib/Transforms/IPO/AttributorAttributes.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
index a82970fafb1d..e8d69e024168 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -1282,8 +1282,7 @@ struct AANoSyncImpl : AANoSync {
/// or monotonic ordering
static bool isNonRelaxedAtomic(Instruction *I);
- /// Helper function uset to check if intrinsic is volatile (memcpy, memmove,
- /// memset).
+ /// Helper function specific for intrinsics which are potentially volatile
static bool isNoSyncIntrinsic(Instruction *I);
};
@@ -1334,21 +1333,12 @@ bool AANoSyncImpl::isNonRelaxedAtomic(Instruction *I) {
return true;
}
-/// Checks if an intrinsic is nosync. Currently only checks mem* intrinsics.
-/// FIXME: We should ipmrove the handling of intrinsics.
+/// 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 *II = dyn_cast<IntrinsicInst>(I)) {
- switch (II->getIntrinsicID()) {
- case Intrinsic::memset:
- case Intrinsic::memmove:
- case Intrinsic::memcpy:
- if (!cast<MemIntrinsic>(II)->isVolatile())
- return true;
- return false;
- default:
- return false;
- }
- }
+ if (auto *MI = dyn_cast<MemIntrinsic>(I))
+ return !MI->isVolatile();
return false;
}
@@ -1356,15 +1346,14 @@ ChangeStatus AANoSyncImpl::updateImpl(Attributor &A) {
auto CheckRWInstForNoSync = [&](Instruction &I) {
/// We are looking for volatile instructions or Non-Relaxed atomics.
- /// FIXME: We should improve the handling of intrinsics.
-
- if (isa<IntrinsicInst>(&I) && isNoSyncIntrinsic(&I))
- return true;
if (const auto *CB = dyn_cast<CallBase>(&I)) {
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();
More information about the llvm-commits
mailing list