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

Abstract Attribute helper functions. More...

Namespaces

namespace  PointerInfo
 

Classes

struct  RangeTy
 Helper to represent an access offset and size, with logic to deal with uncertainty and check for overlapping accesses. More...
 
struct  ValueAndContext
 

Typedefs

using InstExclusionSetTy = SmallPtrSet< Instruction *, 4 >
 

Enumerations

enum class  GPUAddressSpace : unsigned {
  Generic = 0 , Global = 1 , Shared = 3 , Constant = 4 ,
  Local = 5
}
 
enum  ValueScope : uint8_t { Intraprocedural = 1 , Interprocedural = 2 , AnyScope = Intraprocedural | Interprocedural }
 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.
 
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.
 
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.
 
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.
 
ValuegetWithType (Value &V, Type &Ty)
 Try to convert V to type Ty without introducing new instructions.
 
std::optional< Value * > combineOptionalValuesInAAValueLatice (const std::optional< Value * > &A, const std::optional< Value * > &B, Type *Ty)
 Return the combination of A and B such that the result is a possible value of both.
 
raw_ostreamoperator<< (raw_ostream &OS, const RangeTy &R)
 
bool operator== (const RangeTy &A, const RangeTy &B)
 
bool operator!= (const RangeTy &A, const RangeTy &B)
 
ConstantgetInitialValueForObj (Value &Obj, Type &Ty, const TargetLibraryInfo *TLI, const DataLayout &DL, RangeTy *RangePtr=nullptr)
 Return the initial value of Obj with type Ty if that is a constant.
 
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.
 
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.
 
bool isAssumedReadOnly (Attributor &A, const IRPosition &IRP, const AbstractAttribute &QueryingAA, bool &IsKnown)
 Return true if IRP is readonly.
 
bool isAssumedReadNone (Attributor &A, const IRPosition &IRP, const AbstractAttribute &QueryingAA, bool &IsKnown)
 Return true if IRP is readnone.
 
bool isPotentiallyReachable (Attributor &A, const Instruction &FromI, const Instruction &ToI, const AbstractAttribute &QueryingAA, const AA::InstExclusionSetTy *ExclusionSet=nullptr, std::function< bool(const Function &F)> GoBackwardsCB=nullptr)
 Return true if ToI is potentially reachable from FromI without running into any instruction in ExclusionSet The two instructions do not need to be in the same function.
 
bool isPotentiallyReachable (Attributor &A, const Instruction &FromI, const Function &ToFn, const AbstractAttribute &QueryingAA, const AA::InstExclusionSetTy *ExclusionSet=nullptr, std::function< bool(const Function &F)> GoBackwardsCB=nullptr)
 Same as above but it is sufficient to reach any instruction in ToFn.
 
bool isAssumedThreadLocalObject (Attributor &A, Value &Obj, const AbstractAttribute &QueryingAA)
 Return true if Obj is assumed to be a thread local object.
 
bool isPotentiallyAffectedByBarrier (Attributor &A, const Instruction &I, const AbstractAttribute &QueryingAA)
 Return true if I is potentially affected by a barrier.
 
bool isPotentiallyAffectedByBarrier (Attributor &A, ArrayRef< const Value * > Ptrs, const AbstractAttribute &QueryingAA, const Instruction *CtxI)
 

Detailed Description

Abstract Attribute helper functions.

Typedef Documentation

◆ InstExclusionSetTy

Definition at line 156 of file Attributor.h.

Enumeration Type Documentation

◆ GPUAddressSpace

enum class llvm::AA::GPUAddressSpace : unsigned
strong
Enumerator
Generic 
Global 
Shared 
Constant 
Local 

Definition at line 158 of file Attributor.h.

◆ 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 
AnyScope 

Definition at line 169 of file Attributor.h.

Function Documentation

◆ combineOptionalValuesInAAValueLatice()

std::optional< Value * > llvm::AA::combineOptionalValuesInAAValueLatice ( const std::optional< Value * > &  A,
const std::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 309 of file Attributor.cpp.

References A, B, and getWithType().

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

◆ getInitialValueForObj()

Constant * llvm::AA::getInitialValueForObj ( Value Obj,
Type Ty,
const TargetLibraryInfo TLI,
const DataLayout DL,
AA::RangeTy RangePtr = nullptr 
)

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

References A, 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 512 of file Attributor.cpp.

References A, and getPotentialCopiesOfMemoryValue().

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

References A, and 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 562 of file Attributor.cpp.

References A, and isAssumedReadOnlyOrReadNone().

◆ isAssumedThreadLocalObject()

bool llvm::AA::isAssumedThreadLocalObject ( Attributor A,
Value Obj,
const AbstractAttribute QueryingAA 
)

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

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

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

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

◆ isPotentiallyAffectedByBarrier() [1/2]

bool llvm::AA::isPotentiallyAffectedByBarrier ( Attributor A,
ArrayRef< const Value * >  Ptrs,
const AbstractAttribute QueryingAA,
const Instruction CtxI 
)

◆ isPotentiallyAffectedByBarrier() [2/2]

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

◆ isPotentiallyReachable() [1/2]

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

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

Definition at line 740 of file Attributor.cpp.

References A.

◆ isPotentiallyReachable() [2/2]

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

Return true if ToI is potentially reachable from FromI without running into any instruction in ExclusionSet 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 730 of file Attributor.cpp.

References A, and llvm::Instruction::getFunction().

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

References A, 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 250 of file Attributor.cpp.

References A, and I.

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

◆ operator!=()

bool llvm::AA::operator!= ( const RangeTy A,
const RangeTy B 
)
inline

Definition at line 306 of file Attributor.h.

References A, and B.

◆ operator<<()

raw_ostream & llvm::AA::operator<< ( raw_ostream OS,
const RangeTy R 
)
inline

Definition at line 297 of file Attributor.h.

◆ operator==()

bool llvm::AA::operator== ( const RangeTy A,
const RangeTy B 
)
inline

Definition at line 302 of file Attributor.h.

References A, and B.