[llvm] c33fa5a - [Attributor] Port AANoUnwind to the isImpliedByIR interface
Johannes Doerfert via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 9 16:05:05 PDT 2023
Author: Johannes Doerfert
Date: 2023-07-09T16:04:21-07:00
New Revision: c33fa5a6f8f353f534492ba02a51739a116be73f
URL: https://github.com/llvm/llvm-project/commit/c33fa5a6f8f353f534492ba02a51739a116be73f
DIFF: https://github.com/llvm/llvm-project/commit/c33fa5a6f8f353f534492ba02a51739a116be73f.diff
LOG: [Attributor] Port AANoUnwind to the isImpliedByIR interface
Added:
Modified:
llvm/lib/Transforms/IPO/Attributor.cpp
llvm/lib/Transforms/IPO/AttributorAttributes.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp
index da9c32e297f05c..314f59f00a0ebd 100644
--- a/llvm/lib/Transforms/IPO/Attributor.cpp
+++ b/llvm/lib/Transforms/IPO/Attributor.cpp
@@ -3281,8 +3281,7 @@ void Attributor::identifyDefaultAbstractAttributes(Function &F) {
checkAndQueryIRAttr<Attribute::MustProgress, AAMustProgress>(FPos, FnAttrs);
// Every function can be nounwind.
- if (!Attrs.hasFnAttr(Attribute::NoUnwind))
- getOrCreateAAFor<AANoUnwind>(FPos);
+ checkAndQueryIRAttr<Attribute::NoUnwind, AANoUnwind>(FPos, FnAttrs);
// Every function might be marked "nosync"
if (!Attrs.hasFnAttr(Attribute::NoSync))
diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
index f7ba3f86fc5a57..081f9f0f0ac314 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -2033,6 +2033,13 @@ namespace {
struct AANoUnwindImpl : AANoUnwind {
AANoUnwindImpl(const IRPosition &IRP, Attributor &A) : AANoUnwind(IRP, A) {}
+ /// See AbstractAttribute::initialize(...).
+ void initialize(Attributor &A) override {
+ bool IsKnown;
+ assert(!AA::hasAssumedIRAttr<Attribute::NoUnwind>(
+ A, nullptr, getIRPosition(), DepClassTy::NONE, IsKnown));
+ }
+
const std::string getAsStr(Attributor *A) const override {
return getAssumed() ? "nounwind" : "may-unwind";
}
@@ -2049,10 +2056,10 @@ struct AANoUnwindImpl : AANoUnwind {
return true;
if (const auto *CB = dyn_cast<CallBase>(&I)) {
- bool IsKnown;
+ bool IsKnownNoUnwind;
return AA::hasAssumedIRAttr<Attribute::NoUnwind>(
A, this, IRPosition::callsite_function(*CB), DepClassTy::REQUIRED,
- IsKnown);
+ IsKnownNoUnwind);
}
return false;
};
@@ -2087,9 +2094,9 @@ struct AANoUnwindCallSite final : AANoUnwindImpl {
// redirecting requests to the callee argument.
Function *F = getAssociatedFunction();
const IRPosition &FnPos = IRPosition::function(*F);
- bool IsKnown;
+ bool IsKnownNoUnwind;
if (AA::hasAssumedIRAttr<Attribute::NoUnwind>(
- A, this, FnPos, DepClassTy::REQUIRED, IsKnown))
+ A, this, FnPos, DepClassTy::REQUIRED, IsKnownNoUnwind))
return ChangeStatus::UNCHANGED;
return indicatePessimisticFixpoint();
}
@@ -4340,12 +4347,11 @@ struct AAIsDeadValueImpl : public AAIsDead {
return false;
const IRPosition &CallIRP = IRPosition::callsite_function(*CB);
- const auto *NoUnwindAA =
- A.getAndUpdateAAFor<AANoUnwind>(*this, CallIRP, DepClassTy::NONE);
- if (!NoUnwindAA || !NoUnwindAA->isAssumedNoUnwind())
+
+ bool IsKnownNoUnwind;
+ if (!AA::hasAssumedIRAttr<Attribute::NoUnwind>(
+ A, this, CallIRP, DepClassTy::OPTIONAL, IsKnownNoUnwind))
return false;
- if (!NoUnwindAA || !NoUnwindAA->isKnownNoUnwind())
- A.recordDependence(*NoUnwindAA, *this, DepClassTy::OPTIONAL);
bool IsKnown;
return AA::isAssumedReadOnly(A, CallIRP, *this, IsKnown);
@@ -4872,10 +4878,11 @@ identifyAliveSuccessors(Attributor &A, const InvokeInst &II,
AliveSuccessors.push_back(&II.getUnwindDest()->front());
} else {
const IRPosition &IPos = IRPosition::callsite_function(II);
- const auto *AANoUnw =
- A.getAndUpdateAAFor<AANoUnwind>(AA, IPos, DepClassTy::OPTIONAL);
- if (AANoUnw && AANoUnw->isAssumedNoUnwind()) {
- UsedAssumedInformation |= !AANoUnw->isKnownNoUnwind();
+
+ bool IsKnownNoUnwind;
+ if (AA::hasAssumedIRAttr<Attribute::NoUnwind>(
+ A, &AA, IPos, DepClassTy::OPTIONAL, IsKnownNoUnwind)) {
+ UsedAssumedInformation |= !IsKnownNoUnwind;
} else {
AliveSuccessors.push_back(&II.getUnwindDest()->front());
}
More information about the llvm-commits
mailing list