LLVM  13.0.0git
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
llvm::Attributor Struct Reference

The fixpoint analysis framework that orchestrates the attribute deduction. More...

#include "llvm/Transforms/IPO/Attributor.h"

Collaboration diagram for llvm::Attributor:
Collaboration graph
[legend]

Classes

struct  ArgumentReplacementInfo
 Helper struct used in the communication between an abstract attribute (AA) that wants to change the signature of a function and the Attributor which applies the changes. More...
 

Public Member Functions

 Attributor (SetVector< Function * > &Functions, InformationCache &InfoCache, CallGraphUpdater &CGUpdater, DenseSet< const char * > *Allowed=nullptr, bool DeleteFns=true)
 Constructor. More...
 
 ~Attributor ()
 
ChangeStatus run ()
 Run the analyses until a fixpoint is reached or enforced (timeout). More...
 
template<typename AAType >
const AAType & getAAFor (const AbstractAttribute &QueryingAA, const IRPosition &IRP, DepClassTy DepClass)
 Lookup an abstract attribute of type AAType at position IRP. More...
 
template<typename AAType >
const AAType & getAndUpdateAAFor (const AbstractAttribute &QueryingAA, const IRPosition &IRP, DepClassTy DepClass)
 Similar to getAAFor but the return abstract attribute will be updated (via AbstractAttribute::update) even if it is found in the cache. More...
 
template<typename AAType >
const AAType & getOrCreateAAFor (IRPosition IRP, const AbstractAttribute *QueryingAA, DepClassTy DepClass, bool ForceUpdate=false)
 The version of getAAFor that allows to omit a querying abstract attribute. More...
 
template<typename AAType >
const AAType & getOrCreateAAFor (const IRPosition &IRP)
 
template<typename AAType >
AAType * lookupAAFor (const IRPosition &IRP, const AbstractAttribute *QueryingAA=nullptr, DepClassTy DepClass=DepClassTy::OPTIONAL)
 Return the attribute of AAType for IRP if existing. More...
 
void recordDependence (const AbstractAttribute &FromAA, const AbstractAttribute &ToAA, DepClassTy DepClass)
 Explicitly record a dependence from FromAA to ToAA, that is if FromAA changes ToAA should be updated as well. More...
 
template<typename AAType >
AAType & registerAA (AAType &AA)
 Introduce a new abstract attribute into the fixpoint analysis. More...
 
InformationCachegetInfoCache ()
 Return the internal information cache. More...
 
bool isModulePass () const
 Return true if this is a module pass, false otherwise. More...
 
bool isRunOn (Function &Fn) const
 Return true if we derive attributes for Fn. More...
 
void identifyDefaultAbstractAttributes (Function &F)
 Determine opportunities to derive 'default' attributes in F and create abstract attribute objects for them. More...
 
bool isFunctionIPOAmendable (const Function &F)
 Determine whether the function F is IPO amendable. More...
 
void markLiveInternalFunction (const Function &F)
 Mark the internal function F as live. More...
 
void removeCallSite (CallInst *CI)
 Helper function to remove callsite. More...
 
bool changeUseAfterManifest (Use &U, Value &NV)
 Record that U is to be replaces with NV after information was manifested. More...
 
bool changeValueAfterManifest (Value &V, Value &NV, bool ChangeDroppable=true)
 Helper function to replace all uses of V with NV. More...
 
void changeToUnreachableAfterManifest (Instruction *I)
 Record that I is to be replaced with unreachable after information was manifested. More...
 
void registerInvokeWithDeadSuccessor (InvokeInst &II)
 Record that II has at least one dead successor block. More...
 
void deleteAfterManifest (Instruction &I)
 Record that I is deleted after information was manifested. More...
 
void deleteAfterManifest (BasicBlock &BB)
 Record that BB is deleted after information was manifested. More...
 
void deleteAfterManifest (Function &F)
 Record that F is deleted after information was manifested. More...
 
