Skip to content

Commit c33fa5a

Browse files
committed
[Attributor] Port AANoUnwind to the isImpliedByIR interface
1 parent 6e7eb72 commit c33fa5a

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

llvm/lib/Transforms/IPO/Attributor.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3281,8 +3281,7 @@ void Attributor::identifyDefaultAbstractAttributes(Function &F) {
32813281
checkAndQueryIRAttr<Attribute::MustProgress, AAMustProgress>(FPos, FnAttrs);
32823282

32833283
// Every function can be nounwind.
3284-
if (!Attrs.hasFnAttr(Attribute::NoUnwind))
3285-
getOrCreateAAFor<AANoUnwind>(FPos);
3284+
checkAndQueryIRAttr<Attribute::NoUnwind, AANoUnwind>(FPos, FnAttrs);
32863285

32873286
// Every function might be marked "nosync"
32883287
if (!Attrs.hasFnAttr(Attribute::NoSync))

llvm/lib/Transforms/IPO/AttributorAttributes.cpp

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2033,6 +2033,13 @@ namespace {
20332033
struct AANoUnwindImpl : AANoUnwind {
20342034
AANoUnwindImpl(const IRPosition &IRP, Attributor &A) : AANoUnwind(IRP, A) {}
20352035

2036+
/// See AbstractAttribute::initialize(...).
2037+
void initialize(Attributor &A) override {
2038+
bool IsKnown;
2039+
assert(!AA::hasAssumedIRAttr<Attribute::NoUnwind>(
2040+
A, nullptr, getIRPosition(), DepClassTy::NONE, IsKnown));
2041+
}
2042+
20362043
const std::string getAsStr(Attributor *A) const override {
20372044
return getAssumed() ? "nounwind" : "may-unwind";
20382045
}
@@ -2049,10 +2056,10 @@ struct AANoUnwindImpl : AANoUnwind {
20492056
return true;
20502057

20512058
if (const auto *CB = dyn_cast<CallBase>(&I)) {
2052-
bool IsKnown;
2059+
bool IsKnownNoUnwind;
20532060
return AA::hasAssumedIRAttr<Attribute::NoUnwind>(
20542061
A, this, IRPosition::callsite_function(*CB), DepClassTy::REQUIRED,
2055-
IsKnown);
2062+
IsKnownNoUnwind);
20562063
}
20572064
return false;
20582065
};
@@ -2087,9 +2094,9 @@ struct AANoUnwindCallSite final : AANoUnwindImpl {
20872094
// redirecting requests to the callee argument.
20882095
Function *F = getAssociatedFunction();
20892096
const IRPosition &FnPos = IRPosition::function(*F);
2090-
bool IsKnown;
2097+
bool IsKnownNoUnwind;
20912098
if (AA::hasAssumedIRAttr<Attribute::NoUnwind>(
2092-
A, this, FnPos, DepClassTy::REQUIRED, IsKnown))
2099+
A, this, FnPos, DepClassTy::REQUIRED, IsKnownNoUnwind))
20932100
return ChangeStatus::UNCHANGED;
20942101
return indicatePessimisticFixpoint();
20952102
}
@@ -4340,12 +4347,11 @@ struct AAIsDeadValueImpl : public AAIsDead {
43404347
return false;
43414348

43424349
const IRPosition &CallIRP = IRPosition::callsite_function(*CB);
4343-
const auto *NoUnwindAA =
4344-
A.getAndUpdateAAFor<AANoUnwind>(*this, CallIRP, DepClassTy::NONE);
4345-
if (!NoUnwindAA || !NoUnwindAA->isAssumedNoUnwind())
4350+
4351+
bool IsKnownNoUnwind;
4352+
if (!AA::hasAssumedIRAttr<Attribute::NoUnwind>(
4353+
A, this, CallIRP, DepClassTy::OPTIONAL, IsKnownNoUnwind))
43464354
return false;
4347-
if (!NoUnwindAA || !NoUnwindAA->isKnownNoUnwind())
4348-
A.recordDependence(*NoUnwindAA, *this, DepClassTy::OPTIONAL);
43494355

43504356
bool IsKnown;
43514357
return AA::isAssumedReadOnly(A, CallIRP, *this, IsKnown);
@@ -4872,10 +4878,11 @@ identifyAliveSuccessors(Attributor &A, const InvokeInst &II,
48724878
AliveSuccessors.push_back(&II.getUnwindDest()->front());
48734879
} else {
48744880
const IRPosition &IPos = IRPosition::callsite_function(II);
4875-
const auto *AANoUnw =
4876-
A.getAndUpdateAAFor<AANoUnwind>(AA, IPos, DepClassTy::OPTIONAL);
4877-
if (AANoUnw && AANoUnw->isAssumedNoUnwind()) {
4878-
UsedAssumedInformation |= !AANoUnw->isKnownNoUnwind();
4881+
4882+
bool IsKnownNoUnwind;
4883+
if (AA::hasAssumedIRAttr<Attribute::NoUnwind>(
4884+
A, &AA, IPos, DepClassTy::OPTIONAL, IsKnownNoUnwind)) {
4885+
UsedAssumedInformation |= !IsKnownNoUnwind;
48794886
} else {
48804887
AliveSuccessors.push_back(&II.getUnwindDest()->front());
48814888
}

0 commit comments

Comments
 (0)