LLVM  14.0.0git
Classes | Public Member Functions | Public Attributes | List of all members
AAHeapToStackFunction Struct Referencefinal

--------------------— Heap-To-Stack Conversion ------------------------— More...

Inheritance diagram for AAHeapToStackFunction:
Inheritance graph
[legend]
Collaboration diagram for AAHeapToStackFunction:
Collaboration graph
[legend]

Classes

struct  AllocationInfo
 
struct  DeallocationInfo
 

Public Member Functions

 AAHeapToStackFunction (const IRPosition &IRP, Attributor &A)
 
 ~AAHeapToStackFunction ()
 
void initialize (Attributor &A) override
 Initialize the state with the information in the Attributor A. More...
 
const std::string getAsStr () const override
 This function should return the "summarized" assumed state as string. More...
 
void trackStatistics () const override
 See AbstractAttribute::trackStatistics(). More...
 
bool isAssumedHeapToStack (const CallBase &CB) const override
 Returns true if HeapToStack conversion is assumed to be possible. More...
 
bool isAssumedHeapToStackRemovedFree (CallBase &CB) const override
 Returns true if HeapToStack conversion is assumed and the CB is a callsite to a free operation to be removed. More...
 
ChangeStatus manifest (Attributor &A) override
 Hook for the Attributor to trigger the manifestation of the information represented by the abstract attribute in the LLVM-IR. More...
 
Optional< APIntgetAPInt (Attributor &A, const AbstractAttribute &AA, Value &V)
 
Optional< APIntgetSize (Attributor &A, const AbstractAttribute &AA, AllocationInfo &AI)
 
ChangeStatus updateImpl (Attributor &A) override
 The actual update/transfer function which has to be implemented by the derived classes. More...
 
- Public Member Functions inherited from llvm::AAHeapToStack
 AAHeapToStack (const IRPosition &IRP, Attributor &A)
 
const std::string getName () const override
 See AbstractAttribute::getName() More...
 
const char * getIdAddr () const override
 See AbstractAttribute::getIdAddr() More...
 
- Public Member Functions inherited from llvm::StateWrapper< BooleanState, AbstractAttribute >
 StateWrapper (const IRPosition &IRP, Ts... Args)
 
StateTypegetState () override
 See AbstractAttribute::getState(...). More...
 
const StateTypegetState () const override
 See AbstractAttribute::getState(...). More...
 
- Public Member Functions inherited from llvm::AbstractAttribute
 AbstractAttribute (const IRPosition &IRP)
 
virtual ~AbstractAttribute ()
 Virtual destructor. More...
 
virtual const StateTypegetState () const =0
 
const IRPositiongetIRPosition () const
 Return an IR position, see struct IRPosition. More...
 
IRPositiongetIRPosition ()
 
void print (raw_ostream &OS) const override
 Helper functions, for debug purposes only. More...
 
virtual void printWithDeps (raw_ostream &OS) const
 
void dump () const
 
- Public Member Functions inherited from llvm::IRPosition
 IRPosition ()
 Default constructor available to create invalid positions implicitly. More...
 
bool operator== (const IRPosition &RHS) const
 
bool operator!= (const IRPosition &RHS) const
 
ValuegetAnchorValue () const
 Return the value this abstract attribute is anchored with. More...
 
FunctiongetAssociatedFunction () const
 Return the associated function, if any. More...
 
ArgumentgetAssociatedArgument () const
 Return the associated argument, if any. More...
 
bool isFnInterfaceKind () const
 Return true if the position refers to a function interface, that is the function scope, the function return, or an argument. More...
 
FunctiongetAnchorScope () const
 Return the Function surrounding the anchor value. More...
 
InstructiongetCtxI () const
 Return the context instruction, if any. More...
 
ValuegetAssociatedValue () const
 Return the value this abstract attribute is associated with. More...
 
TypegetAssociatedType () const
 Return the type this abstract attribute is associated with. More...
 
int getCalleeArgNo () const
 Return the callee argument number of the associated value if it is an argument or call site argument, otherwise a negative value. More...
 
int getCallSiteArgNo () const
 Return the call site argument number of the associated value if it is an argument or call site argument, otherwise a negative value. More...
 
unsigned getAttrIdx () const
 Return the index in the attribute list for this position. More...
 
Kind getPositionKind () const
 Return the associated position kind. More...
 
