Skip to content

Commit c272728

Browse files
committed
[Attributor] Port AANoSync to the isImpliedByIR interface
1 parent c33fa5a commit c272728

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

llvm/lib/Transforms/IPO/Attributor.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,10 @@ bool AA::isNoSyncInst(Attributor &A, const Instruction &I,
204204
if (AANoSync::isNoSyncIntrinsic(&I))
205205
return true;
206206

207-
const auto *NoSyncAA = A.getAAFor<AANoSync>(
208-
QueryingAA, IRPosition::callsite_function(*CB), DepClassTy::OPTIONAL);
209-
return NoSyncAA && NoSyncAA->isAssumedNoSync();
207+
bool IsKnownNoSync;
208+
return AA::hasAssumedIRAttr<Attribute::NoSync>(
209+
A, &QueryingAA, IRPosition::callsite_function(*CB),
210+
DepClassTy::OPTIONAL, IsKnownNoSync);
210211
}
211212

212213
if (!I.mayReadOrWriteMemory())
@@ -3284,8 +3285,7 @@ void Attributor::identifyDefaultAbstractAttributes(Function &F) {
32843285
checkAndQueryIRAttr<Attribute::NoUnwind, AANoUnwind>(FPos, FnAttrs);
32853286

32863287
// Every function might be marked "nosync"
3287-
if (!Attrs.hasFnAttr(Attribute::NoSync))
3288-
getOrCreateAAFor<AANoSync>(FPos);
3288+
checkAndQueryIRAttr<Attribute::NoSync, AANoSync>(FPos, FnAttrs);
32893289

32903290
// Every function might be "no-free".
32913291
checkAndQueryIRAttr<Attribute::NoFree, AANoFree>(FPos, FnAttrs);

llvm/lib/Transforms/IPO/AttributorAttributes.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2417,6 +2417,13 @@ namespace {
24172417
struct AANoSyncImpl : AANoSync {
24182418
AANoSyncImpl(const IRPosition &IRP, Attributor &A) : AANoSync(IRP, A) {}
24192419

2420+
/// See AbstractAttribute::initialize(...).
2421+
void initialize(Attributor &A) override {
2422+
bool IsKnown;
2423+
assert(!AA::hasAssumedIRAttr<Attribute::NoSync>(A, nullptr, getIRPosition(),
2424+
DepClassTy::NONE, IsKnown));
2425+
}
2426+
24202427
const std::string getAsStr(Attributor *A) const override {
24212428
return getAssumed() ? "nosync" : "may-sync";
24222429
}

0 commit comments

Comments
 (0)