LLVM
15.0.0git
|
Abstract Attribute helper functions. More...
Namespaces | |
PointerInfo | |
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 Value &V, const Instruction &CtxI, InformationCache &InfoCache) |
Return true if V is a valid value at position CtxI , that is a constant, an argument of the same function as CtxI , or an instruction in that function that dominates CtxI . More... | |
Value * | getWithType (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... | |
Constant * | getInitialValueForObj (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... | |
Abstract Attribute helper functions.
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 153 of file Attributor.h.
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 291 of file Attributor.cpp.
References B, and getWithType().
Referenced by llvm::AAPointerInfo::Access::operator&=(), and llvm::ValueSimplifyStateType::unionAssumed().
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.
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().
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(), getWithType(), and llvm::isAllocationFn().
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 457 of file Attributor.cpp.
References getPotentialCopiesOfMemoryValue(), and SI.
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 447 of file Attributor.cpp.
References getPotentialCopiesOfMemoryValue().
Referenced by genericValueTraversal().
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 268 of file Attributor.cpp.
References llvm::UndefValue::get(), llvm::PoisonValue::get(), llvm::ConstantExpr::getFPTrunc(), llvm::Constant::getNullValue(), llvm::ConstantExpr::getPointerCast(), llvm::Type::getPrimitiveSizeInBits(), llvm::ConstantExpr::getTrunc(), llvm::Value::getType(), llvm::Type::isFloatingPointTy(), llvm::Type::isIntegerTy(), and llvm::Type::isPointerTy().
Referenced by combineOptionalValuesInAAValueLatice(), llvm::Attributor::getAssumedConstant(), llvm::Attributor::getAssumedSimplified(), and getInitialValueForObj().
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 502 of file Attributor.cpp.
References 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 497 of file Attributor.cpp.
References isAssumedReadOnlyOrReadNone().
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().
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.
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 618 of file Attributor.cpp.
References isPotentiallyReachable().
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 607 of file Attributor.cpp.
References llvm::dbgs(), llvm::Instruction::getFunction(), isPotentiallyReachable(), and LLVM_DEBUG.
bool llvm::AA::isValidAtPosition | ( | const Value & | V, |
const Instruction & | CtxI, | ||
InformationCache & | InfoCache | ||
) |
Return true if V
is a valid value at position CtxI
, that is a constant, an argument of the same function as CtxI
, or an instruction in that function that dominates CtxI
.
Definition at line 245 of file Attributor.cpp.
References llvm::any_of(), llvm::InformationCache::getAnalysisResultForFunction(), llvm::Instruction::getFunction(), llvm::Instruction::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 235 of file Attributor.cpp.
References I.
Referenced by genericValueTraversal().