struct AbstractAttribute

Declaration

struct AbstractAttribute { /* full declaration omitted */ };

Description

Base struct for all "concrete attribute" deductions. The abstract attribute is a minimal interface that allows the Attributor to orchestrate the abstract/fixpoint analysis. The design allows to hide away implementation choices made for the subclasses but also to structure their implementation and simplify the use of other abstract attributes in-flight. To allow easy creation of new attributes, most methods have default implementations. The ones that do not are generally straight forward, except `AbstractAttribute::updateImpl` which is the location of most reasoning associated with the abstract attribute. The update is invoked by the Attributor in case the situation used to justify the current optimistic state might have changed. The Attributor determines this automatically by monitoring the `Attributor::getAAFor` calls made by abstract attributes. The `updateImpl` method should inspect the IR and other abstract attributes in-flight to justify the best possible (=optimistic) state. The actual implementation is, similar to the underlying abstract state encoding, not exposed. In the most common case, the `updateImpl` will go through a list of reasons why its optimistic state is valid given the current information. If any combination of them holds and is sufficient to justify the current optimistic state, the method shall return UNCHAGED. If not, the optimistic state is adjusted to the situation and the method shall return CHANGED. If the manifestation of the "concrete attribute" deduced by the subclass differs from the "default" behavior, which is a (set of) LLVM-IR attribute(s) for an argument, call site argument, function return value, or function, the `AbstractAttribute::manifest` method should be overloaded. NOTE: If the state obtained via getState() is INVALID, thus if AbstractAttribute::getState().isValidState() returns false, no information provided by the methods of this class should be used. NOTE: The Attributor currently has certain limitations to what we can do. As a general rule of thumb, "concrete" abstract attributes should *for now* only perform "backward" information propagation. That means optimistic information obtained through abstract attributes should only be used at positions that precede the origin of the information with regards to the program flow. More practically, information can *now* be propagated from instructions to their enclosing function, but *not* from call sites to the called function. The mechanisms to allow both directions will be added in the future. NOTE: The mechanics of adding a new "concrete" abstract attribute are described in the file comment.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:1729

Method Overview

  • public void dump() const
  • public virtual const std::string getAsStr() const
  • public virtual const llvm::IRPosition & getIRPosition() const
  • public virtual llvm::AbstractAttribute::StateType & getState()
  • public virtual const llvm::AbstractAttribute::StateType & getState() const
  • public virtual void initialize(llvm::Attributor & A)
  • protected virtual llvm::ChangeStatus manifest(llvm::Attributor & A)
  • public virtual void print(llvm::raw_ostream & OS) const
  • protected virtual void trackStatistics() const
  • protected llvm::ChangeStatus update(llvm::Attributor & A)
  • protected virtual llvm::ChangeStatus updateImpl(llvm::Attributor & A)
  • public virtual ~AbstractAttribute()

Methods

void dump() const

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:1755

virtual const std::string getAsStr() const

Description

This function should return the "summarized" assumed state as string.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:1758

virtual const llvm::IRPosition& getIRPosition()
    const

Description

Return an IR position, see struct IRPosition.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:1750

virtual llvm::AbstractAttribute::StateType&
getState()

Description

Return the internal abstract state for inspection.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:1746

virtual const llvm::AbstractAttribute::StateType&
getState() const

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:1747

virtual void initialize(llvm::Attributor& A)

Description

Initialize the state with the information in the Attributor \p A. This function is called by the Attributor once all abstract attributes have been identified. It can and shall be used for task like: - identify existing knowledge in the IR and use it for the "known state" - perform any work that is not going to change over time, e.g., determine a subset of the IR, or attributes in-flight, that have to be looked at in the `updateImpl` method.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:1743

Parameters

llvm::Attributor& A

virtual llvm::ChangeStatus manifest(
    llvm::Attributor& A)

Description

Hook for the Attributor to trigger the manifestation of the information represented by the abstract attribute in the LLVM-IR.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:1777

Parameters

llvm::Attributor& A

Returns

CHANGED if the IR was altered, otherwise UNCHANGED.

virtual void print(llvm::raw_ostream& OS) const

Description

Helper functions, for debug purposes only. {

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:1754

Parameters

llvm::raw_ostream& OS

virtual void trackStatistics() const

Description

Hook to enable custom statistic tracking, called after manifest that resulted in a change if statistics are enabled. We require subclasses to provide an implementation so we remember to add statistics for them.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:1786

llvm::ChangeStatus update(llvm::Attributor& A)

Description

Hook for the Attributor to trigger an update of the internal state. If this attribute is already fixed, this method will return UNCHANGED, otherwise it delegates to `AbstractAttribute::updateImpl`.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:1771

Parameters

llvm::Attributor& A

Returns

CHANGED if the internal state changed, otherwise UNCHANGED.

virtual llvm::ChangeStatus updateImpl(
    llvm::Attributor& A)

Description

The actual update/transfer function which has to be implemented by the derived classes. If it is called, the environment has changed and we have to determine if the current information is still valid or adjust it otherwise.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:1795

Parameters

llvm::Attributor& A

Returns

CHANGED if the internal state changed, otherwise UNCHANGED.

virtual ~AbstractAttribute()

Description

Virtual destructor.

Declared at: llvm/include/llvm/Transforms/IPO/Attributor.h:1733