bool hasAttr (ArrayRef< Attribute::AttrKind > AKs, bool IgnoreSubsumingPositions=false, Attributor *A=nullptr) const
 TODO: Figure out if the attribute related helper functions should live here or somewhere else. More...
 
void getAttrs (ArrayRef< Attribute::AttrKind > AKs, SmallVectorImpl< Attribute > &Attrs, bool IgnoreSubsumingPositions=false, Attributor *A=nullptr) const
 Return the attributes of any kind in AKs existing in the IR at a position that will affect this one. More...
 
void removeAttrs (ArrayRef< Attribute::AttrKind > AKs) const
 Remove the attribute of kind AKs existing in the IR at this position. More...
 
bool isAnyCallSitePosition () const
 
bool isArgumentPosition () const
 Return true if the position is an argument or call site argument. More...
 
IRPosition stripCallBaseContext () const
 Return the same position without the call base context. More...
 
const CallBaseContextgetCallBaseContext () const
 Get the call base context from the position. More...
 
bool hasCallBaseContext () const
 Check if the position has any call base context. More...
 
 operator void * () const
 } More...
 
- Public Member Functions inherited from llvm::AADepGraphNode
virtual ~AADepGraphNode ()
 
aaiterator begin ()
 
aaiterator end ()
 
iterator child_begin ()
 
iterator child_end ()
 
TinyPtrVector< DepTy > & getDeps ()
 
- Public Member Functions inherited from llvm::BooleanState
 BooleanState ()
 
 BooleanState (base_t Assumed)
 
void setAssumed (bool Value)
 Set the assumed value to Value but never below the known one. More...
 
void setKnown (bool Value)
 Set the known and asssumed value to Value. More...
 
bool isAssumed () const
 Return true if the state is assumed to hold. More...
 
bool isKnown () const
 Return true if the state is known to hold. More...
 
- Public Member Functions inherited from llvm::IntegerStateBase< bool, 1, 0 >
 IntegerStateBase ()
 
 IntegerStateBase (base_t Assumed)
 
bool isValidState () const override
 See AbstractState::isValidState() NOTE: For now we simply pretend that the worst possible state is invalid. More...
 
bool isAtFixpoint () const override
 See AbstractState::isAtFixpoint() More...
 
ChangeStatus indicateOptimisticFixpoint () override
 See AbstractState::indicateOptimisticFixpoint(...) More...
 
ChangeStatus indicatePessimisticFixpoint () override
 See AbstractState::indicatePessimisticFixpoint(...) More...
 
base_t getKnown () const
 Return the known state encoding. More...
 
base_t getAssumed () const
 Return the assumed state encoding. More...
 
bool operator== (const IntegerStateBase< base_t, BestState, WorstState > &R) const
 Equality for IntegerStateBase. More...
 
bool operator!= (const IntegerStateBase< base_t, BestState, WorstState > &R) const
 Inequality for IntegerStateBase. More...
 
void operator^= (const IntegerStateBase< base_t, BestState, WorstState > &R)
 "Clamp" this state with R. More...
 
void operator+= (const IntegerStateBase< base_t, BestState, WorstState > &R)
 "Clamp" this state with R. More...
 
void operator|= (const IntegerStateBase< base_t, BestState, WorstState > &R)
 
void operator&= (const IntegerStateBase< base_t, BestState, WorstState > &R)
 
- Public Member Functions inherited from llvm::AbstractState
virtual ~AbstractState ()
 
virtual bool isValidState () const =0
 Return if this abstract state is in a valid state. More...
 
virtual bool isAtFixpoint () const =0
 Return if this abstract state is fixed, thus does not need to be updated if information changes as it cannot change itself. More...
 

Public Attributes

DenseMap< CallBase *, AllocationInfo * > AllocationInfos
 Collection of all malloc-like calls in a function with associated information. More...
 
DenseMap< CallBase *, DeallocationInfo * > DeallocationInfos
 Collection of all free-like calls in a function with associated information. More...
 

Additional Inherited Members

- Public Types inherited from llvm::AAHeapToStack
using Base = StateWrapper< BooleanState, AbstractAttribute >
 
- Public Types inherited from llvm::StateWrapper< BooleanState, AbstractAttribute >
using StateType = BooleanState
 Provide static access to the type of the state. More...
 
- Public Types inherited from llvm::AbstractAttribute
using StateType = AbstractState
 
