LLVM
10.0.0svn
|
Base struct for all "concrete attribute" deductions. More...
#include "llvm/Transforms/IPO/Attributor.h"
Public Types | |
using | StateType = AbstractState |
Public Member Functions | |
virtual | ~AbstractAttribute () |
Virtual destructor. More... | |
virtual void | initialize (Attributor &A) |
Initialize the state with the information in the Attributor A . More... | |
virtual StateType & | getState ()=0 |
Return the internal abstract state for inspection. More... | |
virtual const StateType & | getState () const =0 |
virtual const IRPosition & | getIRPosition () const =0 |
Return an IR position, see struct IRPosition. More... | |
virtual void | print (raw_ostream &OS) const |
Helper functions, for debug purposes only. More... | |
void | dump () const |
virtual const std::string | getAsStr () const =0 |
This function should return the "summarized" assumed state as string. More... | |
Protected Member Functions | |
ChangeStatus | update (Attributor &A) |
Hook for the Attributor to trigger an update of the internal state. More... | |
virtual ChangeStatus | manifest (Attributor &A) |
Hook for the Attributor to trigger the manifestation of the information represented by the abstract attribute in the LLVM-IR. More... | |
virtual void | trackStatistics () const =0 |
Hook to enable custom statistic tracking, called after manifest that resulted in a change if statistics are enabled. More... | |
virtual IRPosition & | getIRPosition ()=0 |
Return an IR position, see struct IRPosition. More... | |
virtual ChangeStatus | updateImpl (Attributor &A)=0 |
The actual update/transfer function which has to be implemented by the derived classes. More... | |
Friends | |
struct | Attributor |
} More... | |
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.
Definition at line 1327 of file Attributor.h.
Definition at line 1328 of file Attributor.h.
|
inlinevirtual |
Virtual destructor.
Definition at line 1331 of file Attributor.h.
|
inline |
Definition at line 1353 of file Attributor.h.
References llvm::dbgs(), and print().
|
pure virtual |
This function should return the "summarized" assumed state as string.
Referenced by llvm::IRPosition::getAttrs(), and print().
|
pure virtual |
Return an IR position, see struct IRPosition.
Implemented in llvm::AAHeapToStack, llvm::AAValueSimplify, llvm::AAIsDead, llvm::IRAttribute< Attribute::NonNull, StateWrapper< BooleanState, AbstractAttribute > >, llvm::IRAttribute< Attribute::NoSync, StateWrapper< BooleanState, AbstractAttribute > >, llvm::IRAttribute< Attribute::Alignment, StateWrapper< IntegerState, AbstractAttribute > >, llvm::IRAttribute< Attribute::ReadNone, StateWrapper< IntegerState, AbstractAttribute > >, llvm::IRAttribute< Attribute::NoRecurse, StateWrapper< BooleanState, AbstractAttribute > >, llvm::IRAttribute< Attribute::NoFree, StateWrapper< BooleanState, AbstractAttribute > >, llvm::IRAttribute< Attribute::Dereferenceable, StateWrapper< DerefState, AbstractAttribute > >, llvm::IRAttribute< Attribute::NoReturn, StateWrapper< BooleanState, AbstractAttribute > >, llvm::IRAttribute< Attribute::NoAlias, StateWrapper< BooleanState, AbstractAttribute > >, llvm::IRAttribute< Attribute::WillReturn, StateWrapper< BooleanState, AbstractAttribute > >, llvm::IRAttribute< Attribute::NoUnwind, StateWrapper< BooleanState, AbstractAttribute > >, llvm::IRAttribute< Attribute::NoCapture, StateWrapper< IntegerState, AbstractAttribute > >, and llvm::IRAttribute< Attribute::Returned, AbstractAttribute >.
Referenced by llvm::Attributor::checkForAllCallSites(), llvm::Attributor::checkForAllInstructions(), llvm::Attributor::checkForAllReadWriteInstructions(), llvm::Attributor::checkForAllReturnedValues(), llvm::Attributor::checkForAllReturnedValuesAndReturnInsts(), llvm::IRPosition::getAttrs(), llvm::Attributor::isAssumedDead(), and print().
|
protectedpure virtual |
Return an IR position, see struct IRPosition.
Implemented in llvm::AAHeapToStack, llvm::AAValueSimplify, llvm::AAIsDead, llvm::IRAttribute< Attribute::NonNull, StateWrapper< BooleanState, AbstractAttribute > >, llvm::IRAttribute< Attribute::NoSync, StateWrapper< BooleanState, AbstractAttribute > >, llvm::IRAttribute< Attribute::Alignment, StateWrapper< IntegerState, AbstractAttribute > >, llvm::IRAttribute< Attribute::ReadNone, StateWrapper< IntegerState, AbstractAttribute > >, llvm::IRAttribute< Attribute::NoRecurse, StateWrapper< BooleanState, AbstractAttribute > >, llvm::IRAttribute< Attribute::NoFree, StateWrapper< BooleanState, AbstractAttribute > >, llvm::IRAttribute< Attribute::Dereferenceable, StateWrapper< DerefState, AbstractAttribute > >, llvm::IRAttribute< Attribute::NoReturn, StateWrapper< BooleanState, AbstractAttribute > >, llvm::IRAttribute< Attribute::NoAlias, StateWrapper< BooleanState, AbstractAttribute > >, llvm::IRAttribute< Attribute::WillReturn, StateWrapper< BooleanState, AbstractAttribute > >, llvm::IRAttribute< Attribute::NoUnwind, StateWrapper< BooleanState, AbstractAttribute > >, llvm::IRAttribute< Attribute::NoCapture, StateWrapper< IntegerState, AbstractAttribute > >, and llvm::IRAttribute< Attribute::Returned, AbstractAttribute >.
|
pure virtual |
Return the internal abstract state for inspection.
Implemented in llvm::StateWrapper< IntegerState, AbstractAttribute >, llvm::StateWrapper< DerefState, AbstractAttribute >, and llvm::StateWrapper< BooleanState, AbstractAttribute >.
Referenced by llvm::IRPosition::getAttrs(), llvm::Attributor::getDataLayout(), print(), llvm::Attributor::run(), and update().
|
inlinevirtual |
Initialize the state with the information in the Attributor A
.
This function is called by the Attributor once all abstract attributes have been identified. It can and shall be used for task like:
updateImpl
method. Reimplemented in llvm::IRAttribute< Attribute::NonNull, StateWrapper< BooleanState, AbstractAttribute > >, llvm::IRAttribute< Attribute::NoSync, StateWrapper< BooleanState, AbstractAttribute > >, llvm::IRAttribute< Attribute::Alignment, StateWrapper< IntegerState, AbstractAttribute > >, llvm::IRAttribute< Attribute::ReadNone, StateWrapper< IntegerState, AbstractAttribute > >, llvm::IRAttribute< Attribute::NoRecurse, StateWrapper< BooleanState, AbstractAttribute > >, llvm::IRAttribute< Attribute::NoFree, StateWrapper< BooleanState, AbstractAttribute > >, llvm::IRAttribute< Attribute::Dereferenceable, StateWrapper< DerefState, AbstractAttribute > >, llvm::IRAttribute< Attribute::NoReturn, StateWrapper< BooleanState, AbstractAttribute > >, llvm::IRAttribute< Attribute::NoAlias, StateWrapper< BooleanState, AbstractAttribute > >, llvm::IRAttribute< Attribute::WillReturn, StateWrapper< BooleanState, AbstractAttribute > >, llvm::IRAttribute< Attribute::NoUnwind, StateWrapper< BooleanState, AbstractAttribute > >, llvm::IRAttribute< Attribute::NoCapture, StateWrapper< IntegerState, AbstractAttribute > >, and llvm::IRAttribute< Attribute::Returned, AbstractAttribute >.
Definition at line 1341 of file Attributor.h.
References print().
Referenced by llvm::IRPosition::getAttrs(), and llvm::Attributor::getDataLayout().
|
inlineprotectedvirtual |
Hook for the Attributor to trigger the manifestation of the information represented by the abstract attribute in the LLVM-IR.
CHANGED if the IR was altered, otherwise UNCHANGED.
Reimplemented in llvm::IRAttribute< Attribute::NonNull, StateWrapper< BooleanState, AbstractAttribute > >, llvm::IRAttribute< Attribute::NoSync, StateWrapper< BooleanState, AbstractAttribute > >, llvm::IRAttribute< Attribute::Alignment, StateWrapper< IntegerState, AbstractAttribute > >, llvm::IRAttribute< Attribute::ReadNone, StateWrapper< IntegerState, AbstractAttribute > >, llvm::IRAttribute< Attribute::NoRecurse, StateWrapper< BooleanState, AbstractAttribute > >, llvm::IRAttribute< Attribute::NoFree, StateWrapper< BooleanState, AbstractAttribute > >, llvm::IRAttribute< Attribute::Dereferenceable, StateWrapper< DerefState, AbstractAttribute > >, llvm::IRAttribute< Attribute::NoReturn, StateWrapper< BooleanState, AbstractAttribute > >, llvm::IRAttribute< Attribute::NoAlias, StateWrapper< BooleanState, AbstractAttribute > >, llvm::IRAttribute< Attribute::WillReturn, StateWrapper< BooleanState, AbstractAttribute > >, llvm::IRAttribute< Attribute::NoUnwind, StateWrapper< BooleanState, AbstractAttribute > >, llvm::IRAttribute< Attribute::NoCapture, StateWrapper< IntegerState, AbstractAttribute > >, and llvm::IRAttribute< Attribute::Returned, AbstractAttribute >.
Definition at line 1375 of file Attributor.h.
References A, llvm::operator<<(), and llvm::UNCHANGED.
Referenced by llvm::IRPosition::getAttrs().
|
virtual |
Helper functions, for debug purposes only.
{
Definition at line 4920 of file Attributor.cpp.
References getAsStr(), getIRPosition(), and getState().
Referenced by llvm::operator<<().
|
protectedpure virtual |
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.
Referenced by llvm::IRPosition::getAttrs().
|
protected |
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
.
CHANGED if the internal state changed, otherwise UNCHANGED.
Definition at line 315 of file Attributor.cpp.
References llvm::dbgs(), getState(), LLVM_DEBUG, llvm::UNCHANGED, and updateImpl().
Referenced by llvm::Attributor::getDataLayout().
|
protectedpure virtual |
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.
CHANGED if the internal state changed, otherwise UNCHANGED.
Referenced by llvm::IRPosition::getAttrs(), and update().
|
friend |
}
Allow the Attributor access to the protected methods.
Definition at line 1360 of file Attributor.h.