int AttributeIdx;
};
+/// Helper struct necessary as the modular build fails if the virtual method
+/// IRAttribute::manifest is defined in the Attributor.cpp.
+struct IRAttributeManifest {
+ static ChangeStatus manifestAttrs(Attributor &A, IRPosition &IRP,
+ const ArrayRef<Attribute> &DeducedAttrs);
+};
+
/// Helper class that provides common functionality to manifest IR attributes.
template <Attribute::AttrKind AK, typename Base>
-struct IRAttribute : public IRPosition, public Base {
+struct IRAttribute : public IRPosition, public Base, public IRAttributeManifest {
+ ~IRAttribute() {}
/// Constructors for the IRPosition.
///
///}
/// See AbstractAttribute::manifest(...).
- virtual ChangeStatus manifest(Attributor &A);
+ ChangeStatus manifest(Attributor &A) {
+ SmallVector<Attribute, 4> DeducedAttrs;
+ getDeducedAttributes(getAnchorScope().getContext(), DeducedAttrs);
+ return IRAttributeManifest::manifestAttrs(A, getIRPosition(), DeducedAttrs);
+ }
/// Return the kind that identifies the abstract attribute implementation.
Attribute::AttrKind getAttrKind() const { return AK; }
return HasChanged;
}
-template <Attribute::AttrKind AK, typename Base>
-ChangeStatus IRAttribute<AK, Base>::manifest(Attributor &A) {
- assert(this->getState().isValidState() &&
- "Attempted to manifest an invalid state!");
- assert(getIRPosition().getAssociatedValue() &&
+ ChangeStatus IRAttributeManifest::manifestAttrs(Attributor &A, IRPosition
+ &IRP, const ArrayRef<Attribute> &DeducedAttrs) {
+ assert(IRP.getAssociatedValue() &&
"Attempted to manifest an attribute without associated value!");
ChangeStatus HasChanged = ChangeStatus::UNCHANGED;
- Function &ScopeFn = getAnchorScope();
+ Function &ScopeFn = IRP.getAnchorScope();
LLVMContext &Ctx = ScopeFn.getContext();
- IRPosition::Kind PK = getPositionKind();
-
- SmallVector<Attribute, 4> DeducedAttrs;
- getDeducedAttributes(Ctx, DeducedAttrs);
+ IRPosition::Kind PK = IRP.getPositionKind();
// In the following some generic code that will manifest attributes in
// DeducedAttrs if they improve the current IR. Due to the different
Attrs = ScopeFn.getAttributes();
break;
case IRPosition::IRP_CALL_SITE_ARGUMENT:
- Attrs = ImmutableCallSite(&getAnchorValue()).getAttributes();
+ Attrs = ImmutableCallSite(&IRP.getAnchorValue()).getAttributes();
break;
}
for (const Attribute &Attr : DeducedAttrs) {
- if (!addIfNotExistent(Ctx, Attr, Attrs, getAttrIdx()))
+ if (!addIfNotExistent(Ctx, Attr, Attrs, IRP.getAttrIdx()))
continue;
HasChanged = ChangeStatus::CHANGED;
ScopeFn.setAttributes(Attrs);
break;
case IRPosition::IRP_CALL_SITE_ARGUMENT:
- CallSite(&getAnchorValue()).setAttributes(Attrs);
+ CallSite(&IRP.getAnchorValue()).setAttributes(Attrs);
}
return HasChanged;