- Public Types inherited from llvm::IRPosition
enum  Kind : char {
  IRP_INVALID, IRP_FLOAT, IRP_RETURNED, IRP_CALL_SITE_RETURNED,
  IRP_FUNCTION, IRP_CALL_SITE, IRP_ARGUMENT, IRP_CALL_SITE_ARGUMENT
}
 The positions we distinguish in the IR. More...
 
using CallBaseContext = CallBase
 
- Public Types inherited from llvm::AADepGraphNode
using DepTy = PointerIntPair< AADepGraphNode *, 1 >
 
using iterator = mapped_iterator< TinyPtrVector< DepTy >::iterator, decltype(&DepGetVal)>
 
using aaiterator = mapped_iterator< TinyPtrVector< DepTy >::iterator, decltype(&DepGetValAA)>
 
- Public Types inherited from llvm::BooleanState
using super = IntegerStateBase< bool, 1, 0 >
 
using base_t = IntegerStateBase::base_t
 
- Public Types inherited from llvm::IntegerStateBase< bool, 1, 0 >
using base_t = bool
 
- Static Public Member Functions inherited from llvm::AAHeapToStack
static AAHeapToStackcreateForPosition (const IRPosition &IRP, Attributor &A)
 Create an abstract attribute view for the position IRP. More...
 
static bool classof (const AbstractAttribute *AA)
 This function should return true if the type of the AA is AAHeapToStack. More...
 
- Static Public Member Functions inherited from llvm::AbstractAttribute
static bool classof (const AADepGraphNode *DGN)
 This function is used to identify if an DGN is of type AbstractAttribute so that the dyn_cast and cast can use such information to cast an AADepGraphNode to an AbstractAttribute. More...
 
- Static Public Member Functions inherited from llvm::IRPosition
static const IRPosition value (const Value &V, const CallBaseContext *CBContext=nullptr)
 Create a position describing the value of V. More...
 
static const IRPosition function (const Function &F, const CallBaseContext *CBContext=nullptr)
 Create a position describing the function scope of F. More...
 
static const IRPosition returned (const Function &F, const CallBaseContext *CBContext=nullptr)
 Create a position describing the returned value of F. More...
 
static const IRPosition argument (const Argument &Arg, const CallBaseContext *CBContext=nullptr)
 Create a position describing the argument Arg. More...
 
static const IRPosition callsite_function (const CallBase &CB)
 Create a position describing the function scope of CB. More...
 
static const IRPosition callsite_returned (const CallBase &CB)
 Create a position describing the returned value of CB. More...
 
static const IRPosition callsite_argument (const CallBase &CB, unsigned ArgNo)
 Create a position describing the argument of CB at position ArgNo. More...
 
static const IRPosition callsite_argument (AbstractCallSite ACS, unsigned ArgNo)
 Create a position describing the argument of ACS at position ArgNo. More...
 
static const IRPosition function_scope (const IRPosition &IRP, const CallBaseContext *CBContext=nullptr)
 Create a position with function scope matching the "context" of IRP. More...
 
- Static Public Member Functions inherited from llvm::IntegerStateBase< bool, 1, 0 >
static constexpr base_t getBestState ()
 Return the best possible representable state. More...
 
static constexpr base_t getBestState (const IntegerStateBase &)
 
static constexpr base_t getWorstState ()
 Return the worst possible representable state. More...
 
static constexpr base_t getWorstState (const IntegerStateBase &)
 
- Static Public Attributes inherited from llvm::AAHeapToStack
static const char ID = 0
 Unique ID (due to the unique address) More...
 
- Static Public Attributes inherited from llvm::IRPosition
static const IRPosition EmptyKey
 Special DenseMap key values. More...
 
static const IRPosition TombstoneKey
 
- Protected Member Functions inherited from llvm::AbstractAttribute
ChangeStatus update (Attributor &A)
 Hook for the Attributor to trigger an update of the internal state. More...
 
- Protected Member Functions inherited from llvm::AADepGraphNode
 operator AbstractAttribute * ()
 
- Protected Member Functions inherited from llvm::IntegerStateBase< bool, 1, 0 >
virtual void handleNewAssumedValue (base_t Value)=0
 Handle a new assumed value Value. Subtype dependent. More...
 
virtual void handleNewKnownValue (base_t Value)=0
 Handle a new known value Value. Subtype dependent. More...
 
virtual void joinOR (base_t AssumedValue, base_t KnownValue)=0
 Handle a value Value. Subtype dependent. More...
 
virtual void joinAND (base_t AssumedValue, base_t KnownValue)=0
 Handle a new assumed value Value. Subtype dependent. More...
 