Optional< Constant * > getAssumedConstant (const Value &V, const AbstractAttribute &AA, bool &UsedAssumedInformation)
 If V is assumed to be a constant, return it, if it is unclear yet, return None, otherwise return nullptr. More...
 
bool isAssumedDead (const AbstractAttribute &AA, const AAIsDead *LivenessAA, bool CheckBBLivenessOnly=false, DepClassTy DepClass=DepClassTy::OPTIONAL)
 Return true if AA (or its context instruction) is assumed dead. More...
 
bool isAssumedDead (const Instruction &I, const AbstractAttribute *QueryingAA, const AAIsDead *LivenessAA, bool CheckBBLivenessOnly=false, DepClassTy DepClass=DepClassTy::OPTIONAL)
 Return true if I is assumed dead. More...
 
bool isAssumedDead (const Use &U, const AbstractAttribute *QueryingAA, const AAIsDead *FnLivenessAA, bool CheckBBLivenessOnly=false, DepClassTy DepClass=DepClassTy::OPTIONAL)
 Return true if U is assumed dead. More...
 
bool isAssumedDead (const IRPosition &IRP, const AbstractAttribute *QueryingAA, const AAIsDead *FnLivenessAA, bool CheckBBLivenessOnly=false, DepClassTy DepClass=DepClassTy::OPTIONAL)
 Return true if IRP is assumed dead. More...
 
bool checkForAllUses (function_ref< bool(const Use &, bool &)> Pred, const AbstractAttribute &QueryingAA, const Value &V, DepClassTy LivenessDepClass=DepClassTy::OPTIONAL)
 Check Pred on all (transitive) uses of V. More...
 
bool isValidFunctionSignatureRewrite (Argument &Arg, ArrayRef< Type * > ReplacementTypes)
 Check if we can rewrite a function signature. More...
 
bool registerFunctionSignatureRewrite (Argument &Arg, ArrayRef< Type * > ReplacementTypes, ArgumentReplacementInfo::CalleeRepairCBTy &&CalleeRepairCB, ArgumentReplacementInfo::ACSRepairCBTy &&ACSRepairCB)
 Register a rewrite for a function signature. More...
 
bool checkForAllCallSites (function_ref< bool(AbstractCallSite)> Pred, const AbstractAttribute &QueryingAA, bool RequireAllCallSites, bool &AllCallSitesKnown)
 Check Pred on all function call sites. More...
 
bool checkForAllReturnedValuesAndReturnInsts (function_ref< bool(Value &, const SmallSetVector< ReturnInst *, 4 > &)> Pred, const AbstractAttribute &QueryingAA)
 Check Pred on all values potentially returned by F. More...
 
bool checkForAllReturnedValues (function_ref< bool(Value &)> Pred, const AbstractAttribute &QueryingAA)
 Check Pred on all values potentially returned by the function associated with QueryingAA. More...
 
bool checkForAllInstructions (function_ref< bool(Instruction &)> Pred, const AbstractAttribute &QueryingAA, const ArrayRef< unsigned > &Opcodes, bool CheckBBLivenessOnly=false)
 Check Pred on all instructions with an opcode present in Opcodes. More...
 
bool checkForAllCallLikeInstructions (function_ref< bool(Instruction &)> Pred, const AbstractAttribute &QueryingAA)
 Check Pred on all call-like instructions (=CallBased derived). More...
 
bool checkForAllReadWriteInstructions (function_ref< bool(Instruction &)> Pred, AbstractAttribute &QueryingAA)
 Check Pred on all Read/Write instructions. More...
 
const DataLayoutgetDataLayout () const
 Return the data layout associated with the anchor scope. More...
 

Static Public Member Functions

static void createShallowWrapper (Function &F)
 Create a shallow wrapper for F such that F has internal linkage afterwards. More...
 

Public Attributes

BumpPtrAllocatorAllocator
 The allocator used to allocate memory, e.g. for AbstractAttributes. More...
 

Detailed Description

The fixpoint analysis framework that orchestrates the attribute deduction.

The Attributor provides a general abstract analysis framework (guided fixpoint iteration) as well as helper functions for the deduction of (LLVM-IR) attributes. However, also other code properties can be deduced, propagated, and ultimately manifested through the Attributor framework. This is particularly useful if these properties interact with attributes and a co-scheduled deduction allows to improve the solution. Even if not, thus if attributes/properties are completely isolated, they should use the Attributor framework to reduce the number of fixpoint iteration frameworks in the code base. Note that the Attributor design makes sure that isolated attributes are not impacted, in any way, by others derived at the same time if there is no cross-reasoning performed.

The public facing interface of the Attributor is kept simple and basically allows abstract attributes to one thing, query abstract attributes in-flight. There are two reasons to do this: a) The optimistic state of one abstract attribute can justify an optimistic state of another, allowing to framework to end up with an optimistic (=best possible) fixpoint instead of one based solely on information in the IR. b) This avoids reimplementing various kinds of lookups, e.g., to check for existing IR attributes, in favor of a single lookups interface provided by an abstract attribute subclass.

NOTE: The mechanics of adding a new "concrete" abstract attribute are described in the file comment.

Definition at line 1054 of file Attributor.h.

Constructor & Destructor Documentation

◆ Attributor()

llvm::Attributor::Attributor ( SetVector< Function * > &  Functions,
InformationCache InfoCache,
CallGraphUpdater CGUpdater,
DenseSet< const char * > *  Allowed = nullptr,
bool  DeleteFns = true 
)
inline

Constructor.

Parameters
FunctionsThe set of functions we are deriving attributes for.
InfoCacheCache to hold various information accessible for the abstract attributes.
CGUpdaterHelper to update an underlying call graph.
AllowedIf not null, a set limiting the attribute opportunities.
DeleteFnsWhether to delete functions

Definition at line 1063 of file Attributor.h.

◆ ~Attributor()

Attributor::~Attributor ( )

Member Function Documentation

◆ changeToUnreachableAfterManifest()

void llvm::Attributor::changeToUnreachableAfterManifest ( Instruction I)
inline

Record that I is to be replaced with unreachable after information was manifested.

Definition at line 1359 of file Attributor.h.

References I.

◆ changeUseAfterManifest()

bool llvm::Attributor::changeUseAfterManifest ( Use U,
Value NV 
)
inline

Record that U is to be replaces with NV after information was manifested.

This also triggers deletion of trivially dead istructions.

Definition at line 1333 of file Attributor.h.

References assert(), and llvm::Value::stripPointerCasts().

Referenced by changeValueAfterManifest().

◆ changeValueAfterManifest()

bool llvm::Attributor::changeValueAfterManifest ( Value V,
Value NV,
bool  ChangeDroppable = true 
)
inline

Helper function to replace all uses of V with NV.

Return true if there is any change. The flag ChangeDroppable indicates if dropppable uses should be changed too.

Definition at line 1347 of file Attributor.h.

References changeUseAfterManifest(), and llvm::Value::uses().

◆ checkForAllCallLikeInstructions()

bool llvm::Attributor::checkForAllCallLikeInstructions ( function_ref< bool(Instruction &)>  Pred,
const AbstractAttribute QueryingAA 
)
inline

Check Pred on all call-like instructions (=CallBased derived).

See checkForAllCallLikeInstructions(...) for more information.

Definition at line 1570 of file Attributor.h.

References llvm::MCID::Call, and checkForAllInstructions().

◆ checkForAllCallSites()

bool Attributor::checkForAllCallSites ( function_ref< bool(AbstractCallSite)>  Pred,
const AbstractAttribute QueryingAA,
bool  RequireAllCallSites,
bool &  AllCallSitesKnown 
)

Check Pred on all function call sites.

This method will evaluate Pred on call sites and return true if Pred holds in every call sites. However, this is only possible all call sites are known, hence the function has internal linkage. If true is returned, AllCallSitesKnown is set if all possible call sites of the function have been visited.

Definition at line 760 of file Attributor.cpp.

References llvm::dbgs(), llvm::IRPosition::getAssociatedFunction(), llvm::AbstractAttribute::getIRPosition(), and LLVM_DEBUG.

Referenced by isValidFunctionSignatureRewrite().

◆ checkForAllInstructions()

bool Attributor::checkForAllInstructions ( function_ref< bool(Instruction &)>  Pred,
const AbstractAttribute QueryingAA,
const ArrayRef< unsigned > &  Opcodes,
bool  CheckBBLivenessOnly = false 
)

Check Pred on all instructions with an opcode present in Opcodes.

This method will evaluate Pred on all instructions with an opcode present in Opcode and return true if Pred holds on all of them.

Definition at line 940 of file Attributor.cpp.

References checkForAllInstructionsImpl(), llvm::IRPosition::function(), llvm::IRPosition::getAssociatedFunction(), llvm::AbstractAttribute::getIRPosition(), llvm::InformationCache::getOpcodeInstMapForFunction(), and llvm::NONE.

Referenced by checkForAllCallLikeInstructions().

◆ checkForAllReadWriteInstructions()

bool Attributor::checkForAllReadWriteInstructions ( function_ref< bool(Instruction &)>  Pred,
AbstractAttribute QueryingAA 
)

Check Pred on all Read/Write instructions.

This method will evaluate Pred on all instructions that read or write to memory present in the information cache and return true if Pred holds on all of them.

Definition at line 967 of file Attributor.cpp.

References llvm::IRPosition::function(), llvm::IRPosition::getAssociatedFunction(), llvm::AbstractAttribute::getIRPosition(), llvm::InformationCache::getReadOrWriteInstsForFunction(), I, isAssumedDead(), llvm::NONE, and llvm::IRPosition::value().

◆ checkForAllReturnedValues()

bool Attributor::checkForAllReturnedValues ( function_ref< bool(Value &)>  Pred,
const AbstractAttribute QueryingAA 
)

Check Pred on all values potentially returned by the function associated with QueryingAA.

This is the context insensitive version of the method above.

Definition at line 895 of file Attributor.cpp.

References llvm::IRPosition::function(), llvm::IRPosition::getAssociatedFunction(), llvm::AbstractAttribute::getIRPosition(), and llvm::REQUIRED.

◆ checkForAllReturnedValuesAndReturnInsts()

bool Attributor::checkForAllReturnedValuesAndReturnInsts ( function_ref< bool(Value &, const SmallSetVector< ReturnInst *, 4 > &)>  Pred,
const AbstractAttribute QueryingAA 
)

Check Pred on all values potentially returned by F.

This method will evaluate Pred on all values potentially returned by the function associated with QueryingAA. The returned values are matched with their respective return instructions. Returns true if Pred holds on all of them.

Definition at line 872 of file Attributor.cpp.

References llvm::IRPosition::function(), llvm::IRPosition::getAssociatedFunction(), llvm::AbstractAttribute::getIRPosition(), and llvm::REQUIRED.

◆ checkForAllUses()

bool Attributor::checkForAllUses ( function_ref< bool(const Use &, bool &)>  Pred,
const AbstractAttribute QueryingAA,
const Value V,
DepClassTy  LivenessDepClass = DepClassTy::OPTIONAL 
)

Check Pred on all (transitive) uses of V.

This method will evaluate Pred on all (transitive) uses of the associated value and return true if Pred holds every time.

Definition at line 695 of file Attributor.cpp.

References llvm::dbgs(), llvm::IRPosition::function(), llvm::IRPosition::getAnchorScope(), getAssumedConstant(), llvm::AbstractAttribute::getIRPosition(), llvm::SmallPtrSetImpl< PtrType >::insert(), isAssumedDead(), LLVM_DEBUG, llvm::NONE, llvm::SmallVectorImpl< T >::pop_back_val(), llvm::Value::use_empty(), and llvm::Value::uses().

◆ createShallowWrapper()

void Attributor::createShallowWrapper ( Function F)
static

Create a shallow wrapper for F such that F has internal linkage afterwards.

It also sets the original F 's name to anonymous

A wrapper is a function with the same type (and attributes) as F that will only call F and return the result, if any.

Assuming the declaration of looks like: rty F(aty0 arg0, ..., atyN argN);

The wrapper will then look as follows: rty wrapper(aty0 arg0, ..., atyN argN) { return F(arg0, ..., argN); }

Definition at line 1480 of file Attributor.cpp.

References llvm::CallBase::addAttribute(), Arg, llvm::AMDGPU::HSAMD::Kernel::Key::Args, assert(), llvm::BasicBlock::Create(), llvm::Function::Create(), llvm::CallInst::Create(), llvm::ReturnInst::Create(), F, llvm::AttributeList::FunctionIndex, getName(), llvm::Value::getType(), llvm::GlobalValue::InternalLinkage, llvm::Type::isVoidTy(), M, llvm::CallInst::setTailCall(), and Wrapper.

Referenced by runAttributorOnFunctions().

◆ deleteAfterManifest() [1/3]

void llvm::Attributor::deleteAfterManifest ( BasicBlock BB)
inline

Record that BB is deleted after information was manifested.

This also triggers deletion of trivially dead istructions.

Definition at line 1376 of file Attributor.h.

References BB.

◆ deleteAfterManifest() [2/3]

void llvm::Attributor::deleteAfterManifest ( Function F)
inline

Record that F is deleted after information was manifested.

Definition at line 1379 of file Attributor.h.

References F.

◆ deleteAfterManifest() [3/3]

void llvm::Attributor::deleteAfterManifest ( Instruction I)
inline

Record that I is deleted after information was manifested.

This also triggers deletion of trivially dead istructions.

Definition at line 1372 of file Attributor.h.

References I.

◆ getAAFor()

template<typename AAType >
const AAType& llvm::Attributor::getAAFor ( const AbstractAttribute QueryingAA,
const IRPosition IRP,
DepClassTy  DepClass 
)
inline

Lookup an abstract attribute of type AAType at position IRP.

While no abstract attribute is found equivalent positions are checked, see SubsumingPositionIterator. Thus, the returned abstract attribute might be anchored at a different position, e.g., the callee if IRP is a call base.

This method is the only (supported) way an abstract attribute can retrieve information from another abstract attribute. As an example, take an abstract attribute that determines the memory access behavior for a argument (readnone, readonly, ...). It should use getAAFor to get the most optimistic information for other abstract attributes in-flight, e.g. the one reasoning about the "captured" state for the argument or the one reasoning on the memory access behavior of the function as a whole.

If the DepClass enum is set to DepClassTy::None the dependence from QueryingAA to the return abstract attribute is not automatically recorded. This should only be used if the caller will record the dependence explicitly if necessary, thus if it the returned abstract attribute is used for reasoning. To record the dependences explicitly use the Attributor::recordDependence method.

Definition at line 1101 of file Attributor.h.

◆ getAndUpdateAAFor()

template<typename AAType >
const AAType& llvm::Attributor::getAndUpdateAAFor ( const AbstractAttribute QueryingAA,
const IRPosition IRP,
DepClassTy  DepClass 
)
inline

Similar to getAAFor but the return abstract attribute will be updated (via AbstractAttribute::update) even if it is found in the cache.

This is especially useful for AAIsDead as changes in liveness can make updates possible/useful that were not happening before as the abstract attribute was assumed dead.

Definition at line 1113 of file Attributor.h.

◆ getAssumedConstant()

Optional< Constant * > Attributor::getAssumedConstant ( const Value V,
const AbstractAttribute AA,
bool &  UsedAssumedInformation 
)

If V is assumed to be a constant, return it, if it is unclear yet, return None, otherwise return nullptr.

Definition at line 549 of file Attributor.cpp.

References llvm::Value::getType(), llvm::Optional< T >::getValue(), llvm::Optional< T >::hasValue(), llvm::None, llvm::NONE, llvm::OPTIONAL, recordDependence(), and llvm::IRPosition::value().

Referenced by checkForAllUses().

◆ getDataLayout()

const DataLayout& llvm::Attributor::getDataLayout ( ) const
inline

Return the data layout associated with the anchor scope.

Definition at line 1603 of file Attributor.h.

◆ getInfoCache()

InformationCache& llvm::Attributor::getInfoCache ( )
inline

Return the internal information cache.

Definition at line 1279 of file Attributor.h.

Referenced by getOrCreateAAFor().

◆ getOrCreateAAFor() [1/2]

template<typename AAType >
const AAType& llvm::Attributor::getOrCreateAAFor ( const IRPosition IRP)
inline

Definition at line 1207 of file Attributor.h.

References llvm::NONE.

◆ getOrCreateAAFor() [2/2]

template<typename AAType >
const AAType& llvm::Attributor::getOrCreateAAFor ( IRPosition  IRP,
const AbstractAttribute QueryingAA,
DepClassTy  DepClass,
bool  ForceUpdate = false 
)
inline

The version of getAAFor that allows to omit a querying abstract attribute.

Using this after Attributor started running is restricted to only the Attributor itself. Initial seeding of AAs can be done via this function. NOTE: ForceUpdate is ignored in any stage other than the update stage.

Definition at line 1126 of file Attributor.h.

References llvm::IRPosition::getAnchorScope(), getInfoCache(), llvm::AbstractAttribute::getState(), llvm::Function::hasFnAttribute(), llvm::AbstractState::isValidState(), llvm::MaxInitializationChainLength, recordDependence(), registerAA(), and llvm::IRPosition::stripCallBaseContext().

◆ identifyDefaultAbstractAttributes()

void Attributor::identifyDefaultAbstractAttributes ( Function F)

Determine opportunities to derive 'default' attributes in F and create abstract attribute objects for them.

Parameters
FThe function that is checked for attribute opportunities.

Note that abstract attribute instances are generally created even if the IR already contains the information they would deduce. The most important reason for this is the single interface, the one of the abstract attribute instance, which can be queried without the need to look at the IR in various places.

Definition at line 1990 of file Attributor.cpp.

References AnnotateDeclarationCallSites, Arg, llvm::IRPosition::argument(), assert(), llvm::MCID::Call, Callee, llvm::IRPosition::callsite_argument(), llvm::IRPosition::callsite_returned(), checkForAllInstructionsImpl(), E, EnableHeapToStack, F, llvm::IRPosition::function(), llvm::InformationCache::getOpcodeInstMapForFunction(), llvm::getPointerOperand(), llvm::Use::getUser(), I, isModulePass(), llvm::SPII::Load, llvm::IRPosition::returned(), llvm::SPII::Store, Success, and llvm::IRPosition::value().

Referenced by markLiveInternalFunction().

◆ isAssumedDead() [1/4]

bool Attributor::isAssumedDead ( const AbstractAttribute AA,
const AAIsDead LivenessAA,
bool  CheckBBLivenessOnly = false,
DepClassTy  DepClass = DepClassTy::OPTIONAL 
)

Return true if AA (or its context instruction) is assumed dead.

If LivenessAA is not provided it is queried.

Definition at line 584 of file Attributor.cpp.

References llvm::IRPosition::getAnchorScope(), and llvm::AbstractAttribute::getIRPosition().

Referenced by checkForAllReadWriteInstructions(), checkForAllUses(), and isAssumedDead().

◆ isAssumedDead() [2/4]

bool Attributor::isAssumedDead ( const Instruction I,
const AbstractAttribute QueryingAA,
const AAIsDead LivenessAA,
bool  CheckBBLivenessOnly = false,
DepClassTy  DepClass = DepClassTy::OPTIONAL 
)

Return true if I is assumed dead.

If LivenessAA is not provided it is queried.

Definition at line 625 of file Attributor.cpp.

References llvm::IRPosition::function(), llvm::IRPosition::getAnchorScope(), llvm::AbstractAttribute::getIRPosition(), I, llvm::AAIsDead::isAssumedDead(), llvm::NONE, recordDependence(), and llvm::IRPosition::value().

◆ isAssumedDead() [3/4]

bool Attributor::isAssumedDead ( const IRPosition IRP,
const AbstractAttribute QueryingAA,
const AAIsDead FnLivenessAA,
bool  CheckBBLivenessOnly = false,
DepClassTy  DepClass = DepClassTy::OPTIONAL 
)

◆ isAssumedDead() [4/4]

bool Attributor::isAssumedDead ( const Use U,
const AbstractAttribute QueryingAA,
const AAIsDead FnLivenessAA,
bool  CheckBBLivenessOnly = false,
DepClassTy  DepClass = DepClassTy::OPTIONAL 
)

Return true if U is assumed dead.

If FnLivenessAA is not provided it is queried.

Definition at line 593 of file Attributor.cpp.

References llvm::IRPosition::callsite_argument(), llvm::Use::get(), llvm::BasicBlock::getTerminator(), llvm::Use::getUser(), isAssumedDead(), llvm::IRPosition::returned(), and llvm::IRPosition::value().

◆ isFunctionIPOAmendable()

bool llvm::Attributor::isFunctionIPOAmendable ( const Function F)
inline

Determine whether the function F is IPO amendable.

If a function is exactly defined or it has alwaysinline attribute and is viable to be inlined, we say it is IPO amendable

Definition at line 1308 of file Attributor.h.

References F.

◆ isModulePass()

bool llvm::Attributor::isModulePass ( ) const
inline

Return true if this is a module pass, false otherwise.

Definition at line 1282 of file Attributor.h.

Referenced by identifyDefaultAbstractAttributes().

◆ isRunOn()

bool llvm::Attributor::isRunOn ( Function Fn) const
inline

Return true if we derive attributes for Fn.

Definition at line 1288 of file Attributor.h.

◆ isValidFunctionSignatureRewrite()

bool Attributor::isValidFunctionSignatureRewrite ( Argument Arg,
ArrayRef< Type * >  ReplacementTypes 
)

Check if we can rewrite a function signature.

The argument Arg is replaced with new ones defined by the number, order, and types in ReplacementTypes.

Returns
True, if the replacement can be registered, via registerFunctionSignatureRewrite, false otherwise.

Definition at line 1578 of file Attributor.cpp.

References Arg, llvm::MCID::Call, checkForAllCallSites(), checkForAllInstructionsImpl(), llvm::dbgs(), llvm::Function::getAttributes(), llvm::AbstractCallSite::getCalledFunction(), llvm::AbstractCallSite::getInstruction(), llvm::InformationCache::getOpcodeInstMapForFunction(), llvm::Function::getReturnType(), llvm::Value::getType(), llvm::AttributeList::hasAttrSomewhere(), I, llvm::AbstractCallSite::isCallbackCall(), llvm::CallBase::isMustTailCall(), llvm::Function::isVarArg(), and LLVM_DEBUG.

Referenced by registerFunctionSignatureRewrite().

◆ lookupAAFor()

template<typename AAType >
AAType* llvm::Attributor::lookupAAFor ( const IRPosition IRP,
const AbstractAttribute QueryingAA = nullptr,
DepClassTy  DepClass = DepClassTy::OPTIONAL 
)
inline

Return the attribute of AAType for IRP if existing.

This also allows non-AA users lookup.

Definition at line 1215 of file Attributor.h.

References llvm::NONE, and recordDependence().

◆ markLiveInternalFunction()

void llvm::Attributor::markLiveInternalFunction ( const Function F)
inline

Mark the internal function F as live.

This will trigger the identification and initialization of attributes for F.

Definition at line 1316 of file Attributor.h.

