LLVM  15.0.0git
Namespaces | Classes | Enumerations | Functions
llvm::AA Namespace Reference

Abstract Attribute helper functions. More...

Namespaces

 PointerInfo
 

Classes

struct  ValueAndContext
 

Enumerations

enum  ValueScope : uint8_t { Intraprocedural = 1, Interprocedural = 2 }
 Flags to distinguish intra-procedural queries from potentially inter-procedural queries. More...
 

Functions

bool isNoSyncInst (Attributor &A, const Instruction &I, const AbstractAttribute &QueryingAA)
 Return true if I is a nosync instruction. More...
 
bool isDynamicallyUnique (Attributor &A, const AbstractAttribute &QueryingAA, const Value &V, bool ForAnalysisOnly=true)
 Return true if V is dynamically unique, that is, there are no two "instances" of V at runtime with different values. More...
 
bool isValidInScope (const Value &V, const Function *Scope)
 Return true if V is a valid value in Scope, that is a constant or an instruction/argument of Scope. More...
 
bool isValidAtPosition (const ValueAndContext &VAC, InformationCache &InfoCache)
 Return true if the value of VAC is a valid at the position of VAC, that is a constant, an argument of the same function, or an instruction in that function that dominates the position. More...
 
ValuegetWithType (Value &V, Type &Ty)
 Try to convert V to type Ty without introducing new instructions. More...
 
Optional< Value * > combineOptionalValuesInAAValueLatice (const Optional< Value * > &A, const Optional< Value * > &B, Type *Ty)
 Return the combination of A and B such that the result is a possible value of both. More...
 
ConstantgetInitialValueForObj (Value &Obj, Type &Ty, const TargetLibraryInfo *TLI)
 Return the initial value of Obj with type Ty if that is a constant. More...
 
bool getAssumedUnderlyingObjects (Attributor &A, const Value &Ptr, SmallVectorImpl< Value * > &Objects, const AbstractAttribute &QueryingAA, const Instruction *CtxI, bool &UsedAssumedInformation, AA::ValueScope VS=Interprocedural)
 Collect all potential underlying objects of Ptr at position CtxI in Objects. More...
 
bool getPotentiallyLoadedValues (Attributor &A, LoadInst &LI, SmallSetVector< Value *, 4 > &PotentialValues, SmallSetVector< Instruction *, 4 > &PotentialValueOrigins, const AbstractAttribute &QueryingAA, bool &UsedAssumedInformation, bool OnlyExact=false)
 Collect all potential values LI could read into PotentialValues. More...
 
bool getPotentialCopiesOfStoredValue (Attributor &A, StoreInst &SI, SmallSetVector< Value *, 4 > &PotentialCopies, const AbstractAttribute &QueryingAA, bool &UsedAssumedInformation, bool OnlyExact=false)
 Collect all potential values of the one stored by SI into PotentialCopies. More...
 
bool isAssumedReadOnly (Attributor &A, const IRPosition &IRP, const AbstractAttribute &QueryingAA, bool &IsKnown)
 Return true if IRP is readonly. More...
 
bool isAssumedReadNone (Attributor &A, const IRPosition &IRP, const AbstractAttribute &QueryingAA, bool &IsKnown)
 Return true if IRP is readnone. More...
 
bool isPotentiallyReachable (Attributor &A, const Instruction &FromI, const Instruction &ToI, const AbstractAttribute &QueryingAA, std::function< bool(const Function &F)> GoBackwardsCB=nullptr)
 Return true if ToI is potentially reachable from FromI. More...
 
bool isPotentiallyReachable (Attributor &A, const Instruction &FromI, const Function &ToFn, const AbstractAttribute &QueryingAA, std::function< bool(const Function &F)> GoBackwardsCB)
 Same as above but it is sufficient to reach any instruction in ToFn. More...
 

Detailed Description

Abstract Attribute helper functions.

Enumeration Type Documentation

◆ ValueScope

enum llvm::AA::ValueScope : uint8_t

Flags to distinguish intra-procedural queries from potentially inter-procedural queries.

Not that information can be valid for both and therefore both bits might be set.

Enumerator
Intraprocedural 
Interprocedural 