- Static Protected Member Functions inherited from llvm::AADepGraphNode
static AADepGraphNodeDepGetVal (DepTy &DT)
 
static AbstractAttributeDepGetValAA (DepTy &DT)
 
- Protected Attributes inherited from llvm::AADepGraphNode
TinyPtrVector< DepTyDeps
 Set of dependency graph nodes which should be updated if this one is updated. More...
 
- Protected Attributes inherited from llvm::IntegerStateBase< bool, 1, 0 >
base_t Known
 The known state encoding in an integer of type base_t. More...
 
base_t Assumed
 The assumed state encoding in an integer of type base_t. More...
 

Detailed Description

--------------------— Heap-To-Stack Conversion ------------------------—

Definition at line 5751 of file AttributorAttributes.cpp.

Constructor & Destructor Documentation

◆ AAHeapToStackFunction()

AAHeapToStackFunction::AAHeapToStackFunction ( const IRPosition IRP,
Attributor A 
)
inline

Definition at line 5794 of file AttributorAttributes.cpp.

◆ ~AAHeapToStackFunction()

AAHeapToStackFunction::~AAHeapToStackFunction ( )
inline

Definition at line 5797 of file AttributorAttributes.cpp.

Member Function Documentation

◆ getAPInt()

Optional<APInt> AAHeapToStackFunction::getAPInt ( Attributor A,
const AbstractAttribute AA,
Value V 
)
inline

◆ getAsStr()

const std::string AAHeapToStackFunction::getAsStr ( ) const
inlineoverridevirtual

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

Implements llvm::AbstractAttribute.

Definition at line 5846 of file AttributorAttributes.cpp.

References llvm::to_string().

◆ getSize()

Optional<APInt> AAHeapToStackFunction::getSize ( Attributor A,
const AbstractAttribute AA,
AllocationInfo AI 
)
inline

◆ initialize()

void AAHeapToStackFunction::initialize ( Attributor A)
inlineoverridevirtual

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:

  • 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.

Reimplemented from llvm::AbstractAttribute.

Definition at line 5806 of file AttributorAttributes.cpp.

References assert(), F, I, llvm::AbstractAttribute::initialize(), llvm::isAlignedAllocLikeFn(), llvm::isCallocLikeFn(), llvm::isFreeCall(), llvm::isMallocLikeFn(), AAHeapToStackFunction::AllocationInfo::LibraryFunctionId, and Success.

◆ isAssumedHeapToStack()

bool AAHeapToStackFunction::isAssumedHeapToStack ( const CallBase CB) const
inlineoverridevirtual

Returns true if HeapToStack conversion is assumed to be possible.

Implements llvm::AAHeapToStack.

Definition at line 5868 of file AttributorAttributes.cpp.

◆ isAssumedHeapToStackRemovedFree()

bool AAHeapToStackFunction::isAssumedHeapToStackRemovedFree ( CallBase CB) const
inlineoverridevirtual

Returns true if HeapToStack conversion is assumed and the CB is a callsite to a free operation to be removed.

Implements llvm::AAHeapToStack.

Definition at line 5875 of file AttributorAttributes.cpp.

References llvm::SmallPtrSetImpl< PtrType >::count(), AAHeapToStackFunction::AllocationInfo::PotentialFreeCalls, and AAHeapToStackFunction::AllocationInfo::Status.

◆ manifest()

ChangeStatus AAHeapToStackFunction::manifest ( Attributor A)
inlineoverridevirtual

◆ trackStatistics()

void AAHeapToStackFunction::trackStatistics ( ) const
inlineoverridevirtual

See AbstractAttribute::trackStatistics().

Implements llvm::AbstractAttribute.

Definition at line 5859 of file AttributorAttributes.cpp.

References BUILD_STAT_NAME, and STATS_DECL.

◆ updateImpl()

ChangeStatus AAHeapToStackFunction::updateImpl ( Attributor A)
overridevirtual

Member Data Documentation

◆ AllocationInfos

DenseMap<CallBase *, AllocationInfo *> AAHeapToStackFunction::AllocationInfos

Collection of all malloc-like calls in a function with associated information.

Definition at line 6025 of file AttributorAttributes.cpp.

◆ DeallocationInfos

DenseMap<CallBase *, DeallocationInfo *> AAHeapToStackFunction::DeallocationInfos

Collection of all free-like calls in a function with associated information.

Definition at line 6029 of file AttributorAttributes.cpp.


The documentation for this struct was generated from the following file: