LLVM 20.0.0git
Classes | Public Types | 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"

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 Types

using SimplifictionCallbackTy = std::function< std::optional< Value * >(const IRPosition &, const AbstractAttribute *, bool &)>
 Register CB as a simplification callback.
 
using GlobalVariableSimplifictionCallbackTy = std::function< std::optional< Constant * >(const GlobalVariable &, const AbstractAttribute *, bool &)>
 Register CB as a simplification callback.
 
using VirtualUseCallbackTy = std::function< bool(Attributor &, const AbstractAttribute *)>
 

Public Member Functions

 Attributor (SetVector< Function * > &Functions, InformationCache &InfoCache, AttributorConfig Configuration)
 Constructor.
 
 ~Attributor ()
 
ChangeStatus run ()
 Run the analyses until a fixpoint is reached or enforced (timeout).
 
template<typename AAType >
const AAType * getAAFor (const AbstractAttribute &QueryingAA, const IRPosition &IRP, DepClassTy DepClass)
 Lookup an abstract attribute of type AAType at position IRP.
 
template<typename AAType >
const AAType * getOrCreateAAFor (IRPosition IRP, const AbstractAttribute *QueryingAA, DepClassTy DepClass, bool ForceUpdate=false, bool UpdateAfterInit=true)
 The version of getAAFor that allows to omit a querying abstract attribute.
 
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, bool AllowInvalidState=false)
 Return the attribute of AAType for IRP if existing and valid.
 
void registerForUpdate (AbstractAttribute &AA)
 Allows a query AA to request an update if a new query was received.
 
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.
 
template<typename AAType >
AAType & registerAA (AAType &AA)
 Introduce a new abstract attribute into the fixpoint analysis.
 
InformationCachegetInfoCache ()
 Return the internal information cache.
 
bool isModulePass () const
 Return true if this is a module pass, false otherwise.
 
bool shouldSpecializeCallSiteForCallee (const AbstractAttribute &AA, CallBase &CB, Function &Callee, unsigned NumAssumedCallees)
 Return true if we should specialize the call site CB for the potential callee Fn.
 
bool isClosedWorldModule () const
 Return true if the module contains the whole world, thus, no outside functions exist.
 
bool isRunOn (Function &Fn) const
 Return true if we derive attributes for Fn.
 
bool isRunOn (Function *Fn) const
 
template<typename AAType >
bool shouldUpdateAA (const IRPosition &IRP)
 
template<typename AAType >
bool shouldInitialize (const IRPosition &IRP, bool &ShouldUpdateAA)
 
void identifyDefaultAbstractAttributes (Function &F)
 Determine opportunities to derive 'default' attributes in F and create abstract attribute objects for them.
 
bool isFunctionIPOAmendable (const Function &F)
 Determine whether the function F is IPO amendable.
 
void markLiveInternalFunction (const Function &F)
 Mark the internal function F as live.
 
bool changeUseAfterManifest (Use &U, Value &NV)
 Record that U is to be replaces with NV after information was manifested.
 
bool changeAfterManifest (const IRPosition IRP, Value &NV, bool ChangeDroppable=true)
 Helper function to replace all uses associated with IRP with NV.
 
void changeToUnreachableAfterManifest (Instruction *I)
 Record that I is to be replaced with unreachable after information was manifested.
 
void registerInvokeWithDeadSuccessor (InvokeInst &II)
 Record that II has at least one dead successor block.
 
void deleteAfterManifest (Instruction &I)
 Record that I is deleted after information was manifested.
 
void deleteAfterManifest (BasicBlock &BB)
 Record that BB is deleted after information was manifested.
 
void registerManifestAddedBasicBlock (BasicBlock &BB)
 
void deleteAfterManifest (Function &F)
 Record that F is deleted after information was manifested.
 
bool getAttrsFromAssumes (const IRPosition &IRP, Attribute::AttrKind AK, SmallVectorImpl< Attribute > &Attrs)
 Return the attributes of kind AK existing in the IR as operand bundles of an llvm.assume.
 
bool hasAttr (const IRPosition &IRP, ArrayRef< Attribute::AttrKind > AKs, bool IgnoreSubsumingPositions=false, Attribute::AttrKind ImpliedAttributeKind=Attribute::None)
 Return true if any kind in AKs existing in the IR at a position that will affect this one.
 
void getAttrs (const IRPosition &IRP, ArrayRef< Attribute::AttrKind > AKs, SmallVectorImpl< Attribute > &Attrs, bool IgnoreSubsumingPositions=false)
 Return the attributes of any kind in AKs existing in the IR at a position that will affect this one.
 
ChangeStatus removeAttrs (const IRPosition &IRP, ArrayRef< Attribute::AttrKind > AttrKinds)
 Remove all AttrKinds attached to IRP.
 
ChangeStatus removeAttrs (const IRPosition &IRP, ArrayRef< StringRef > Attrs)
 
ChangeStatus manifestAttrs (const IRPosition &IRP, ArrayRef< Attribute > DeducedAttrs, bool ForceReplace=false)
 Attach DeducedAttrs to IRP, if ForceReplace is set we do this even if the same attribute kind was already present.
 
std::optional< Constant * > getAssumedConstant (const IRPosition &IRP, const AbstractAttribute &AA, bool &UsedAssumedInformation)
 If IRP is assumed to be a constant, return it, if it is unclear yet, return std::nullopt, otherwise return nullptr.
 
std::optional< Constant * > getAssumedConstant (const Value &V, const AbstractAttribute &AA, bool &UsedAssumedInformation)
 
std::optional< Value * > getAssumedSimplified (const IRPosition &IRP, const AbstractAttribute &AA, bool &UsedAssumedInformation, AA::ValueScope S)
 If V is assumed simplified, return it, if it is unclear yet, return std::nullopt, otherwise return nullptr.
 
std::optional< Value * > getAssumedSimplified (const Value &V, const AbstractAttribute &AA, bool &UsedAssumedInformation, AA::ValueScope S)
 
std::optional< Value * > getAssumedSimplified (const IRPosition &V, const AbstractAttribute *AA, bool &UsedAssumedInformation, AA::ValueScope S)
 If V is assumed simplified, return it, if it is unclear yet, return std::nullopt, otherwise return nullptr.
 
bool getAssumedSimplifiedValues (const IRPosition &IRP, const AbstractAttribute *AA, SmallVectorImpl< AA::ValueAndContext > &Values, AA::ValueScope S, bool &UsedAssumedInformation, bool RecurseForSelectAndPHI=true)
 Try to simplify IRP and in the scope S.
 
void registerSimplificationCallback (const IRPosition &IRP, const SimplifictionCallbackTy &CB)
 
bool hasSimplificationCallback (const IRPosition &IRP)
 Return true if there is a simplification callback for IRP.
 
void registerGlobalVariableSimplificationCallback (const GlobalVariable &GV, const GlobalVariableSimplifictionCallbackTy &CB)
 
bool hasGlobalVariableSimplificationCallback (const GlobalVariable &GV)
 Return true if there is a simplification callback for GV.
 
std::optional< Constant * > getAssumedInitializerFromCallBack (const GlobalVariable &GV, const AbstractAttribute *AA, bool &UsedAssumedInformation)
 Return std::nullopt if there is no call back registered for GV or the call back is still not sure if GV can be simplified.
 
void registerVirtualUseCallback (const Value &V, const VirtualUseCallbackTy &CB)
 
std::optional< Value * > translateArgumentToCallSiteContent (std::optional< Value * > V, CallBase &CB, const AbstractAttribute &AA, bool &UsedAssumedInformation)
 Translate V from the callee context into the call site context.
 
bool isAssumedDead (const AbstractAttribute &AA, const AAIsDead *LivenessAA, bool &UsedAssumedInformation, bool CheckBBLivenessOnly=false, DepClassTy DepClass=DepClassTy::OPTIONAL)
 Return true if AA (or its context instruction) is assumed dead.
 
bool isAssumedDead (const Instruction &I, const AbstractAttribute *QueryingAA, const AAIsDead *LivenessAA, bool &UsedAssumedInformation, bool CheckBBLivenessOnly=false, DepClassTy DepClass=DepClassTy::OPTIONAL, bool CheckForDeadStore=false)
 Return true if I is assumed dead.
 
bool isAssumedDead (const Use &U, const AbstractAttribute *QueryingAA, const AAIsDead *FnLivenessAA, bool &UsedAssumedInformation, bool CheckBBLivenessOnly=false, DepClassTy DepClass=DepClassTy::OPTIONAL)
 Return true if U is assumed dead.
 
bool isAssumedDead (const IRPosition &IRP, const AbstractAttribute *QueryingAA, const AAIsDead *FnLivenessAA, bool &UsedAssumedInformation, bool CheckBBLivenessOnly=false, DepClassTy DepClass=DepClassTy::OPTIONAL)
 Return true if IRP is assumed dead.
 
bool isAssumedDead (const BasicBlock &BB, const AbstractAttribute *QueryingAA, const AAIsDead *FnLivenessAA, DepClassTy DepClass=DepClassTy::OPTIONAL)
 Return true if BB is assumed dead.
 
bool checkForAllCallees (function_ref< bool(ArrayRef< const Function * > Callees)> Pred, const AbstractAttribute &QueryingAA, const CallBase &CB)
 Check Pred on all potential Callees of CB.
 
bool checkForAllUses (function_ref< bool(const Use &, bool &)> Pred, const AbstractAttribute &QueryingAA, const Value &V, bool CheckBBLivenessOnly=false, DepClassTy LivenessDepClass=DepClassTy::OPTIONAL, bool IgnoreDroppableUses=true, function_ref< bool(const Use &OldU, const Use &NewU)> EquivalentUseCB=nullptr)
 Check Pred on all (transitive) uses of V.
 
template<typename RemarkKind , typename RemarkCallBack >
void emitRemark (Instruction *I, StringRef RemarkName, RemarkCallBack &&RemarkCB) const
 Emit a remark generically.
 
template<typename RemarkKind , typename RemarkCallBack >
void emitRemark (Function *F, StringRef RemarkName, RemarkCallBack &&RemarkCB) const
 Emit a remark on a function.
 
bool isValidFunctionSignatureRewrite (Argument &Arg, ArrayRef< Type * > ReplacementTypes)
 Check if we can rewrite a function signature.
 
bool registerFunctionSignatureRewrite (Argument &Arg, ArrayRef< Type * > ReplacementTypes, ArgumentReplacementInfo::CalleeRepairCBTy &&CalleeRepairCB, ArgumentReplacementInfo::ACSRepairCBTy &&ACSRepairCB)
 Register a rewrite for a function signature.
 
bool checkForAllCallSites (function_ref< bool(AbstractCallSite)> Pred, const AbstractAttribute &QueryingAA, bool RequireAllCallSites, bool &UsedAssumedInformation)
 Check Pred on all function call sites.
 
bool checkForAllCallSites (function_ref< bool(AbstractCallSite)> Pred, const Function &Fn, bool RequireAllCallSites, const AbstractAttribute *QueryingAA, bool &UsedAssumedInformation, bool CheckPotentiallyDead=false)
 Check Pred on all call sites of Fn.
 
bool checkForAllReturnedValues (function_ref< bool(Value &)> Pred, const AbstractAttribute &QueryingAA, AA::ValueScope S=AA::ValueScope::Intraprocedural, bool RecurseForSelectAndPHI=true)
 Check Pred on all values potentially returned by the function associated with QueryingAA.
 
bool checkForAllInstructions (function_ref< bool(Instruction &)> Pred, const Function *Fn, const AbstractAttribute *QueryingAA, ArrayRef< unsigned > Opcodes, bool &UsedAssumedInformation, bool CheckBBLivenessOnly=false, bool CheckPotentiallyDead=false)
 Check Pred on all instructions in Fn with an opcode present in Opcodes.
 
bool checkForAllInstructions (function_ref< bool(Instruction &)> Pred, const AbstractAttribute &QueryingAA, ArrayRef< unsigned > Opcodes, bool &UsedAssumedInformation, bool CheckBBLivenessOnly=false, bool CheckPotentiallyDead=false)
 Check Pred on all instructions with an opcode present in Opcodes.
 
bool checkForAllCallLikeInstructions (function_ref< bool(Instruction &)> Pred, const AbstractAttribute &QueryingAA, bool &UsedAssumedInformation, bool CheckBBLivenessOnly=false, bool CheckPotentiallyDead=false)
 Check Pred on all call-like instructions (=CallBased derived).
 
bool checkForAllReadWriteInstructions (function_ref< bool(Instruction &)> Pred, AbstractAttribute &QueryingAA, bool &UsedAssumedInformation)
 Check Pred on all Read/Write instructions.
 
const DataLayoutgetDataLayout () const
 Return the data layout associated with the anchor scope.
 
const SmallSetVector< Function *, 8 > & getModifiedFunctions ()
 

Static Public Member Functions

static void createShallowWrapper (Function &F)
 Create a shallow wrapper for F such that F has internal linkage afterwards.
 
static bool isInternalizable (Function &F)
 Returns true if the function F can be internalized.
 
static FunctioninternalizeFunction (Function &F, bool Force=false)
 Make another copy of the function F such that the copied version has internal linkage afterwards and can be analysed.
 
static bool internalizeFunctions (SmallPtrSetImpl< Function * > &FnSet, DenseMap< Function *, Function * > &FnMap)
 Make copies of each function in the set FnSet such that the copied version has internal linkage afterwards and can be analysed.
 

Public Attributes

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

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 1516 of file Attributor.h.

Member Typedef Documentation

◆ GlobalVariableSimplifictionCallbackTy

Register CB as a simplification callback.

Similar to registerSimplificationCallback, the call back will be called first when we simplify a global variable GV.

Definition at line 2031 of file Attributor.h.

◆ SimplifictionCallbackTy

using llvm::Attributor::SimplifictionCallbackTy = std::function<std::optional<Value *>( const IRPosition &, const AbstractAttribute *, bool &)>

Register CB as a simplification callback.

Attributor::getAssumedSimplified will use these callbacks before we it will ask AAValueSimplify. It is important to ensure this is called before identifyDefaultAbstractAttributes, assuming the latter is called at all.

Definition at line 2016 of file Attributor.h.

◆ VirtualUseCallbackTy

Definition at line 2062 of file Attributor.h.

Constructor & Destructor Documentation

◆ Attributor()

Attributor::Attributor ( SetVector< Function * > &  Functions,
InformationCache InfoCache,
AttributorConfig  Configuration 
)

Constructor.

Parameters
FunctionsThe set of functions we are deriving attributes for.
InfoCacheCache to hold various information accessible for the abstract attributes.
ConfigurationThe Attributor configuration which determines what generic features to use.

Definition at line 1064 of file Attributor.cpp.

References Allocator, and isClosedWorldModule().

◆ ~Attributor()

Attributor::~Attributor ( )

Definition at line 1530 of file Attributor.cpp.

References llvm::AbstractAttribute::~AbstractAttribute().

Member Function Documentation

◆ changeAfterManifest()

bool llvm::Attributor::changeAfterManifest ( const IRPosition  IRP,
Value NV,
bool  ChangeDroppable = true 
)
inline

Helper function to replace all uses associated with IRP with NV.

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

Definition at line 1856 of file Attributor.h.

References assert(), changeUseAfterManifest(), llvm::IRPosition::getAssociatedValue(), llvm::IRPosition::getCallSiteArgNo(), llvm::IRPosition::getCtxI(), llvm::IRPosition::getPositionKind(), llvm::IRPosition::IRP_CALL_SITE_ARGUMENT, and llvm::Value::stripPointerCasts().

◆ changeToUnreachableAfterManifest()

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

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

Definition at line 1877 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 1842 of file Attributor.h.

References assert().

Referenced by changeAfterManifest().

◆ checkForAllCallees()

bool Attributor::checkForAllCallees ( function_ref< bool(ArrayRef< const Function * > Callees)>  Pred,
const AbstractAttribute QueryingAA,
const CallBase CB 
)

Check Pred on all potential Callees of CB.

This method will evaluate Pred with all potential callees of CB as input and return true if Pred does. If some callees might be unknown this function will return false.

Definition at line 1736 of file Attributor.cpp.

References llvm::IRPosition::callsite_function(), llvm::CallBase::getCalledOperand(), and llvm::OPTIONAL.

◆ checkForAllCallLikeInstructions()

bool llvm::Attributor::checkForAllCallLikeInstructions ( function_ref< bool(Instruction &)>  Pred,
const AbstractAttribute QueryingAA,
bool UsedAssumedInformation,
bool  CheckBBLivenessOnly = false,
bool  CheckPotentiallyDead = false 
)
inline

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

See checkForAllCallLikeInstructions(...) for more information.

Definition at line 2370 of file Attributor.h.

References checkForAllInstructions().

◆ checkForAllCallSites() [1/2]

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

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, UsedAssumedInformation is set if assumed information was used to skip or simplify potential call sites.

Definition at line 1859 of file Attributor.cpp.

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

Referenced by checkForAllCallSites(), and isValidFunctionSignatureRewrite().

◆ checkForAllCallSites() [2/2]

bool Attributor::checkForAllCallSites ( function_ref< bool(AbstractCallSite)>  Pred,
const Function Fn,
bool  RequireAllCallSites,
const AbstractAttribute QueryingAA,
bool UsedAssumedInformation,
bool  CheckPotentiallyDead = false 
)

Check Pred on all call sites of Fn.

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, UsedAssumedInformation is set if assumed information was used to skip or simplify potential call sites.

Definition at line 1878 of file Attributor.cpp.

References llvm::Function::arg_size(), assert(), llvm::dbgs(), DEBUG_WITH_TYPE, llvm::Function::getArg(), llvm::AbstractCallSite::getCallArgOperand(), llvm::AbstractCallSite::getCalledFunction(), llvm::AbstractCallSite::getCalleeUseForCallback(), llvm::AbstractCallSite::getInstruction(), llvm::Value::getName(), llvm::AbstractCallSite::getNumArgOperands(), llvm::Value::getType(), llvm::GlobalValue::hasLocalLinkage(), isAssumedDead(), llvm::AbstractCallSite::isCallbackCall(), llvm::AbstractCallSite::isCallee(), LLVM_DEBUG, llvm::make_pointer_range(), llvm::Value::uses(), Uses, and VERBOSE_DEBUG_TYPE.

◆ checkForAllInstructions() [1/2]