Definition at line 155 of file Attributor.h.

Function Documentation

◆ combineOptionalValuesInAAValueLatice()

Optional< Value * > llvm::AA::combineOptionalValuesInAAValueLatice ( const Optional< Value * > &  A,
const Optional< Value * > &  B,
Type Ty 
)

Return the combination of A and B such that the result is a possible value of both.

B is potentially casted to match the type Ty or the type of A if Ty is null.

Examples: X + none => X not_none + undef => not_none V1 + V2 => nullptr

Definition at line 296 of file Attributor.cpp.

References B, and getWithType().

Referenced by llvm::AAPointerInfo::Access::operator&=(), and llvm::ValueSimplifyStateType::unionAssumed().

◆ getAssumedUnderlyingObjects()

bool llvm::AA::getAssumedUnderlyingObjects ( Attributor A,
const Value Ptr,
SmallVectorImpl< Value * > &  Objects,
const AbstractAttribute QueryingAA,
const Instruction CtxI,
bool &  UsedAssumedInformation,
AA::ValueScope  VS = Interprocedural 
)

Collect all potential underlying objects of Ptr at position CtxI in Objects.

Assumed information is used and dependences onto QueryingAA are added appropriately.

Returns
True if Objects contains all assumed underlying objects, and false if something went wrong and the objects could not be determined.

Definition at line 459 of file AttributorAttributes.cpp.

References A, genericValueTraversal(), llvm::getUnderlyingObject(), llvm::SmallPtrSetImpl< PtrType >::insert(), and llvm::AArch64CC::VS.

Referenced by getPotentialCopiesOfMemoryValue().

◆ getInitialValueForObj()

Constant * llvm::AA::getInitialValueForObj ( Value Obj,
Type Ty,
const TargetLibraryInfo TLI 
)

Return the initial value of Obj with type Ty if that is a constant.

Definition at line 221 of file Attributor.cpp.

References llvm::UndefValue::get(), llvm::getInitialValueOfAllocation(), and getWithType().

Referenced by getPotentialCopiesOfMemoryValue().

◆ getPotentialCopiesOfStoredValue()

bool llvm::AA::getPotentialCopiesOfStoredValue ( Attributor A,
StoreInst SI,
SmallSetVector< Value *, 4 > &  PotentialCopies,
const AbstractAttribute QueryingAA,
bool &  UsedAssumedInformation,
bool  OnlyExact = false 
)

Collect all potential values of the one stored by SI into PotentialCopies.

That is, the only copies that were made via the store are assumed to be known and all are in PotentialCopies. Dependences onto QueryingAA are properly tracked, UsedAssumedInformation will inform the caller if assumed information was used.

Returns
True if the assumed potential copies are all in PotentialCopies, false if something went wrong and the copies could not be determined.

Definition at line 463 of file Attributor.cpp.

References getPotentialCopiesOfMemoryValue(), and SI.

Referenced by llvm::Attributor::checkForAllUses().

◆ getPotentiallyLoadedValues()

bool llvm::AA::getPotentiallyLoadedValues ( Attributor A,
LoadInst LI,
SmallSetVector< Value *, 4 > &  PotentialValues,
SmallSetVector< Instruction *, 4 > &  PotentialValueOrigins,
const AbstractAttribute QueryingAA,
bool &  UsedAssumedInformation,
bool  OnlyExact = false 
)

Collect all potential values LI could read into PotentialValues.

That is, the only values read by LI are assumed to be known and all are in PotentialValues. PotentialValueOrigins will contain all the instructions that might have put a potential value into PotentialValues. Dependences onto QueryingAA are properly tracked, UsedAssumedInformation will inform the caller if assumed information was used.

Returns
True if the assumed potential copies are all in PotentialValues, false if something went wrong and the copies could not be determined.

Definition at line 453 of file Attributor.cpp.

References getPotentialCopiesOfMemoryValue().

Referenced by genericValueTraversal().

◆ getWithType()

Value * llvm::AA::getWithType ( Value V,
Type Ty 
)

◆ isAssumedReadNone()

bool llvm::AA::isAssumedReadNone ( Attributor A,
const IRPosition IRP,
const AbstractAttribute QueryingAA,
bool &  IsKnown 
)

Return true if IRP is readnone.

This will query respective AAs that deduce the information and introduce dependences for QueryingAA.

Definition at line 508 of file Attributor.cpp.

References isAssumedReadOnlyOrReadNone().

◆ isAssumedReadOnly()

bool llvm::AA::isAssumedReadOnly ( Attributor A,
const IRPosition IRP,
const AbstractAttribute QueryingAA,
bool &  IsKnown 
)

Return true if IRP is readonly.

This will query respective AAs that deduce the information and introduce dependences for QueryingAA.

Definition at line 503 of file Attributor.cpp.

References isAssumedReadOnlyOrReadNone().

◆ isDynamicallyUnique()

bool llvm::AA::isDynamicallyUnique ( Attributor A,
const AbstractAttribute QueryingAA,
const Value V,
bool  ForAnalysisOnly = true 
)

Return true if V is dynamically unique, that is, there are no two "instances" of V at runtime with different values.

Note: If ForAnalysisOnly is set we only check that the Attributor will never use V to represent two "instances" not that V could not technically represent them.

Definition at line 211 of file Attributor.cpp.

References llvm::AAInstanceInfo::isAssumedUniqueForAnalysis(), llvm::OPTIONAL, and llvm::IRPosition::value().

Referenced by genericValueTraversal().

◆ isNoSyncInst()

bool llvm::AA::isNoSyncInst ( Attributor A,
const Instruction I,
const AbstractAttribute QueryingAA 
)

Return true if I is a nosync instruction.

}

Use generic reasoning and potentially the corresponding AANoSync.

Definition at line 186 of file Attributor.cpp.

References llvm::IRPosition::callsite_function(), I, llvm::AANoSync::isAssumedNoSync(), llvm::AANoSync::isNonRelaxedAtomic(), llvm::AANoSync::isNoSyncIntrinsic(), and llvm::OPTIONAL.

◆ isPotentiallyReachable() [1/2]

bool llvm::AA::isPotentiallyReachable ( Attributor A,
const Instruction FromI,
const Function ToFn,
const AbstractAttribute QueryingAA,
std::function< bool(const Function &F)>  GoBackwardsCB 
)

Same as above but it is sufficient to reach any instruction in ToFn.

Definition at line 624 of file Attributor.cpp.

References isPotentiallyReachable().

◆ isPotentiallyReachable() [2/2]

bool llvm::AA::isPotentiallyReachable ( Attributor A,
const Instruction FromI,
const Instruction ToI,
const AbstractAttribute QueryingAA,
std::function< bool(const Function &F)>  GoBackwardsCB = nullptr 
)

Return true if ToI is potentially reachable from FromI.

The two instructions do not need to be in the same function. GoBackwardsCB can be provided to convey domain knowledge about the "lifespan" the user is interested in. By default, the callers of FromI are checked as well to determine if ToI can be reached. If the query is not interested in callers beyond a certain point, e.g., a GPU kernel entry or the function containing an alloca, the GoBackwardsCB should return false.

Definition at line 613 of file Attributor.cpp.

References llvm::dbgs(), llvm::Instruction::getFunction(), isPotentiallyReachable(), and LLVM_DEBUG.

◆ isValidAtPosition()

bool llvm::AA::isValidAtPosition ( const ValueAndContext VAC,
InformationCache InfoCache 
)

Return true if the value of VAC is a valid at the position of VAC, that is a constant, an argument of the same function, or an instruction in that function that dominates the position.

Definition at line 247 of file Attributor.cpp.

References llvm::any_of(), llvm::InformationCache::getAnalysisResultForFunction(), llvm::AA::ValueAndContext::getCtxI(), llvm::Instruction::getFunction(), llvm::Instruction::getParent(), llvm::AA::ValueAndContext::getValue(), I, and llvm::make_range().

◆ isValidInScope()

bool llvm::AA::isValidInScope ( const Value V,
const Function Scope 
)

Return true if V is a valid value in Scope, that is a constant or an instruction/argument of Scope.

Definition at line 237 of file Attributor.cpp.

References I.

Referenced by genericValueTraversal().