struct AbstractAttribute

Declaration

struct AbstractAttribute : public IRPosition, public AADepGraphNode { /* 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:2925

Inherits from: IRPosition, AADepGraphNode

Member Variables

Inherited from AADepGraphNode:

protected Deps

Inherited from IRPosition:

public static EmptyKey
public static TombstoneKey

Method Overview

  • public AbstractAttribute(const llvm::IRPosition & IRP)
  • public static bool classof(const llvm::AADepGraphNode * DGN)
  • public void dump() const
  • public virtual const std::string getAsStr() const
  • public const llvm::IRPosition & getIRPosition() const
  • public llvm::IRPosition & getIRPosition()
  • public virtual const char * getIdAddr() const
  • public virtual const std::string getName() const
  • public virtual llvm::AbstractAttribute::StateType & getState()
  • public virtual const llvm::AbstractAttribute::StateType & getState() const
  • public virtual void initialize(llvm::Attributor & A)
  • public virtual bool isQueryAA() const
  • protected virtual llvm::ChangeStatus manifest(llvm::Attributor & A)
  • public void print(llvm::raw_ostream & OS) const
  • public virtual void printWithDeps(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()

Inherited from AADepGraphNode:

Inherited from IRPosition:

Methods

AbstractAttribute(const llvm::IRPosition& IRP)

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

Parameters

const llvm::IRPosition& IRP

static bool classof(
    const llvm::AADepGraphNode* DGN)

Description

This function is used to identify if an \p DGN is of type AbstractAttribute so that the dyn_cast and cast can use such information to cast an AADepGraphNode to an AbstractAttribute. We eagerly return true here because all AADepGraphNodes except for the Synthethis Node are of type AbstractAttribute

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

Parameters

const llvm::AADepGraphNode* DGN

void dump() const

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

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:2974

const llvm::IRPosition& getIRPosition() const

Description

Return an IR position, see struct IRPosition.

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

llvm::IRPosition& getIRPosition()

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

virtual const char* getIdAddr() const

Description

This function should return the address of the ID of the AbstractAttribute

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

virtual const std::string getName() const

Description

This function should return the name of the AbstractAttribute

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

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

Description

Return the internal abstract state for inspection.

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

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

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

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:2949

Parameters

llvm::Attributor& A

virtual bool isQueryAA() const

Description

A query AA is always scheduled as long as we do updates because it does lazy computation that cannot be determined to be done from the outside. However, while query AAs will not be fixed if they do not have outstanding dependences, we will only schedule them like other AAs. If a query AA that received a new query it needs to request an update via `Attributor::requestUpdateForAA`.

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

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:2999

Parameters

llvm::Attributor& A

Returns

CHANGED if the IR was altered, otherwise UNCHANGED.

void print(llvm::raw_ostream& OS) const

Description

Helper functions, for debug purposes only. {

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

Parameters

llvm::raw_ostream& OS

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

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

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:3008

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:2993

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:3017

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:2931