bool Attributor::checkForAllInstructions ( function_ref< bool(Instruction &)>  Pred,
const AbstractAttribute QueryingAA,
ArrayRef< unsigned Opcodes,
bool UsedAssumedInformation,
bool  CheckBBLivenessOnly = false,
bool  CheckPotentiallyDead = 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 2065 of file Attributor.cpp.

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

◆ checkForAllInstructions() [2/2]

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

Check Pred on all instructions in Fn 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 2039 of file Attributor.cpp.

References checkForAllInstructionsImpl(), llvm::IRPosition::function(), llvm::InformationCache::getOpcodeInstMapForFunction(), llvm::GlobalValue::isDeclaration(), and llvm::NONE.

Referenced by checkForAllCallLikeInstructions(), and checkForAllInstructions().

◆ checkForAllReadWriteInstructions()

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

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 2078 of file Attributor.cpp.

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

◆ checkForAllReturnedValues()

bool Attributor::checkForAllReturnedValues ( function_ref< bool(Value &)>  Pred,
const AbstractAttribute QueryingAA,
AA::ValueScope  S = AA::ValueScope::Intraprocedural,
bool  RecurseForSelectAndPHI = true 
)

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 1987 of file Attributor.cpp.

References llvm::all_of(), llvm::IRPosition::getAssociatedFunction(), getAssumedSimplifiedValues(), llvm::AbstractAttribute::getIRPosition(), and llvm::IRPosition::returned().

◆ checkForAllUses()

bool Attributor::checkForAllUses ( function_ref< bool(const Use &, bool &)>  Pred,
const AbstractAttribute QueryingAA,
const Value V,
bool  CheckBBLivenessOnly = false,
DepClassTy  LivenessDepClass = DepClassTy::OPTIONAL,
bool  IgnoreDroppableUses = true,
function_ref< bool(const Use &OldU, const Use &NewU)>  EquivalentUseCB = nullptr 
)

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. If uses are skipped in favor of equivalent ones, e.g., if we look through memory, the EquivalentUseCB will be used to give the caller an idea what original used was replaced by a new one (or new ones). The visit is cut short if EquivalentUseCB returns false and the function will return false as well.

Definition at line 1755 of file Attributor.cpp.

References canMarkAsVisited(), llvm::dbgs(), DEBUG_WITH_TYPE, llvm::SmallVectorBase< Size_T >::empty(), llvm::IRPosition::function(), llvm::IRPosition::getAnchorScope(), llvm::AbstractAttribute::getIRPosition(), llvm::AA::getPotentialCopiesOfStoredValue(), llvm::SmallPtrSetImpl< PtrType >::insert(), isAssumedDead(), LLVM_DEBUG, llvm::NONE, llvm::SmallVectorImpl< T >::pop_back_val(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::SetVector< T, Vector, Set, N >::size(), llvm::SmallVectorBase< Size_T >::size(), and VERBOSE_DEBUG_TYPE.

◆ 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 2713 of file Attributor.cpp.

References llvm::CallBase::addFnAttr(), assert(), llvm::Function::Create(), llvm::CallInst::Create(), llvm::ReturnInst::Create(), llvm::BasicBlock::Create(), F, getName(), llvm::Value::getType(), llvm::GlobalValue::InternalLinkage, llvm::Type::isVoidTy(), 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 1894 of file Attributor.h.

◆ deleteAfterManifest() [2/3]

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

Record that F is deleted after information was manifested.

Definition at line 1903 of file Attributor.h.

References llvm::AttributorConfig::DeleteFns, and 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 1890 of file Attributor.h.

References I.

◆ emitRemark() [1/2]

template<typename RemarkKind , typename RemarkCallBack >
void llvm::Attributor::emitRemark ( Function F,
StringRef  RemarkName,
RemarkCallBack &&  RemarkCB 
) const
inline

Emit a remark on a function.

Definition at line 2189 of file Attributor.h.

References F, llvm::AttributorConfig::OREGetter, llvm::AttributorConfig::PassName, and llvm::StringRef::starts_with().

◆ emitRemark() [2/2]

template<typename RemarkKind , typename RemarkCallBack >
void llvm::Attributor::emitRemark ( Instruction I,
StringRef  RemarkName,
RemarkCallBack &&  RemarkCB 
) const
inline

Emit a remark generically.

This template function can be used to generically emit a remark. The RemarkKind should be one of the following:

The remark is built using a callback function RemarkCB that takes a RemarkKind as input and returns a RemarkKind.

Definition at line 2168 of file Attributor.h.

References F, I, llvm::AttributorConfig::OREGetter, llvm::AttributorConfig::PassName, and llvm::StringRef::starts_with().

◆ 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 1559 of file Attributor.h.

◆ getAssumedConstant() [1/2]

std::optional< Constant * > Attributor::getAssumedConstant ( const IRPosition IRP,
const AbstractAttribute AA,
bool UsedAssumedInformation 
)

If IRP is assumed to be a constant, return it, if it is unclear yet, return std::nullopt, otherwise return nullptr.

Definition at line 1396 of file Attributor.cpp.

References llvm::CallingConv::C, llvm::SmallVectorBase< Size_T >::empty(), llvm::IRPosition::getAssociatedValue(), getAssumedSimplifiedValues(), llvm::AAPotentialValues::getSingleValue(), and llvm::AA::Interprocedural.

Referenced by getAssumedConstant().

◆ getAssumedConstant() [2/2]

std::optional< Constant * > llvm::Attributor::getAssumedConstant ( const Value V,
const AbstractAttribute AA,
bool UsedAssumedInformation 
)
inline

Definition at line 1967 of file Attributor.h.

References getAssumedConstant(), and llvm::IRPosition::value().

◆ getAssumedInitializerFromCallBack()

std::optional< Constant * > llvm::Attributor::getAssumedInitializerFromCallBack ( const GlobalVariable GV,
const AbstractAttribute AA,
bool UsedAssumedInformation 
)
inline

Return std::nullopt if there is no call back registered for GV or the call back is still not sure if GV can be simplified.

Return nullptr if GV can't be simplified.

Definition at line 2049 of file Attributor.h.

References assert(), and llvm_unreachable.

◆ getAssumedSimplified() [1/3]

std::optional< Value * > llvm::Attributor::getAssumedSimplified ( const IRPosition IRP,
const AbstractAttribute AA,
bool UsedAssumedInformation,
AA::ValueScope  S 
)
inline

If V is assumed simplified, return it, if it is unclear yet, return std::nullopt, otherwise return nullptr.

Definition at line 1975 of file Attributor.h.

References getAssumedSimplified().

Referenced by getAssumedSimplified(), identifyDefaultAbstractAttributes(), and translateArgumentToCallSiteContent().

◆ getAssumedSimplified() [2/3]

std::optional< Value * > Attributor::getAssumedSimplified ( const IRPosition V,
const AbstractAttribute AA,
bool UsedAssumedInformation,
AA::ValueScope  S 
)

If V is assumed simplified, return it, if it is unclear yet, return std::nullopt, otherwise return nullptr.

Same as the public version except that it can be used without recording dependences on any AA.

Definition at line 1425 of file Attributor.cpp.

References llvm::SmallVectorBase< Size_T >::empty(), llvm::IRPosition::getAssociatedValue(), getAssumedSimplifiedValues(), llvm::IRPosition::getPositionKind(), llvm::AAPotentialValues::getSingleValue(), llvm::IRPosition::IRP_CALL_SITE_RETURNED, and llvm::IRPosition::IRP_RETURNED.

◆ getAssumedSimplified() [3/3]

std::optional< Value * > llvm::Attributor::getAssumedSimplified ( const Value V,
const AbstractAttribute AA,
bool UsedAssumedInformation,
AA::ValueScope  S 
)
inline

Definition at line 1981 of file Attributor.h.

References getAssumedSimplified(), and llvm::IRPosition::value().

◆ getAssumedSimplifiedValues()

bool Attributor::getAssumedSimplifiedValues ( const IRPosition IRP,
const AbstractAttribute AA,
SmallVectorImpl< AA::ValueAndContext > &  Values,
AA::ValueScope  S,
bool UsedAssumedInformation,
bool  RecurseForSelectAndPHI = true 
)

Try to simplify IRP and in the scope S.

If successful, true is returned and all potential values IRP can take are put into Values. If the result in Values contains select or PHI instructions it means those could not be simplified to a single value. Recursive calls with these instructions will yield their respective potential values. If false is returned no other information is valid.

Definition at line 1448 of file Attributor.cpp.

References llvm::SmallVectorBase< Size_T >::empty(), llvm::IRPosition::getAnchorScope(), llvm::IRPosition::getAssociatedValue(), llvm::IRPosition::getCtxI(), llvm::IRPosition::getPositionKind(), I, llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::AA::Interprocedural, llvm::IRPosition::IRP_RETURNED, llvm::AA::isValidInScope(), llvm::OPTIONAL, llvm::SmallVectorTemplateBase< T, bool >::pop_back(), llvm::SmallVectorImpl< T >::pop_back_val(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::SmallVectorBase< Size_T >::size(), and llvm::IRPosition::value().

Referenced by checkForAllReturnedValues(), getAssumedConstant(), and getAssumedSimplified().

◆ getAttrs()

void Attributor::getAttrs ( const IRPosition IRP,
ArrayRef< Attribute::AttrKind AKs,
SmallVectorImpl< Attribute > &  Attrs,
bool  IgnoreSubsumingPositions = false 
)

Return the attributes of any kind in AKs existing in the IR at a position that will affect this one.

While each position can only have a single attribute of any kind in AKs, there are "subsuming" positions that could have an attribute as well. This method returns all attributes found in Attrs.

Parameters
IgnoreSubsumingPositionsFlag to determine if subsuming positions, e.g., the function position if this is an argument position, should be ignored.

Definition at line 1197 of file Attributor.cpp.

References getAttrsFromAssumes().

◆ getAttrsFromAssumes()

bool Attributor::getAttrsFromAssumes ( const IRPosition IRP,
Attribute::AttrKind  AK,
SmallVectorImpl< Attribute > &  Attrs 
)

◆ getDataLayout()

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

Return the data layout associated with the anchor scope.

Definition at line 2443 of file Attributor.h.

◆ getInfoCache()

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

Return the internal information cache.

Definition at line 1721 of file Attributor.h.

Referenced by getAttrsFromAssumes().

◆ getModifiedFunctions()

const SmallSetVector< Function *, 8 > & llvm::Attributor::getModifiedFunctions ( )
inline

Definition at line 2448 of file Attributor.h.

◆ getOrCreateAAFor() [1/2]

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

Definition at line 1641 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,
bool  UpdateAfterInit = true 
)
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 1571 of file Attributor.h.

References llvm::AbstractAttribute::getState(), llvm::AbstractState::isValidState(), recordDependence(), registerAA(), llvm::DebugCounter::shouldExecute(), and llvm::IRPosition::stripCallBaseContext().

◆ hasAttr()

bool Attributor::hasAttr ( const IRPosition IRP,
ArrayRef< Attribute::AttrKind AKs,
bool  IgnoreSubsumingPositions = false,
Attribute::AttrKind  ImpliedAttributeKind = Attribute::None 
)

Return true if any kind in AKs existing in the IR at a position that will affect this one.

See also getAttrs(...).

Parameters
IgnoreSubsumingPositionsFlag to determine if subsuming positions, e.g., the function position if this is an argument position, should be ignored.

Definition at line 1155 of file Attributor.cpp.

References llvm::Attribute::get(), llvm::IRPosition::getAnchorValue(), getAttrsFromAssumes(), llvm::Value::getContext(), manifestAttrs(), and llvm::Attribute::None.

◆ hasGlobalVariableSimplificationCallback()

bool llvm::Attributor::hasGlobalVariableSimplificationCallback ( const GlobalVariable GV)
inline

Return true if there is a simplification callback for GV.

Definition at line 2041 of file Attributor.h.

◆ hasSimplificationCallback()

bool llvm::Attributor::hasSimplificationCallback ( const IRPosition IRP)
inline

Return true if there is a simplification callback for IRP.

Definition at line 2024 of file Attributor.h.

◆ 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 3341 of file Attributor.cpp.

References AnnotateDeclarationCallSites, llvm::IRPosition::argument(), assert(), llvm::IRPosition::callsite_argument(), llvm::IRPosition::callsite_function(), llvm::IRPosition::callsite_returned(), checkForAllInstructionsImpl(), llvm::DenormalMode::Dynamic, EnableHeapToStack, F, llvm::IRPosition::function(), getAssumedSimplified(), llvm::IRPosition::getAttrList(), llvm::InformationCache::getOpcodeInstMapForFunction(), llvm::AttributeList::getParamAttrs(), llvm::AttributeList::hasParamAttr(), I, llvm::APFloatBase::IEEEsingle(), llvm::IRPosition::inst(), llvm::AA::Intraprocedural, isFunctionIPOAmendable(), isModulePass(), llvm::AttributeFuncs::isNoFPClassCompatibleType(), llvm::Type::isPointerTy(), llvm::IRPosition::returned(), SimplifyAllLoads, Success, and llvm::IRPosition::value().

Referenced by markLiveInternalFunction().

◆ internalizeFunction()

Function * Attributor::internalizeFunction ( Function F,
bool  Force = false 
)
static

Make another copy of the function F such that the copied version has internal linkage afterwards and can be analysed.

Then we replace all uses of the original function to the copied one

Only non-locally linked functions that have linkonce_odr or weak_odr linkage can be internalized because these linkages guarantee that other definitions with the same name have the same semantics as this one.

This will only be run if the attributor-allow-deep-wrappers option is set, or if the function is called with Force set to true.

If the function F failed to be internalized the return value will be a null pointer.

Definition at line 2769 of file Attributor.cpp.

References AllowDeepWrapper, F, internalizeFunctions(), and isInternalizable().

Referenced by runAttributorOnFunctions().

◆ internalizeFunctions()

bool Attributor::internalizeFunctions ( SmallPtrSetImpl< Function * > &  FnSet,
DenseMap< Function *, Function * > &  FnMap 
)
static

Make copies of each function in the set FnSet such that the copied version has internal linkage afterwards and can be analysed.

Then we replace all uses of the original function to the copied one. The map FnMap contains a mapping of functions to their internalized versions.

Only non-locally linked functions that have linkonce_odr or weak_odr linkage can be internalized because these linkages guarantee that other definitions with the same name have the same semantics as this one.

This version will internalize all the functions in the set FnSet at once and then replace the uses. This prevents internalized functions being called by external functions when there is an internalized version in the module.

Definition at line 2782 of file Attributor.cpp.

References llvm::GlobalObject::addMetadata(), llvm::Function::arg_begin(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::clear(), llvm::CloneFunctionInto(), llvm::Function::Create(), llvm::GlobalValue::DefaultVisibility, F, llvm::Value::getName(), llvm::GlobalObject::hasMetadata(), isInternalizable(), llvm::Function::IsNewDbgInfoFormat, llvm::LocalChangesOnly, llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::lookup(), llvm::GlobalValue::PrivateLinkage, llvm::GlobalValue::setDSOLocal(), llvm::GlobalValue::setLinkage(), and llvm::GlobalValue::setVisibility().

Referenced by internalizeFunction(), and llvm::OpenMPOptPass::run().

◆ isAssumedDead() [1/5]

bool Attributor::isAssumedDead ( const AbstractAttribute AA,
const AAIsDead LivenessAA,
bool UsedAssumedInformation,
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 1539 of file Attributor.cpp.

References llvm::SetVector< T, Vector, Set, N >::count(), llvm::IRPosition::getAnchorScope(), llvm::AbstractAttribute::getIRPosition(), isAssumedDead(), and llvm::AttributorConfig::UseLiveness.

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

◆ isAssumedDead() [2/5]

bool Attributor::isAssumedDead ( const BasicBlock BB,
const AbstractAttribute QueryingAA,
const AAIsDead FnLivenessAA,
DepClassTy  DepClass = DepClassTy::OPTIONAL 
)

Return true if BB is assumed dead.

If LivenessAA is not provided it is queried.

Definition at line 1712 of file Attributor.cpp.

References F, llvm::IRPosition::function(), llvm::IRPosition::getAnchorScope(), llvm::BasicBlock::getParent(), llvm::AAIsDead::isAssumedDead(), llvm::NONE, recordDependence(), and llvm::AttributorConfig::UseLiveness.

◆ isAssumedDead() [3/5]

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

◆ isAssumedDead() [4/5]

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

◆ isAssumedDead() [5/5]

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

◆ isClosedWorldModule()

bool Attributor::isClosedWorldModule ( ) const

Return true if the module contains the whole world, thus, no outside functions exist.

Definition at line 3654 of file Attributor.cpp.

References CloseWorldAssumption, llvm::AttributorConfig::IsClosedWorldModule, and isModulePass().

Referenced by Attributor().

◆ 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 1821 of file Attributor.h.

References F, and llvm::AttributorConfig::IPOAmendableCB.

Referenced by identifyDefaultAbstractAttributes().

◆ isInternalizable()

bool Attributor::isInternalizable ( Function F)
static

Returns true if the function F can be internalized.

i.e. it has a compatible linkage.

Definition at line 2762 of file Attributor.cpp.

References F, and llvm::GlobalValue::isInterposableLinkage().

Referenced by internalizeFunction(), internalizeFunctions(), and llvm::OpenMPOptPass::run().

◆ isModulePass()

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

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

Definition at line 1724 of file Attributor.h.

References llvm::AttributorConfig::IsModulePass.

Referenced by identifyDefaultAbstractAttributes(), isClosedWorldModule(), and shouldUpdateAA().

◆ isRunOn() [1/2]

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

Return true if we derive attributes for Fn.

Definition at line 1742 of file Attributor.h.

References isRunOn().

Referenced by isRunOn(), and shouldUpdateAA().

◆ isRunOn() [2/2]

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

◆ isValidFunctionSignatureRewrite()

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

◆ lookupAAFor()

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

Return the attribute of AAType for IRP if existing and valid.

This also allows non-AA users lookup.

Definition at line 1649 of file Attributor.h.

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

◆ manifestAttrs()

ChangeStatus Attributor::manifestAttrs ( const IRPosition IRP,
ArrayRef< Attribute DeducedAttrs,
bool  ForceReplace = false 
)

Attach DeducedAttrs to IRP, if ForceReplace is set we do this even if the same attribute kind was already present.

Definition at line 1245 of file Attributor.cpp.

References addIfNotExistent(), llvm::IRPosition::getAnchorValue(), and llvm::Value::getContext().

Referenced by hasAttr().

◆ 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 1830 of file Attributor.h.

References assert(), llvm::AttributorConfig::DefaultInitializeLiveInternals, F, identifyDefaultAbstractAttributes(), and llvm::AttributorConfig::InitializationCallback.

◆ 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 3302 of file Attributor.cpp.

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

Referenced by 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 1700 of file Attributor.h.

References assert(), llvm::AADepGraphNode::Deps, llvm::SetVector< T, Vector, Set, N >::insert(), llvm::REQUIRED, and llvm::AADepGraph::SyntheticRoot.

Referenced by getOrCreateAAFor().

◆ registerForUpdate()

void Attributor::registerForUpdate ( AbstractAttribute AA)

Allows a query AA to request an update if a new query was received.

Definition at line 2248 of file Attributor.cpp.

References assert(), and llvm::AbstractAttribute::isQueryAA().

◆ 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 2914 of file Attributor.cpp.

References llvm::Function::arg_size(), assert(), llvm::dbgs(), llvm::SmallVectorBase< Size_T >::empty(), llvm::Argument::getArgNo(), llvm::Value::getName(), llvm::Argument::getParent(), isValidFunctionSignatureRewrite(), LLVM_DEBUG, llvm::SmallVectorImpl< T >::resize(), and llvm::ArrayRef< T >::size().

◆ registerGlobalVariableSimplificationCallback()

void llvm::Attributor::registerGlobalVariableSimplificationCallback ( const GlobalVariable GV,
const GlobalVariableSimplifictionCallbackTy CB 
)
inline

Definition at line 2034 of file Attributor.h.

◆ 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 1884 of file Attributor.h.

References II.

◆ registerManifestAddedBasicBlock()

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

Definition at line 1898 of file Attributor.h.

◆ registerSimplificationCallback()

void llvm::Attributor::registerSimplificationCallback ( const IRPosition IRP,
const SimplifictionCallbackTy CB 
)
inline

Definition at line 2018 of file Attributor.h.

◆ registerVirtualUseCallback()

void llvm::Attributor::registerVirtualUseCallback ( const Value V,
const VirtualUseCallbackTy CB 
)
inline

Definition at line 2064 of file Attributor.h.

◆ removeAttrs() [1/2]

ChangeStatus Attributor::removeAttrs ( const IRPosition IRP,
ArrayRef< Attribute::AttrKind AttrKinds 
)

Remove all AttrKinds attached to IRP.

Definition at line 1220 of file Attributor.cpp.

◆ removeAttrs() [2/2]

ChangeStatus Attributor::removeAttrs ( const IRPosition IRP,
ArrayRef< StringRef Attrs 
)

Definition at line 1232 of file Attributor.cpp.

◆ 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 2635 of file Attributor.cpp.

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

◆ shouldInitialize()

template<typename AAType >
bool llvm::Attributor::shouldInitialize ( const IRPosition IRP,
bool ShouldUpdateAA 
)
inline

◆ shouldSpecializeCallSiteForCallee()

bool llvm::Attributor::shouldSpecializeCallSiteForCallee ( const AbstractAttribute AA,
CallBase CB,
Function Callee,
unsigned  NumAssumedCallees 
)
inline

Return true if we should specialize the call site CB for the potential callee Fn.

Definition at line 1728 of file Attributor.h.

References llvm::AttributorConfig::IndirectCalleeSpecializationCallback.

◆ shouldUpdateAA()

template<typename AAType >
bool llvm::Attributor::shouldUpdateAA ( const IRPosition IRP)
inline

◆ translateArgumentToCallSiteContent()

std::optional< Value * > Attributor::translateArgumentToCallSiteContent ( std::optional< Value * >  V,
CallBase CB,
const AbstractAttribute AA,
bool UsedAssumedInformation 
)

Translate V from the callee context into the call site context.

Definition at line 1513 of file Attributor.cpp.

References llvm::CallBase::arg_size(), llvm::IRPosition::callsite_argument(), getAssumedSimplified(), llvm::CallBase::getCalledOperand(), and llvm::AA::Intraprocedural.

Member Data Documentation

◆ Allocator

BumpPtrAllocator& llvm::Attributor::Allocator

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

Definition at line 2446 of file Attributor.h.


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