References assert(), F, and identifyDefaultAbstractAttributes().

◆ recordDependence()

void Attributor::recordDependence ( const AbstractAttribute FromAA,
const AbstractAttribute ToAA,
DepClassTy  DepClass 
)

Explicitly record a dependence from FromAA to ToAA, that is if FromAA changes ToAA should be updated as well.

This method should be used in conjunction with the getAAFor method and with the DepClass enum passed to the method set to None. This can be beneficial to avoid false dependences but it requires the users of getAAFor to explicitly record true dependences through this method. The DepClass flag indicates if the dependence is striclty necessary. That means for required dependences, if FromAA changes to an invalid state, ToAA can be moved to a pessimistic fixpoint because it required information from FromAA but none are available anymore.

Definition at line 1962 of file Attributor.cpp.

References llvm::AbstractAttribute::getState(), llvm::AbstractState::isAtFixpoint(), and llvm::NONE.

Referenced by getAssumedConstant(), getOrCreateAAFor(), isAssumedDead(), and lookupAAFor().

◆ registerAA()

template<typename AAType >
AAType& llvm::Attributor::registerAA ( AAType &  AA)
inline

Introduce a new abstract attribute into the fixpoint analysis.

Note that ownership of the attribute is given to the Attributor. It will invoke delete for the Attributor on destruction of the Attributor.

Attributes are identified by their IR position (AAType::getIRPosition()) and the address of their static member (see AAType::ID).

Definition at line 1258 of file Attributor.h.

References assert(), llvm::AADepGraphNode::Deps, llvm::REQUIRED, and llvm::AADepGraph::SyntheticRoot.

Referenced by getOrCreateAAFor().

◆ registerFunctionSignatureRewrite()

bool Attributor::registerFunctionSignatureRewrite ( Argument Arg,
ArrayRef< Type * >  ReplacementTypes,
ArgumentReplacementInfo::CalleeRepairCBTy &&  CalleeRepairCB,
ArgumentReplacementInfo::ACSRepairCBTy &&  ACSRepairCB 
)

Register a rewrite for a function signature.

The argument Arg is replaced with new ones defined by the number, order, and types in ReplacementTypes. The rewiring at the call sites is done through ACSRepairCB and at the callee site through CalleeRepairCB.

Returns
True, if the replacement was registered, false otherwise.

Definition at line 1637 of file Attributor.cpp.

References Arg, llvm::Function::arg_size(), assert(), llvm::dbgs(), isValidFunctionSignatureRewrite(), LLVM_DEBUG, move, llvm::SmallVectorImpl< T >::resize(), and llvm::ArrayRef< T >::size().

◆ registerInvokeWithDeadSuccessor()

void llvm::Attributor::registerInvokeWithDeadSuccessor ( InvokeInst II)
inline

Record that II has at least one dead successor block.

This information is used, e.g., to replace II with a call, after information was manifested.

Definition at line 1366 of file Attributor.h.

◆ removeCallSite()

void llvm::Attributor::removeCallSite ( CallInst CI)
inline

Helper function to remove callsite.

Definition at line 1324 of file Attributor.h.

References llvm::CallGraphUpdater::removeCallSite().

◆ run()

ChangeStatus Attributor::run ( )

Run the analyses until a fixpoint is reached or enforced (timeout).

The attributes registered with this Attributor can be used after as long as the Attributor is not destroyed (it owns the attributes now).

\Returns CHANGED if the IR was changed, otherwise UNCHANGED.

Definition at line 1421 of file Attributor.cpp.

References DumpDepGraph, llvm::AADepGraph::dumpGraph(), llvm::AADepGraph::print(), PrintDependencies, ViewDepGraph, and llvm::AADepGraph::viewGraph().

Member Data Documentation

◆ Allocator

BumpPtrAllocator& llvm::Attributor::Allocator

The allocator used to allocate memory, e.g. for AbstractAttributes.

Definition at line 1606 of file Attributor.h.


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