LLVM 20.0.0git
|
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 | isGPU (const Module &M) |
Return true iff M target a GPU (and we can use GPU AS reasoning). | |
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. | |
Value * | getWithType (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_ostream & | operator<< (raw_ostream &OS, const RangeTy &R) |
bool | operator== (const RangeTy &A, const RangeTy &B) |
bool | operator!= (const RangeTy &A, const RangeTy &B) |
Constant * | getInitialValueForObj (Attributor &A, const AbstractAttribute &QueryingAA, 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) |
template<Attribute::AttrKind AK, typename AAType = AbstractAttribute> | |
bool | hasAssumedIRAttr (Attributor &A, const AbstractAttribute *QueryingAA, const IRPosition &IRP, DepClassTy DepClass, bool &IsKnown, bool IgnoreSubsumingPositions=false, const AAType **AAPtr=nullptr) |
Helper to avoid creating an AA for IR Attributes that might already be set. | |
Abstract Attribute helper functions.
using llvm::AA::InstExclusionSetTy = typedef SmallPtrSet<Instruction *, 4> |
Definition at line 164 of file Attributor.h.
|
strong |
Enumerator | |
---|---|
Generic | |
Global | |
Shared | |
Constant | |
Local |
Definition at line 166 of file Attributor.h.
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 180 of file Attributor.h.
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 340 of file Attributor.cpp.
References A, B, and getWithType().
Referenced by llvm::AAPotentialValues::getSingleValue(), llvm::AAPointerInfo::Access::operator&=(), and llvm::ValueSimplifyStateType::unionAssumed().
Constant * llvm::AA::getInitialValueForObj | ( | Attributor & | A, |
const AbstractAttribute & | QueryingAA, | ||
Value & | Obj, | ||
Type & | Ty, | ||
const TargetLibraryInfo * | TLI, | ||
const DataLayout & | DL, | ||
AA::RangeTy * | RangePtr = nullptr |
||
) |
Return the initial value of Obj
with type Ty
if that is a constant.
Definition at line 243 of file Attributor.cpp.
References A, llvm::ConstantFoldLoadFromConst(), llvm::ConstantFoldLoadFromUniformValue(), DL, llvm::UndefValue::get(), llvm::getInitialValueOfAllocation(), llvm::AA::RangeTy::Offset, llvm::Offset, and llvm::AA::RangeTy::offsetOrSizeAreUnknown().
Referenced by getPotentialCopiesOfMemoryValue().
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.
PotentialCopies
, false if something went wrong and the copies could not be determined. Definition at line 600 of file Attributor.cpp.
References A, and getPotentialCopiesOfMemoryValue().
Referenced by llvm::Attributor::checkForAllUses().
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.
PotentialValues
, false if something went wrong and the copies could not be determined. Definition at line 590 of file Attributor.cpp.
References A, and getPotentialCopiesOfMemoryValue().
Try to convert V
to type Ty
without introducing new instructions.
If this is not possible return nullptr
. Note: this function basically knows how to cast various constants.
Definition at line 317 of file Attributor.cpp.
References llvm::CallingConv::C, llvm::ConstantFoldCastInstruction(), llvm::UndefValue::get(), llvm::PoisonValue::get(), llvm::Constant::getNullValue(), llvm::ConstantExpr::getPointerCast(), llvm::Type::getPrimitiveSizeInBits(), llvm::ConstantExpr::getTrunc(), llvm::Type::isFloatingPointTy(), llvm::Type::isIntegerTy(), and llvm::Type::isPointerTy().
Referenced by combineOptionalValuesInAAValueLatice(), llvm::AAValueConstantRange::getAssumedConstant(), llvm::AAPotentialConstantValues::getAssumedConstant(), and getPotentialCopiesOfMemoryValue().
bool llvm::AA::hasAssumedIRAttr | ( | Attributor & | A, |
const AbstractAttribute * | QueryingAA, | ||
const IRPosition & | IRP, | ||
DepClassTy | DepClass, | ||
bool & | IsKnown, | ||
bool | IgnoreSubsumingPositions = false , |
||
const AAType ** | AAPtr = nullptr |
||
) |
Helper to avoid creating an AA for IR Attributes that might already be set.
Definition at line 6427 of file Attributor.h.
References CASE, llvm_unreachable, llvm::AAMemoryBehavior::NO_ACCESSES, llvm::AAMemoryBehavior::NO_READS, and llvm::AAMemoryBehavior::NO_WRITES.
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 654 of file Attributor.cpp.
References A, and isAssumedReadOnlyOrReadNone().
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 649 of file Attributor.cpp.
References A, and isAssumedReadOnlyOrReadNone().
bool llvm::AA::isAssumedThreadLocalObject | ( | Attributor & | A, |
Value & | Obj, | ||
const AbstractAttribute & | QueryingAA | ||
) |
Return true if Obj
is assumed to be a thread local object.
Definition at line 836 of file Attributor.cpp.
References A, llvm::dbgs(), llvm::Type::getPointerAddressSpace(), llvm::Value::getType(), LLVM_DEBUG, llvm::InformationCache::stackIsAccessibleByOtherThreads(), and llvm::IRPosition::value().
Referenced by isPotentiallyAffectedByBarrier().
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 232 of file Attributor.cpp.
References A, llvm::AAInstanceInfo::isAssumedUniqueForAnalysis(), and llvm::IRPosition::value().
Return true iff M
target a GPU (and we can use GPU AS reasoning).
}
Definition at line 201 of file Attributor.cpp.
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 206 of file Attributor.cpp.
References A, llvm::IRPosition::callsite_function(), I, llvm::AANoSync::isNonRelaxedAtomic(), and llvm::AANoSync::isNoSyncIntrinsic().
bool llvm::AA::isPotentiallyAffectedByBarrier | ( | Attributor & | A, |
ArrayRef< const Value * > | Ptrs, | ||
const AbstractAttribute & | QueryingAA, | ||
const Instruction * | CtxI | ||
) |
Definition at line 919 of file Attributor.cpp.
References A, llvm::dbgs(), isAssumedThreadLocalObject(), LLVM_DEBUG, Ptr, and llvm::IRPosition::value().
bool llvm::AA::isPotentiallyAffectedByBarrier | ( | Attributor & | A, |
const Instruction & | I, | ||
const AbstractAttribute & | QueryingAA | ||
) |
Return true if I
is potentially affected by a barrier.
Definition at line 890 of file Attributor.cpp.
References A, llvm::dbgs(), llvm::SetVector< T, Vector, Set, N >::getArrayRef(), llvm::MemoryLocation::getForDest(), llvm::MemoryLocation::getForSource(), llvm::MemoryLocation::getOrNone(), I, llvm::SetVector< T, Vector, Set, N >::insert(), isPotentiallyAffectedByBarrier(), LLVM_DEBUG, and MI.
Referenced by isPotentiallyAffectedByBarrier().
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 827 of file Attributor.cpp.
References A.
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 817 of file Attributor.cpp.
References A, and llvm::Instruction::getFunction().
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 291 of file Attributor.cpp.
References A, llvm::any_of(), llvm::InformationCache::getAnalysisResultForFunction(), llvm::Instruction::getFunction(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), I, and llvm::make_range().
Return true if V
is a valid value in Scope
, that is a constant or an instruction/argument of Scope
.
Definition at line 281 of file Attributor.cpp.
Referenced by llvm::Attributor::getAssumedSimplifiedValues().
Definition at line 323 of file Attributor.h.
|
inline |
Definition at line 314 of file Attributor.h.
References OS.
Definition at line 319 of file Attributor.h.
References A, B, and llvm::operator==().