97#ifndef LLVM_TRANSFORMS_IPO_ATTRIBUTOR_H
98#define LLVM_TRANSFORMS_IPO_ATTRIBUTOR_H
194 using Base = std::pair<Value *, const Instruction *>;
215 const Value &
V,
bool ForAnalysisOnly =
true);
242 const std::optional<Value *> &
B,
Type *Ty);
268 "Inconsistent state!");
285 if (R.isUnassigned())
311 if (L.Offset < R.Offset)
313 if (L.Offset == R.Offset)
314 return L.Size < R.Size;
324 static constexpr int64_t
Unassigned = std::numeric_limits<int32_t>::min();
325 static constexpr int64_t
Unknown = std::numeric_limits<int32_t>::max();
329 OS <<
"[" << R.Offset <<
", " << R.Size <<
"]";
334 return A.Offset ==
B.Offset &&
A.Size ==
B.Size;
360 bool OnlyExact =
false);
374 bool OnlyExact =
false);
400 std::function<
bool(
const Function &
F)> GoBackwardsCB =
nullptr);
407 std::function<
bool(
const Function &
F)> GoBackwardsCB =
nullptr);
428 return Base::getHashValue(VAC);
433 return Base::isEqual(
LHS,
RHS);
441 return Base::getHashValue(S);
445 return Base::isEqual(
LHS,
RHS);
450struct DenseMapInfo<
const AA::InstExclusionSetTy *>
451 :
public DenseMapInfo<void *> {
455 for (
const auto *
II : *BES)
456 H += DenseMapInfo<const Instruction *>::getHashValue(
II);
463 auto SizeLHS =
LHS ?
LHS->size() : 0;
464 auto SizeRHS =
RHS ?
RHS->size() : 0;
465 if (SizeLHS != SizeRHS)
522 OS <<
"AADepNode Impl\n";
677 return Enc ==
RHS.Enc &&
RHS.CBContext == CBContext;
688 switch (getEncodingBits()) {
690 case ENC_RETURNED_VALUE:
691 case ENC_FLOATING_FUNCTION:
692 return *getAsValuePtr();
693 case ENC_CALL_SITE_ARGUMENT_USE:
694 return *(getAsUsePtr()->getUser());
707 return Arg->getParent();
709 CB->getCalledOperand()->stripPointerCasts());
759 if (!Arg->getParent()->isDeclaration())
760 return &Arg->getParent()->getEntryBlock().front();
762 if (!
F->isDeclaration())
763 return &(
F->getEntryBlock().front());
770 if (getEncodingBits() == ENC_CALL_SITE_ARGUMENT_USE)
771 return *getAsUsePtr()->get();
788 return getArgNo(
true);
797 return getArgNo(
false);
808 return AttributeList::FunctionIndex;
811 return AttributeList::ReturnIndex;
818 "There is no attribute index for a floating or invalid position!");
831 return CB->getAttributes();
838 return CB->setAttributes(AttrList);
844 char EncodingBits = getEncodingBits();
845 if (EncodingBits == ENC_CALL_SITE_ARGUMENT_USE)
847 if (EncodingBits == ENC_FLOATING_FUNCTION)
850 Value *
V = getAsValuePtr();
888 Result.CBContext =
nullptr;
899 operator void *()
const {
return Enc.getOpaqueValue(); }
904 : CBContext(CBContext) {
909 explicit IRPosition(Value &AnchorVal, Kind PK,
911 : CBContext(CBContext) {
919 Enc = {&AnchorVal, ENC_FLOATING_FUNCTION};
921 Enc = {&AnchorVal, ENC_VALUE};
925 Enc = {&AnchorVal, ENC_VALUE};
929 Enc = {&AnchorVal, ENC_RETURNED_VALUE};
932 Enc = {&AnchorVal, ENC_VALUE};
936 "Cannot create call site argument IRP with an anchor value!");
945 int getArgNo(
bool CallbackCalleeArgIfApplicable)
const {
952 if (CallbackCalleeArgIfApplicable) {
954 return Arg->getArgNo();
956 Use &
U = *getAsUsePtr();
969 "Use constructor is for call site arguments only!");
970 Enc = {&
U, ENC_CALL_SITE_ARGUMENT_USE};
975#ifdef EXPENSIVE_CHECKS
983 Value *getAsValuePtr()
const {
984 assert(getEncodingBits() != ENC_CALL_SITE_ARGUMENT_USE &&
985 "Not a value pointer!");
986 return reinterpret_cast<Value *
>(Enc.getPointer());
991 Use *getAsUsePtr()
const {
992 assert(getEncodingBits() == ENC_CALL_SITE_ARGUMENT_USE &&
993 "Not a value pointer!");
994 return reinterpret_cast<Use *
>(Enc.getPointer());
999 static bool isReturnPosition(
char EncodingBits) {
1000 return EncodingBits == ENC_RETURNED_VALUE;
1011 ENC_RETURNED_VALUE = 0b01,
1012 ENC_FLOATING_FUNCTION = 0b10,
1013 ENC_CALL_SITE_ARGUMENT_USE = 0b11,
1018 static constexpr int NumEncodingBits =
1020 static_assert(NumEncodingBits >= 2,
"At least two bits are required!");
1023 PointerIntPair<void *, NumEncodingBits, char> Enc;
1030 char getEncodingBits()
const {
return Enc.getInt(); }
1071 using iterator =
decltype(IRPositions)::iterator;
1075 iterator
begin() {
return IRPositions.begin(); }
1076 iterator
end() {
return IRPositions.end(); }
1092 template <
typename,
typename =
void>
1095 template <
typename Analysis>
1097 bool RequestCachedOnly =
false) {
1098 if (!LegacyPass && !FAM)
1101 if (CachedOnly || RequestCachedOnly)
1106 if (!CachedOnly && !RequestCachedOnly)
1108 ->getAnalysis<
typename Analysis::LegacyWrapper>(
1113 ->getAnalysisIfAvailable<typename Analysis::LegacyWrapper>())
1114 return &
P->getResult();
1121 assert(FAM &&
"Can only be used from the new PM!");
1126 : FAM(&FAM), CachedOnly(CachedOnly) {}
1128 : LegacyPass(
P), CachedOnly(CachedOnly) {}
1133 Pass *LegacyPass =
nullptr;
1137 bool CachedOnly =
false;
1140template <
typename Analysis>
1142 Analysis, std::void_t<typename Analysis::LegacyWrapper>> =
true;
1159 bool UseExplorer =
true)
1160 :
CGSCC(
CGSCC), M(M), Allocator(Allocator), AG(AG) {
1181 for (
auto &It : FuncInfoMap)
1182 It.getSecond()->~FunctionInfo();
1185 for (
auto *BES : BESets)
1186 BES->~InstExclusionSetTy();
1188 Explorer->~MustBeExecutedContextExplorer();
1194 template <
typename CBTy>
1196 bool LookThroughConstantExprUses =
true) {
1199 for (
unsigned Idx = 0; Idx < Worklist.
size(); ++Idx) {
1200 Use &U = *Worklist[Idx];
1221 std::array<InstructionVectorTy *, Instruction::OtherOpsEnd>;
1226 return getFunctionInfo(
F).OpcodeInstMap;
1231 return getFunctionInfo(
F).RWInsts;
1246 FunctionInfo &FI = getFunctionInfo(
F);
1253 FunctionInfo &FI = getFunctionInfo(*Arg.
getParent());
1254 return FI.CalledViaMustTail || FI.ContainsMustTailCall;
1259 FunctionInfo &FI = getFunctionInfo(
F);
1260 if (!FI.AssumeOnlyValuesCollected)
1261 collectAssumeOnlyValues(FI);
1262 return AssumeOnlyValues.contains(&
I);
1270 template <
typename AP>
1272 bool CachedOnly =
false) {
1273 return AG.getAnalysis<AP>(
F, CachedOnly);
1287 auto It = BESets.
find(BES);
1288 if (It != BESets.end())
1291 bool Success = BESets.insert(UniqueBES).second;
1314 if (
const FunctionInfo *FI = FuncInfoMap.lookup(&
F))
1315 return FI->IsExactOrInlineable;
1316 return F.hasExactDefinition();
1325 struct FunctionInfo {
1329 bool IsExactOrInlineable =
false;
1340 bool CalledViaMustTail;
1343 bool ContainsMustTailCall;
1350 bool AssumeOnlyValuesCollected =
false;
1354 DenseMap<const Function *, FunctionInfo *> FuncInfoMap;
1357 FunctionInfo &getFunctionInfo(
const Function &
F) {
1358 auto [It,
Inserted] = FuncInfoMap.try_emplace(&
F);
1363 FunctionInfo *FI =
new (Allocator) FunctionInfo();
1365 initializeInformationCache(
F, *FI);
1375 LLVM_ABI void collectAssumeOnlyValues(FunctionInfo &FI);
1390 MustBeExecutedContextExplorer *Explorer =
nullptr;
1396 SetVector<const Instruction *> AssumeOnlyValues;
1399 DenseSet<const AA::InstExclusionSetTy *> BESets;
1405 SmallPtrSet<const Function *, 8> InlineableFunctions;
1417 template <
typename... AATypes>
static constexpr AAKindSet
get();
1420 template <
typename AAType>
bool contains()
const;
1424 : Mask(Mask), IDs(IDs) {}
1468 Function &AssumedCallee,
unsigned NumAssumedCallees)>
1570 template <
typename AAType>
1582 template <
typename AAType>
1585 DepClassTy DepClass,
bool ForceUpdate =
false,
1586 bool UpdateAfterInit =
true) {
1587 if (!shouldPropagateCallBaseContext(IRP))
1592 if (ForceUpdate && Phase == AttributorPhase::UPDATE)
1597 bool ShouldUpdateAA;
1606 auto &
AA = AAType::createForPosition(IRP, *
this);
1613 if (Phase == AttributorPhase::SEEDING && !shouldSeedAttribute(
AA)) {
1614 AA.getState().indicatePessimisticFixpoint();
1621 std::optional<TimeTraceScope> TimeScope;
1622 if (TimeTraceEnabled) {
1623 TimeScope.emplace(
"initialize", [&]() {
1624 return AA.getName().str() +
1625 std::to_string(
AA.getIRPosition().getPositionKind());
1629 ++InitializationChainLength;
1630 AA.initialize(*
this);
1631 --InitializationChainLength;
1634 if (!ShouldUpdateAA) {
1635 AA.getState().indicatePessimisticFixpoint();
1641 if (UpdateAfterInit) {
1642 AttributorPhase OldPhase = Phase;
1643 Phase = AttributorPhase::UPDATE;
1650 if (QueryingAA &&
AA.getState().isValidState())
1656 template <
typename AAType>
1664 template <
typename AAType>
1668 bool AllowInvalidState =
false) {
1669 static_assert(std::is_base_of<AbstractAttribute, AAType>::value,
1670 "Cannot query an attribute with a type not derived from "
1671 "'AbstractAttribute'!");
1678 AAType *
AA =
static_cast<AAType *
>(AAPtr);
1682 AA->getState().isValidState())
1687 if (!AllowInvalidState && !
AA->getState().isValidState())
1718 static_assert(std::is_base_of<AbstractAttribute, AAType>::value,
1719 "Cannot register an attribute with a type not derived from "
1720 "'AbstractAttribute'!");
1726 assert(!AAPtr &&
"Attribute already in map!");
1731 DG.SyntheticRoot.Deps.insert(
1750 unsigned NumAssumedCallees) {
1751 return Configuration.IndirectCalleeSpecializationCallback
1752 ? Configuration.IndirectCalleeSpecializationCallback(
1753 *
this,
AA, CB, Callee, NumAssumedCallees)
1764 return Functions.empty() || Functions.count(Fn);
1777 if (!AssociatedFn && AAType::requiresCalleeForCallBase())
1781 if (AAType::requiresNonAsmForCallBase() &&
1787 if (AAType::requiresCallersForArgOrFunction())
1793 if (!AAType::isValidIRPositionForUpdate(*
this, IRP))
1802 template <
typename AAType>
1804 if (!AAType::isValidIRPositionForInit(*
this, IRP))
1807 if (Configuration.Allowed && !Configuration.Allowed->contains<AAType>())
1817 if (InitializationChainLength > MaxInitializationChainLength)
1822 return !AAType::hasTrivialInitializer() || ShouldUpdateAA;
1842 return InfoCache.isExactOrInlineable(
F) ||
1843 (Configuration.IPOAmendableCB && Configuration.IPOAmendableCB(
F));
1859 return Phase == AttributorPhase::SEEDING ||
1860 Phase == AttributorPhase::UPDATE;
1869 "Only local linkage is assumed dead initially.");
1871 if (Configuration.DefaultInitializeLiveInternals)
1873 if (Configuration.InitializationCallback)
1874 Configuration.InitializationCallback(*
this,
F);
1880 Value *&
V = ToBeChangedUses[&U];
1881 if (
V && (
V->stripPointerCasts() == NV.stripPointerCasts() ||
1885 "Use was registered twice for replacement with different values!");
1894 bool ChangeDroppable =
true) {
1901 auto &Entry = ToBeChangedValues[&
V];
1907 "Value replacement was registered twice with different values!");
1908 Entry = {&NV, ChangeDroppable};
1915 ToBeChangedToUnreachableInsts.insert(
I);
1922 InvokeWithDeadSuccessor.insert(&
II);
1936 ManifestAddedBlocks.insert(&BB);
1941 if (Configuration.DeleteFns)
1942 ToBeDeletedFunctions.insert(&
F);
1958 bool IgnoreSubsumingPositions =
false,
1972 bool IgnoreSubsumingPositions =
false);
1986 bool ForceReplace =
false);
1994 template <Attribute::AttrKind AK,
typename AAType>
1996 bool SkipHasAttrCheck =
false);
1999 template <
typename DescTy>
2013 bool &UsedAssumedInformation);
2016 bool &UsedAssumedInformation) {
2024 bool &UsedAssumedInformation,
2030 bool &UsedAssumedInformation,
2033 UsedAssumedInformation, S);
2054 bool RecurseForSelectAndPHI =
true);
2065 SimplificationCallbacks[IRP].emplace_back(CB);
2070 return SimplificationCallbacks.count(IRP);
2077 std::function<std::optional<Constant *>(
2082 GlobalVariableSimplificationCallbacks[&GV].emplace_back(CB);
2087 return GlobalVariableSimplificationCallbacks.count(&GV);
2093 std::optional<Constant *>
2096 bool &UsedAssumedInformation) {
2097 assert(GlobalVariableSimplificationCallbacks.contains(&GV));
2098 for (
auto &CB : GlobalVariableSimplificationCallbacks.lookup(&GV)) {
2099 auto SimplifiedGV = CB(GV,
AA, UsedAssumedInformation);
2101 assert(SimplifiedGV.has_value() &&
"SimplifiedGV has not value");
2102 return *SimplifiedGV;
2111 VirtualUseCallbacks[&
V].emplace_back(CB);
2117 SimplificationCallbacks;
2123 GlobalVariableSimplificationCallbacks;
2126 VirtualUseCallbacks;
2133 bool &UsedAssumedInformation);
2140 bool &UsedAssumedInformation,
2141 bool CheckBBLivenessOnly =
false,
2150 bool &UsedAssumedInformation,
2151 bool CheckBBLivenessOnly =
false,
2153 bool CheckForDeadStore =
false);
2160 bool &UsedAssumedInformation,
2161 bool CheckBBLivenessOnly =
false,
2170 bool &UsedAssumedInformation,
2171 bool CheckBBLivenessOnly =
false,
2203 bool CheckBBLivenessOnly =
false,
2205 bool IgnoreDroppableUses =
true,
2220 template <
typename RemarkKind,
typename RemarkCallBack>
2222 RemarkCallBack &&RemarkCB)
const {
2223 if (!Configuration.OREGetter)
2227 auto &ORE = Configuration.OREGetter(
F);
2231 return RemarkCB(RemarkKind(Configuration.PassName, RemarkName,
I))
2232 <<
" [" << RemarkName <<
"]";
2236 return RemarkCB(RemarkKind(Configuration.PassName, RemarkName,
I));
2241 template <
typename RemarkKind,
typename RemarkCallBack>
2243 RemarkCallBack &&RemarkCB)
const {
2244 if (!Configuration.OREGetter)
2247 auto &ORE = Configuration.OREGetter(
F);
2251 return RemarkCB(RemarkKind(Configuration.PassName, RemarkName,
F))
2252 <<
" [" << RemarkName <<
"]";
2256 return RemarkCB(RemarkKind(Configuration.PassName, RemarkName,
F));
2265 struct ArgumentReplacementInfo {
2308 :
A(
A), ReplacedFn(*Arg.
getParent()), ReplacedArg(Arg),
2309 ReplacementTypes(ReplacementTypes),
2310 CalleeRepairCB(
std::
move(CalleeRepairCB)),
2311 ACSRepairCB(
std::
move(ACSRepairCB)) {}
2368 bool RequireAllCallSites,
2369 bool &UsedAssumedInformation);
2380 bool RequireAllCallSites,
2382 bool &UsedAssumedInformation,
2383 bool CheckPotentiallyDead =
false);
2393 bool RecurseForSelectAndPHI =
true);
2404 bool &UsedAssumedInformation,
2405 bool CheckBBLivenessOnly =
false,
2406 bool CheckPotentiallyDead =
false);
2415 bool &UsedAssumedInformation,
2416 bool CheckBBLivenessOnly =
false,
2417 bool CheckPotentiallyDead =
false);
2424 bool &UsedAssumedInformation,
2425 bool CheckBBLivenessOnly =
false,
2426 bool CheckPotentiallyDead =
false) {
2429 {(
unsigned)Instruction::Invoke, (
unsigned)Instruction::CallBr,
2431 UsedAssumedInformation, CheckBBLivenessOnly, CheckPotentiallyDead);
2442 bool &UsedAssumedInformation);
2478 bool Force =
false);
2504 return CGModifiedFunctions;
2510 return AttrModifiedFunctions;
2520 void runTillFixpoint();
2532 void identifyDeadInternalFunctions();
2540 void rememberDependences();
2559 using AAMapKeyTy = std::pair<const char *, IRPosition>;
2566 auto Pos =
reinterpret_cast<uintptr_t>(
static_cast<void *
>(IRP));
2571 DenseMap<AAMapKeyTy, AbstractAttribute *, AAMapKeyInfo> AAMap;
2578 ArgumentReplacementMap;
2581 SetVector<Function *> &Functions;
2584 InformationCache &InfoCache;
2591 SmallSetVector<Function *, 8> CGModifiedFunctions;
2595 SmallSetVector<Function *, 8> AttrModifiedFunctions;
2600 const AbstractAttribute *FromAA;
2601 const AbstractAttribute *ToAA;
2612 using DependenceVector = SmallVector<DepInfo, 8>;
2616 DenseSet<const Function *> VisitedFunctions;
2620 SmallMapVector<Use *, Value *, 32> ToBeChangedUses;
2624 SmallMapVector<Value *, PointerIntPair<Value *, 1, bool>, 32>
2628 SmallSetVector<WeakVH, 16> ToBeChangedToUnreachableInsts;
2631 SmallSetVector<WeakVH, 16> InvokeWithDeadSuccessor;
2635 enum class AttributorPhase {
2640 } Phase = AttributorPhase::SEEDING;
2643 unsigned InitializationChainLength = 0;
2644 const unsigned MaxInitializationChainLength;
2653 SmallPtrSet<BasicBlock *, 8> ManifestAddedBlocks;
2654 SmallSetVector<Function *, 8> ToBeDeletedFunctions;
2655 SmallSetVector<BasicBlock *, 8> ToBeDeletedBlocks;
2656 SmallSetVector<WeakVH, 8> ToBeDeletedInsts;
2661 SmallSetVector<AbstractAttribute *, 16> QueryAAsAwaitingUpdate;
2664 const AttributorConfig Configuration;
2667 friend AttributorCallGraph;
2725template <
typename base_ty, base_ty BestState, base_ty WorstState>
2775 return !(*
this == R);
2793 joinOR(R.getAssumed(), R.getKnown());
2797 joinAND(R.getAssumed(), R.getKnown());
2821template <
typename base_ty =
uint32_t, base_ty BestState = ~base_ty(0),
2822 base_ty WorstState = 0>
2832 return (this->
Known & BitsEncoding) == BitsEncoding;
2837 return (this->
Assumed & BitsEncoding) == BitsEncoding;
2844 this->
Known |= Bits;
2867 void handleNewAssumedValue(
base_t Value)
override {
2871 void joinOR(
base_t AssumedValue,
base_t KnownValue)
override {
2872 this->
Known |= KnownValue;
2873 this->
Assumed |= AssumedValue;
2875 void joinAND(
base_t AssumedValue,
base_t KnownValue)
override {
2876 this->
Known &= KnownValue;
2877 this->
Assumed &= AssumedValue;
2883template <
typename base_ty = uint32_t, base_ty BestState = ~base_ty(0),
2884 base_ty WorstState = 0>
2916 void handleNewAssumedValue(
base_t Value)
override {
2920 void joinOR(
base_t AssumedValue,
base_t KnownValue)
override {
2921 this->
Known = std::max(this->
Known, KnownValue);
2924 void joinAND(
base_t AssumedValue,
base_t KnownValue)
override {
2925 this->
Known = std::min(this->
Known, KnownValue);
2932template <
typename base_ty = u
int32_t>
2952 void handleNewAssumedValue(
base_t Value)
override {
2956 void joinOR(
base_t AssumedValue,
base_t KnownValue)
override {
2960 void joinAND(
base_t AssumedValue,
base_t KnownValue)
override {
2987 void handleNewAssumedValue(
base_t Value)
override {
2991 void handleNewKnownValue(
base_t Value)
override {
2995 void joinOR(
base_t AssumedValue,
base_t KnownValue)
override {
2996 Known |= KnownValue;
2999 void joinAND(
base_t AssumedValue,
base_t KnownValue)
override {
3000 Known &= KnownValue;
3027 return ConstantRange::getFull(
BitWidth);
3032 return ConstantRange::getEmpty(
BitWidth);
3123 : Universal(
false), Set(Assumptions) {}
3126 : Universal(Universal), Set(Assumptions) {}
3132 bool empty()
const {
return Set.empty() && !Universal; }
3137 bool IsUniversal = Universal;
3138 unsigned Size = Set.size();
3141 if (
RHS.isUniversal())
3150 Universal &=
RHS.isUniversal();
3151 return IsUniversal != Universal ||
Size != Set.size();
3157 bool IsUniversal = Universal;
3158 unsigned Size = Set.size();
3161 if (!
RHS.isUniversal() && !Universal)
3164 Universal |=
RHS.isUniversal();
3165 return IsUniversal != Universal ||
Size != Set.size();
3181 : Known(Known), Assumed(
true), IsAtFixedpoint(
false) {}
3188 IsAtFixedpoint =
true;
3194 IsAtFixedpoint =
true;
3207 return Assumed.getSet().contains(Elem) || Known.getSet().contains(Elem);
3213 bool IsUniversal = Assumed.isUniversal();
3214 unsigned SizeBefore = Assumed.getSet().size();
3218 Assumed.getIntersection(
RHS);
3219 Assumed.getUnion(Known);
3221 return SizeBefore != Assumed.getSet().size() ||
3222 IsUniversal != Assumed.isUniversal();
3234 SetContents Assumed;
3236 bool IsAtFixedpoint;
3258template <Attribute::AttrKind AK,
typename BaseType,
typename AAType>
3280 bool IgnoreSubsumingPositions =
false) {
3283 if (AAType::isImpliedByPoison() &&
3286 return A.hasAttr(IRP, {ImpliedAttributeKind}, IgnoreSubsumingPositions,
3287 ImpliedAttributeKind);
3295 if (DeducedAttrs.
empty())
3297 return A.manifestAttrs(this->getIRPosition(), DeducedAttrs);
3397 assert(AssociatedFn &&
"Function interface without a function?");
3406 return A.isFunctionIPOAmendable(*AssociatedFn);
3443 virtual void printWithDeps(
raw_ostream &OS)
const;
3501template <
typename base_ty, base_ty BestState, base_ty WorstState>
3509 const IntegerRangeState &State);
3539template <
typename StateType>
3541 auto Assumed = S.getAssumed();
3553 StateWrapper<BooleanState, AbstractAttribute>,
3573 return (
AA->getIdAddr() == &
ID);
3582 StateWrapper<BooleanState, AbstractAttribute>,
3588 bool IgnoreSubsumingPositions =
false) {
3590 assert(ImpliedAttributeKind == Attribute::NoSync);
3591 if (
A.hasAttr(IRP, {Attribute::NoSync}, IgnoreSubsumingPositions,
3599 if (!
F ||
F->isConvergent())
3603 A.getAttrs(IRP, {Attribute::Memory}, Attrs, IgnoreSubsumingPositions);
3607 ME &= Attr.getMemoryEffects();
3620 return IRAttribute::isValidIRPositionForInit(
A, IRP);
3640 bool ExecutedAligned);
3652 return (
AA->getIdAddr() == &
ID);
3662 StateWrapper<BooleanState, AbstractAttribute>,
3668 bool IgnoreSubsumingPositions =
false) {
3670 assert(ImpliedAttributeKind == Attribute::MustProgress);
3671 return A.hasAttr(IRP, {Attribute::MustProgress, Attribute::WillReturn},
3672 IgnoreSubsumingPositions, Attribute::MustProgress);
3692 return (
AA->getIdAddr() == &
ID);
3702 StateWrapper<BooleanState, AbstractAttribute>,
3715 return IRAttribute::isValidIRPositionForInit(
A, IRP);
3720 bool IgnoreSubsumingPositions =
false);
3738 return (
AA->getIdAddr() == &
ID);
3748 StateWrapper<BooleanState, AbstractAttribute>,
3768 return (
AA->getIdAddr() == &
ID);
3778 StateWrapper<BooleanState, AbstractAttribute>,
3784 bool IgnoreSubsumingPositions =
false) {
3786 assert(ImpliedAttributeKind == Attribute::WillReturn);
3788 IgnoreSubsumingPositions))
3793 Attribute::WillReturn));
3802 if (!
A.hasAttr(IRP, {Attribute::MustProgress}))
3806 A.getAttrs(IRP, {Attribute::Memory}, Attrs,
3811 ME &= Attr.getMemoryEffects();
3831 return (
AA->getIdAddr() == &
ID);
3840 :
public StateWrapper<BooleanState, AbstractAttribute> {
3861 return (
AA->getIdAddr() == &
ID);
3870 :
public StateWrapper<BooleanState, AbstractAttribute> {
3892 return (
AA->getIdAddr() == &
ID);
3902 StateWrapper<BooleanState, AbstractAttribute>,
3909 return IRAttribute::isValidIRPositionForInit(
A, IRP);
3914 bool IgnoreSubsumingPositions =
false);
3934 return (
AA->getIdAddr() == &
ID);
3944 StateWrapper<BooleanState, AbstractAttribute>,
3950 bool IgnoreSubsumingPositions =
false) {
3952 assert(ImpliedAttributeKind == Attribute::NoFree);
3954 IRP, {Attribute::ReadNone, Attribute::ReadOnly, Attribute::NoFree},
3955 IgnoreSubsumingPositions, Attribute::NoFree);
3962 return IRAttribute::isValidIRPositionForInit(
A, IRP);
3981 return (
AA->getIdAddr() == &
ID);
3991 StateWrapper<BooleanState, AbstractAttribute>,
4011 return (
AA->getIdAddr() == &
ID);
4020 :
public StateWrapper<BitIntegerState<uint8_t, 3, 0>, AbstractAttribute> {
4090 return (
AA->getIdAddr() == &
ID);
4108 DS.indicatePessimisticFixpoint();
4145 void computeKnownDerefBytesFromAccessedMap() {
4148 if (KnownBytes <
Access.first)
4150 KnownBytes = std::max(KnownBytes,
Access.first + (int64_t)
Access.second);
4179 void takeKnownDerefBytesMaximum(
uint64_t Bytes) {
4183 computeKnownDerefBytesFromAccessedMap();
4187 void takeAssumedDerefBytesMinimum(
uint64_t Bytes) {
4194 AccessedBytes = std::max(AccessedBytes,
Size);
4197 computeKnownDerefBytesFromAccessedMap();
4203 this->GlobalState ==
R.GlobalState;
4207 bool operator!=(
const DerefState &R)
const {
return !(*
this ==
R); }
4212 GlobalState ^=
R.GlobalState;
4219 GlobalState +=
R.GlobalState;
4226 GlobalState &=
R.GlobalState;
4233 GlobalState |=
R.GlobalState;
4241 StateWrapper<DerefState, AbstractAttribute>,
4242 AADereferenceable> {
4248 return IRAttribute::isValidIRPositionForInit(
A, IRP);
4280 return (
AA->getIdAddr() == &
ID);
4292 StateWrapper<AAAlignmentStateType, AbstractAttribute>,
4299 return IRAttribute::isValidIRPositionForInit(
A, IRP);
4314 return (
AA->getIdAddr() == &
ID);
4350 return (
AA->getIdAddr() == &
ID);
4360 Attribute::Captures,
4361 StateWrapper<BitIntegerState<uint16_t, 7, 0>, AbstractAttribute>,
4367 bool IgnoreSubsumingPositions =
false);
4378 return IRAttribute::isValidIRPositionForInit(
A, IRP);
4428 return (
AA->getIdAddr() == &
ID);
4449 DS.indicatePessimisticFixpoint();
4466 return BS.indicatePessimisticFixpoint();
4470 return BS.indicateOptimisticFixpoint();
4507 :
public StateWrapper<ValueSimplifyStateType, AbstractAttribute, Type *> {
4523 return (
AA->getIdAddr() == &
ID);
4535 virtual std::optional<Value *>
4536 getAssumedSimplifiedValue(
Attributor &
A)
const = 0;
4562 return (
AA->getIdAddr() == &
ID);
4580 :
public StateWrapper<BooleanState, AbstractAttribute> {
4611 return (
AA->getIdAddr() == &
ID);
4623 StateWrapper<BitIntegerState<uint8_t, 3>, AbstractAttribute>,
4632 return IRAttribute::isValidIRPositionForInit(
A, IRP);
4681 return (
AA->getIdAddr() == &
ID);
4693 StateWrapper<BitIntegerState<uint32_t, 511>, AbstractAttribute>,
4707 return IRAttribute::isValidIRPositionForInit(
A, IRP);
4860 return (
AA->getIdAddr() == &
ID);
4869 :
public StateWrapper<IntegerRangeState, AbstractAttribute, uint32_t> {
4897 std::optional<Constant *>
4906 return std::nullopt;
4917 return (
AA->getIdAddr() == &
ID);
4938 : IsValidState(IsValid), UndefIsContained(
false) {}
4941 : IsValidState(IsValid), UndefIsContained(
false),
4942 MaxPotentialValues(MaxPotentialValues) {}
4949 return IsValidState.indicatePessimisticFixpoint();
4953 return IsValidState.indicateOptimisticFixpoint();
4970 return UndefIsContained;
4980 return Set ==
RHS.getAssumedSet();
5004 IsValidState ^= PVS.IsValidState;
5010 IsValidState &= PVS.IsValidState;
5024 void checkAndInvalidate() {
5025 if (Set.
size() >= MaxPotentialValues)
5033 void reduceUndefValue() { UndefIsContained = UndefIsContained & Set.
empty(); }
5036 void insert(
const MemberTy &
C) {
5040 checkAndInvalidate();
5049 if (!
R.isValidState()) {
5053 Set.insert_range(
R.Set);
5054 UndefIsContained |=
R.undefIsContained();
5055 checkAndInvalidate();
5059 void unionWithUndef() {
5060 UndefIsContained =
true;
5065 BooleanState IsValidState;
5071 bool UndefIsContained;
5074 unsigned MaxPotentialValues = std::numeric_limits<unsigned>::max();
5095 if (Caller == Callee)
5112 Callee.ModeF32 =
unionAssumed(Callee.ModeF32, Caller.ModeF32);
5188 :
public StateWrapper<PotentialConstantIntValuesState, AbstractAttribute,
5212 std::optional<Constant *>
5225 return std::nullopt;
5237 if (It.countTrailingZeros() < TrailingZeros)
5238 TrailingZeros = It.countTrailingZeros();
5242 return TrailingZeros;
5251 return (
AA->getIdAddr() == &
ID);
5259 :
public StateWrapper<PotentialLLVMValuesState, AbstractAttribute> {
5285 return (
AA->getIdAddr() == &
ID);
5292 virtual bool getAssumedSimplifiedValues(
5302 StateWrapper<BooleanState, AbstractAttribute>,
5312 bool IgnoreSubsumingPositions =
false);
5330 return (
AA->getIdAddr() == &
ID);
5339 Attribute::NoFPClass,
5340 StateWrapper<BitIntegerState<uint32_t, fcAllFlags, fcNone>,
5371 return (
AA->getIdAddr() == &
ID);
5384class AACallEdgeIterator
5386 SetVector<Function *>::iterator> {
5396 friend AttributorCallGraph;
5458 return (
AA->getIdAddr() == &
ID);
5494 return Node->optimisticEdgesBegin();
5498 return Node->optimisticEdgesEnd();
5512 return G->optimisticEdgesBegin();
5516 return G->optimisticEdgesEnd();
5538 :
public StateWrapper<BooleanState, AbstractAttribute> {
5593 virtual std::pair<ExecutionDomainTy, ExecutionDomainTy>
5604 return (
AA->getIdAddr() == &
ID);
5613 :
public StateWrapper<BooleanState, AbstractAttribute> {
5621 if (!Scope || Scope->isDeclaration())
5642 return (
AA->getIdAddr() == &
ID);
5673 return (
AA->getIdAddr() == &
ID);
5751 Offsets = std::move(NewOffsets);
5775 Ranges.reserve(Offsets.size());
5776 for (
unsigned i = 0, e = Offsets.size(); i != e; ++i) {
5777 assert(((i + 1 == e) || Offsets[i] < Offsets[i + 1]) &&
5778 "Expected strictly ascending offsets.");
5793 "Ensure the last element is the greatest.");
5800 std::set_difference(L.begin(), L.end(), R.begin(), R.end(),
5815 if (
RHS.isUnknown()) {
5826 auto LPos =
Ranges.begin();
5827 for (
auto &R :
RHS.Ranges) {
5828 auto Result =
insert(LPos, R);
5831 LPos = Result.first;
5845 return std::make_pair(
Ranges.begin(),
false);
5846 if (R.offsetOrSizeAreUnknown()) {
5852 if (LB ==
Ranges.end() || LB->Offset != R.Offset)
5853 return std::make_pair(
Ranges.insert(LB, R),
true);
5856 if (LB->offsetOrSizeAreUnknown())
5858 return std::make_pair(LB,
Changed);
5864 "Cannot increment if the offset is not yet computed!");
5876 if (
Ranges.front().offsetOrSizeAreUnknown()) {
5877 assert(
Ranges.size() == 1 &&
"Unknown is a singleton range.");
5898 : LocalI(
I), RemoteI(
I), Content(Content), Ranges(
Offset,
Size),
5899 Kind(Kind), Ty(Ty) {
5904 : LocalI(LocalI), RemoteI(RemoteI), Content(Content), Ranges(Ranges),
5906 if (Ranges.size() > 1) {
5907 Kind = AccessKind(Kind | AK_MAY);
5908 Kind = AccessKind(Kind & ~AK_MUST);
5915 : LocalI(LocalI), RemoteI(RemoteI), Content(Content),
5923 return LocalI == R.LocalI && RemoteI == R.RemoteI && Ranges == R.Ranges &&
5924 Content == R.Content && Kind == R.Kind;
5929 assert(RemoteI == R.RemoteI &&
"Expected same instruction!");
5930 assert(LocalI == R.LocalI &&
"Expected same instruction!");
5936 Ranges.merge(R.Ranges);
5944 if ((Kind &
AK_MAY) || Ranges.size() > 1) {
5954 "Expect must or may access, not both.");
5956 "Expect assumption access or write access, never both.");
5958 "Cannot be a must access if there are multiple ranges.");
5977 bool MustAccess = Kind &
AK_MUST;
5978 assert((!MustAccess || Ranges.size() < 2) &&
5979 "Cannot be a must access if there are multiple ranges.");
5984 bool MayAccess = Kind &
AK_MAY;
5985 assert((MayAccess || Ranges.size() < 2) &&
5986 "Cannot be a must access if there are multiple ranges.");
6002 return Content.has_value() && !*Content;
6011 "Value needs to be determined before accessing it.");
6035 std::optional<Value *> Content;
6082 bool FindInterferingWrites,
bool FindInterferingReads,
6089 return (
AA->getIdAddr() == &
ID);
6100 :
public StateWrapper<SetState<StringRef>, AbstractAttribute,
6101 DenseSet<StringRef>> {
6107 :
Base(IRP, Known) {}
6123 return (
AA->getIdAddr() == &
ID);
6153 return (
AA->getIdAddr() == &
ID);
6199 return (
AA->getIdAddr() == &
ID);
6235 return (
AA->getIdAddr() == &
ID);
6248 :
public StateWrapper<BooleanState, AbstractAttribute> {
6272 return (
AA->getIdAddr() == &
ID);
6306 return (
AA->getIdAddr() == &
ID);
6310 std::make_optional<TypeSize>(-1,
true);
6317 :
public StateWrapper<BooleanState, AbstractAttribute> {
6327 return GV->hasLocalLinkage();
6344 return (
AA->getIdAddr() == &
ID);
6353 :
public StateWrapper<BooleanState, AbstractAttribute> {
6361 return CB->getOpcode() == Instruction::Call && CB->isIndirectCall() &&
6362 !CB->isMustTailCall();
6382 return (
AA->getIdAddr() == &
ID);
6392 :
public StateWrapper<DenormalFPMathState, AbstractAttribute> {
6408 return (
AA->getIdAddr() == &
ID);
6429template <Attribute::AttrKind AK,
typename AAType = AbstractAttribute>
6432 bool IgnoreSubsumingPositions =
false,
6433 const AAType **AAPtr =
nullptr) {
6436#define CASE(ATTRNAME, AANAME, ...) \
6437 case Attribute::ATTRNAME: { \
6438 if (AANAME::isImpliedByIR(A, IRP, AK, IgnoreSubsumingPositions)) \
6439 return IsKnown = true; \
6442 const auto *AA = A.getAAFor<AANAME>(*QueryingAA, IRP, DepClass); \
6444 *AAPtr = reinterpret_cast<const AAType *>(AA); \
6445 if (!AA || !AA->isAssumed(__VA_ARGS__)) \
6447 IsKnown = AA->isKnown(__VA_ARGS__); \
6466 llvm_unreachable(
"hasAssumedIRAttr not available for this attribute kind");
6487template <
typename... AATypes>
6489 return sizeof...(AATypes);
6493static_assert(
NumAAKinds <= 64,
"Too many kinds for the mask");
6499template <
typename AAType,
typename... AATypes>
6501 constexpr bool Matches[] = {std::is_same_v<AAType, AATypes>...};
6502 for (
size_t I = 0;
I !=
sizeof...(AATypes); ++
I) {
6506 return sizeof...(AATypes);
6516template <
typename... AATypes>
6527 if constexpr (KindMask != 0)
6528 return Mask & KindMask;
const TargetLowering & TLI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This file defines the BumpPtrAllocator interface.
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
This file contains the simple types necessary to represent the attributes associated with functions a...
#define CASE(ATTRNAME, AANAME,...)
static const Function * getParent(const Value *V)
block Block Frequency Analysis
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
This header provides classes for managing passes over SCCs of the call graph.
This file provides interfaces used to manipulate a call graph, regardless if it is a "old style" Call...
This file contains the declarations for the subclasses of Constant, which represent the different fla...
This file defines the DenseSet and SmallDenseSet classes.
This file defines the little GraphTraits<X> template class that should be specialized by classes that...
Module.h This file contains the declarations for the Module class.
This header defines various interfaces for pass management in LLVM.
This file implements a coalescing interval map for small objects.
Implements a lazy call graph analysis and related passes for the new pass manager.
This file implements a map that provides insertion order iteration.
This file provides utility analysis objects describing memory locations.
Contains a collection of routines for determining if a given instruction is guaranteed to execute if ...
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
uint64_t IntrinsicInst * II
Func getContext().diagnose(DiagnosticInfoUnsupported(Func
BaseType
A given derived pointer can have multiple base pointers through phi/selects.
This file defines generic set operations that may be used on set's of different types,...
This file implements a set that has insertion order iteration characteristics.
This file defines the SmallSet class.
static SymbolRef::Type getType(const Symbol *Sym)
static unsigned getBitWidth(Type *Ty, const DataLayout &DL)
Returns the bitwidth of the given scalar or pointer type.
An Iterator for call edges, creates AACallEdges attributes in a lazy way.
LLVM_ABI AACallGraphNode * operator*() const
bool contains() const
Return true if abstract attributes of type AAType are in the set.
static constexpr AAKindSet get()
Return the set of the kinds of abstract attributes of types AATypes.
Class for arbitrary precision integers.
CallBase * getInstruction() const
Return the underlying instruction.
int getCallArgOperandNo(Argument &Arg) const
Return the operand index of the underlying instruction associated with Arg.
unsigned getNumArgOperands() const
Return the number of parameters of the callee.
This class represents an incoming formal argument to a Function.
const Function * getParent() const
Represent a constant reference to an array (0 or more elements consecutively in memory),...
This represents the llvm.assume intrinsic.
This class stores enough information to efficiently remove some attributes from an existing AttrBuild...
This class holds the attributes for a particular argument, parameter, function, or return value.
Functions, function parameters, and return types can have attributes to indicate how they should be t...
static LLVM_ABI Attribute get(LLVMContext &Context, AttrKind Kind, uint64_t Val=0)
Return a uniquified Attribute object.
static bool isEnumAttrKind(AttrKind Kind)
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results,...
@ None
No attributes have been set.
LLVM Basic Block Representation.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
const Use & getArgOperandUse(unsigned i) const
Wrappers for getting the Use of a call argument.
Wrapper to unify "old style" CallGraph and "new style" LazyCallGraph.
This class represents a range of values.
const APInt * getSingleElement() const
If this set contains a single element, return it, otherwise return null.
LLVM_ABI bool isEmptySet() const
Return true if this set contains no members.
This is an important base class in LLVM.
A parsed version of the target data layout string in and methods for querying it.
Implements a dense probed hash-table based set.
Analysis pass which computes a DominatorTree.
An instruction for ordering other memory operations.
AttributeList getAttributes() const
Return the attribute list for this Function.
void setAttributes(AttributeList Attrs)
Set the attribute list for this Function.
Type * getReturnType() const
Returns the type of the ret val.
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
bool hasLocalLinkage() const
typename Sizer::Allocator Allocator
This is an important class for using LLVM in a threaded context.
An SCC of the call graph.
A lazily constructed view of the call graph of a module.
An instruction for reading from memory.
Analysis pass that exposes the LoopInfo for a function.
bool onlyReadsMemory() const
Whether this function only (at most) reads memory.
static MemoryEffectsBase unknown()
A Module instance is used to store all the information related to an LLVM module.
Pass interface - Implemented by all 'passes'.
PointerIntPair - This class implements a pair of a pointer and small integer.
PointerTy getPointer() const
void setFromOpaqueValue(void *Val) &
Analysis pass which computes a PostDominatorTree.
A set of analyses that are preserved following a run of a transformation pass.
A vector that has set insertion semantics.
size_type size() const
Determine the number of elements in the SetVector.
typename vector_type::const_iterator iterator
bool empty() const
Determine if the SetVector is empty or not.
iterator begin()
Get an iterator to the beginning of the SetVector.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
iterator find(ConstPtrType Ptr) const
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
A SetVector that performs no allocations if smaller than a certain size.
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
SmallSetIterator< int64_t, N, std::less< int64_t > > const_iterator
std::pair< const_iterator, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An instruction for storing to memory.
Represent a constant reference to a string, i.e.
std::string str() const
Get the contents as an std::string.
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
LLVM_ABI SubsumingPositionIterator(const IRPosition &IRP)
Analysis pass providing the TargetLibraryInfo.
Provides information about what library functions are available for the current target.
The instances of the Type class are immutable: once they are created, they are never changed.
bool isPointerTy() const
True if this is an instance of PointerType.
bool isPtrOrPtrVectorTy() const
Return true if this is a pointer type or a vector of pointer types.
bool isIntegerTy() const
True if this is an instance of IntegerType.
static LLVM_ABI UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
A Use represents the edge between a Value definition and its users.
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
LLVMContext & getContext() const
All values hold a context through their type.
LLVM_ABI const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
An efficient, type-erasing, non-owning reference to a callable.
iterator_adaptor_base()=default
A range adaptor for a pair of iterators.
This class implements an extremely fast bulk output stream that can only output to a stream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Abstract Attribute helper functions.
LLVM_ABI bool isAssumedReadNone(Attributor &A, const IRPosition &IRP, const AbstractAttribute &QueryingAA, bool &IsKnown)
Return true if IRP is readnone.
LLVM_ABI bool isAssumedReadOnly(Attributor &A, const IRPosition &IRP, const AbstractAttribute &QueryingAA, bool &IsKnown)
Return true if IRP is readonly.
raw_ostream & operator<<(raw_ostream &OS, const RangeTy &R)
LLVM_ABI 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.
LLVM_ABI 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,...
LLVM_ABI bool isAssumedThreadLocalObject(Attributor &A, Value &Obj, const AbstractAttribute &QueryingAA)
Return true if Obj is assumed to be a thread local object.
LLVM_ABI bool isGPUConstantAddressSpace(const Module &M, unsigned AS)
Check if the given address space AS corresponds to a GPU constant address space for the target triple...
LLVM_ABI 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 di...
LLVM_ABI 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.
LLVM_ABI bool isGPUSharedAddressSpace(const Module &M, unsigned AS)
Check if the given address space AS corresponds to a GPU shared address space for the target triple i...
bool operator!=(const RangeTy &A, const RangeTy &B)
LLVM_ABI bool isGPULocalAddressSpace(const Module &M, unsigned AS)
Check if the given address space AS corresponds to a GPU local/private address space for the target t...
LLVM_ABI bool isPotentiallyAffectedByBarrier(Attributor &A, const Instruction &I, const AbstractAttribute &QueryingAA)
Return true if I is potentially affected by a barrier.
SmallPtrSet< Instruction *, 4 > InstExclusionSetTy
LLVM_ABI bool isGPU(const Module &M)
Return true iff M target a GPU (and we can use GPU AS reasoning).
LLVM_ABI 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 operator==(const RangeTy &A, const RangeTy &B)
ValueScope
Flags to distinguish intra-procedural queries from potentially inter-procedural queries.
LLVM_ABI 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.
LLVM_ABI 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 Exclus...
LLVM_ABI bool isNoSyncInst(Attributor &A, const Instruction &I, const AbstractAttribute &QueryingAA)
Return true if I is a nosync instruction.
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.
LLVM_ABI 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.
LLVM_ABI Value * getWithType(Value &V, Type &Ty)
Try to convert V to type Ty without introducing new instructions.
constexpr E & operator^=(E &LHS, E RHS)
constexpr size_t NumAAKinds
constexpr const char * AAKindSetIDs[]
The storage of the IDs of an AAKindSet.
AAKindList< AANoUnwind, AANoSync, AAMustProgress, AANonNull, AANoRecurse, AAWillReturn, AAUndefinedBehavior, AAIntraFnReachability, AANoAlias, AANoFree, AANoReturn, AAIsDead, AADereferenceable, AAAlign, AAInstanceInfo, AANoCapture, AAValueSimplify, AAHeapToStack, AAPrivatizablePtr, AAMemoryBehavior, AAMemoryLocation, AAValueConstantRange, AAPotentialConstantValues, AAPotentialValues, AANoUndef, AANoFPClass, AACallEdges, AAExecutionDomain, AAInterFnReachability, AANonConvergent, AAPointerInfo, AAAssumptionInfo, AAUnderlyingObjects, AAInvariantLoadPointer, AAAddressSpace, AANoAliasAddrSpace, AAAllocationInfo, AAGlobalValueInfo, AAIndirectCallInfo, AADenormalFPMath > AAKinds
The abstract attributes declared here, by their bit in AAKindSet.
constexpr size_t getAAKindBit(AAKindList< AATypes... >)
Return the bit of AAType in AAKindSet, or the number of kinds if it has none.
constexpr uint64_t getAAKindMask()
Return the bit of AAType in the mask of AAKindSet, or 0 if it has none.
unsigned combineHashValue(unsigned a, unsigned b)
Simplistic combination of 32-bit hash values into 32-bit hash values.
constexpr size_t getNumAAKinds(AAKindList< AATypes... >)
NodeAddr< UseNode * > Use
This is an optimization pass for GlobalISel generic memory operations.
bool isEqual(const GCNRPTracker::LiveRegSet &S1, const GCNRPTracker::LiveRegSet &S2)
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
RelativeUniformCounterPtr Values
APInt operator&(APInt a, const APInt &b)
@ Known
Known to have no common set bits.
void set_intersect(S1Ty &S1, const S2Ty &S2)
set_intersect(A, B) - Compute A := A ^ B Identical to set_intersection, except that it works on set<>...
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
bool operator!=(uint64_t V1, const APInt &V2)
auto dyn_cast_if_present(const Y &Val)
dyn_cast_if_present<X> - Functionally identical to dyn_cast, except that a null (or none in the case ...
LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt & operator+=(DynamicAPInt &A, int64_t B)
bool set_is_subset(const S1Ty &S1, const S2Ty &S2)
set_is_subset(A, B) - Return true iff A in B
auto cast_or_null(const Y &Val)
MemoryEffectsBase< IRMemLocation > MemoryEffects
Summary of how a function affects memory in the program.
bool isa_and_nonnull(const Y &Val)
bool operator==(const AddressRangeValuePair &LHS, const AddressRangeValuePair &RHS)
AttributorRunOption
Run options, used by the pass manager.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
AnalysisManager< LazyCallGraph::SCC, LazyCallGraph & > CGSCCAnalysisManager
The CGSCC analysis manager.
LLVM_ABI bool canSimplifyInvokeNoUnwind(const Function *F)
LLVM_ABI bool shouldCreateAbstractAttribute()
Check the debug counter used to limit the number of AAs created.
DenseMap< RetainedKnowledgeKey, Assume2KnowledgeMap > RetainedKnowledgeMap
PotentialValuesState< std::pair< AA::ValueAndContext, AA::ValueScope > > PotentialLLVMValuesState
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
FPClassTest
Floating-point class tests, supported by 'is_fpclass' intrinsic.
bool timeTraceProfilerEnabled()
Is the time trace profiler enabled, i.e. initialized?
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool set_union(S1Ty &S1, const S2Ty &S2)
set_union(A, B) - Compute A := A u B, return whether A changed.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
@ Success
The lock was released successfully.
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
iterator_range(Container &&) -> iterator_range< llvm::detail::IterOfRange< Container > >
PotentialValuesState< APInt > PotentialConstantIntValuesState
bool operator&=(SparseBitVector< ElementSize > *LHS, const SparseBitVector< ElementSize > &RHS)
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
ChangeStatus clampStateAndIndicateChange(StateType &S, const StateType &R)
Helper function to clamp a state S of type StateType with the information in R and indicate/return if...
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
iterator_range< pointer_iterator< WrappedIteratorT > > make_pointer_range(RangeT &&Range)
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
bool operator|=(SparseBitVector< ElementSize > &LHS, const SparseBitVector< ElementSize > *RHS)
@ OPTIONAL
The target may be valid if the source is not.
@ NONE
Do not track a dependence between source and target.
@ REQUIRED
The target cannot be valid if the source is not.
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
APInt operator|(APInt a, const APInt &b)
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
IncIntegerState< uint64_t, Value::MaximumAlignment, 1 > AAAlignmentStateType
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
Implement std::hash so that hash_code can be used in STL containers.
An abstract interface for address space information.
static LLVM_ABI AAAddressSpace & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
const char * getIdAddr() const override
This function should return the address of the ID of the AbstractAttribute.
static bool requiresCallersForArgOrFunction()
StringRef getName() const override
This function should return the name of the AbstractAttribute.
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAAssumptionInfo.
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP)
virtual uint32_t getAddressSpace() const =0
Return the address space of the associated value.
static LLVM_ABI const char ID
Unique ID (due to the unique address)
AAAddressSpace(const IRPosition &IRP, Attributor &A)
static const uint32_t InvalidAddressSpace
An abstract interface for all align attributes.
AAAlign(const IRPosition &IRP, Attributor &A)
static LLVM_ABI AAAlign & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
static LLVM_ABI const char ID
Unique ID (due to the unique address)
const char * getIdAddr() const override
This function should return the address of the ID of the AbstractAttribute.
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP)
Align getAssumedAlign() const
Return assumed alignment.
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAAlign.
Align getKnownAlign() const
Return known alignment.
StringRef getName() const override
This function should return the name of the AbstractAttribute.
static LLVM_ABI const char ID
virtual std::optional< TypeSize > getAllocatedSize() const =0
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP)
const char * getIdAddr() const override
This function should return the address of the ID of the AbstractAttribute.
static LLVM_ABI AAAllocationInfo & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
StringRef getName() const override
This function should return the name of the AbstractAttribute.
AAAllocationInfo(const IRPosition &IRP, Attributor &A)
static constexpr const std::optional< TypeSize > HasNoAllocationSize
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAAllocationInfo.
An abstract attribute for getting assumption information.
AAAssumptionInfo(const IRPosition &IRP, Attributor &A, const DenseSet< StringRef > &Known)
static LLVM_ABI const char ID
Unique ID (due to the unique address)
StringRef getName() const override
This function should return the name of the AbstractAttribute.
static LLVM_ABI AAAssumptionInfo & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
StateWrapper< SetState< StringRef >, AbstractAttribute, DenseSet< StringRef > > Base
const char * getIdAddr() const override
This function should return the address of the ID of the AbstractAttribute.
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAAssumptionInfo.
virtual bool hasAssumption(const StringRef Assumption) const =0
Returns true if the assumption set contains the assumption Assumption.
An abstract state for querying live call edges.
AACallEdges(const IRPosition &IRP, Attributor &A)
virtual const SetVector< Function * > & getOptimisticEdges() const =0
Get the optimistic edges.
static bool requiresNonAsmForCallBase()
StateWrapper< BooleanState, AbstractAttribute > Base
AACallEdgeIterator optimisticEdgesBegin() const override
Iterator for exploring the call graph.
virtual bool hasUnknownCallee() const =0
Is there any call with a unknown callee.
static LLVM_ABI const char ID
Unique ID (due to the unique address)
StringRef getName() const override
This function should return the name of the AbstractAttribute.
virtual bool hasNonAsmUnknownCallee() const =0
Is there any call with a unknown callee, excluding any inline asm.
AACallEdgeIterator optimisticEdgesEnd() const override
Iterator for exploring the call graph.
static LLVM_ABI AACallEdges & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AACallEdges.
const char * getIdAddr() const override
This function should return the address of the ID of the AbstractAttribute.
iterator_range< AACallEdgeIterator > optimisticEdgesRange() const
Iterator range for exploring the call graph.
virtual AACallEdgeIterator optimisticEdgesBegin() const =0
AACallGraphNode(Attributor &A)
virtual AACallEdgeIterator optimisticEdgesEnd() const =0
virtual ~AACallGraphNode()=default
Attributor & A
Reference to Attributor needed for GraphTraits implementation.
An abstract Attribute for specializing "dynamic" components of denormal_fpenv to a known denormal mod...
const char * getIdAddr() const override
This function should return the address of the ID of the AbstractAttribute.
StringRef getName() const override
This function should return the name of the AbstractAttribute.
AADenormalFPMath(const IRPosition &IRP, Attributor &A)
static LLVM_ABI const char ID
Unique ID (due to the unique address)
StateWrapper< DenormalFPMathState, AbstractAttribute > Base
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AADenormalFPMath.
static LLVM_ABI AADenormalFPMath & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
static AbstractAttribute * DepGetValAA(const DepTy &DT)
mapped_iterator< DepSetTy::iterator, decltype(&DepGetVal)> iterator
mapped_iterator< DepSetTy::iterator, decltype(&DepGetValAA)> aaiterator
virtual ~AADepGraphNode()=default
SmallSetVector< DepTy, 2 > DepSetTy
static AADepGraphNode * DepGetVal(const DepTy &DT)
DepSetTy Deps
Set of dependency graph nodes which should be updated if this one is updated.
virtual void print(Attributor *, raw_ostream &OS) const
PointerIntPair< AADepGraphNode *, 1 > DepTy
void print(raw_ostream &OS) const
The data structure for the dependency graph.
mapped_iterator< AADepGraphNode::DepSetTy::iterator, decltype(&DepGetVal)> iterator
LLVM_ABI void viewGraph()
AADepGraphNode SyntheticRoot
There is no root node for the dependency graph.
LLVM_ABI void print()
Print dependency graph.
static AADepGraphNode * DepGetVal(const DepTy &DT)
LLVM_ABI void dumpGraph(StringRef DotFileNamePrefix)
Dump graph to file.
AADepGraphNode * GetEntryNode()
AADepGraphNode::DepTy DepTy
An abstract interface for all dereferenceable attribute.
uint32_t getKnownDereferenceableBytes() const
Return known dereferenceable bytes.
bool isAssumedGlobal() const
Return true if we assume that underlying value is dereferenceable(_or_null) globally.
bool isKnownGlobal() const
Return true if we know that underlying value is dereferenceable(_or_null) globally.
AADereferenceable(const IRPosition &IRP, Attributor &A)
uint32_t getAssumedDereferenceableBytes() const
Return assumed dereferenceable bytes.
StringRef getName() const override
This function should return the name of the AbstractAttribute.
static LLVM_ABI const char ID
Unique ID (due to the unique address)
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AADereferenceable.
const char * getIdAddr() const override
This function should return the address of the ID of the AbstractAttribute.
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP)
static LLVM_ABI AADereferenceable & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
Summary about the execution domain of a block or instruction.
bool IsExecutedByInitialThreadOnly
BarriersSetTy AlignedBarriers
void addAssumeInst(Attributor &A, AssumeInst &AI)
SmallPtrSet< AssumeInst *, 4 > AssumesSetTy
bool EncounteredNonLocalSideEffect
void addAlignedBarrier(Attributor &A, CallBase &CB)
SmallPtrSet< CallBase *, 2 > BarriersSetTy
void clearAssumeInstAndAlignedBarriers()
bool IsReachedFromAlignedBarrierOnly
bool IsReachingAlignedBarrierOnly
AssumesSetTy EncounteredAssumes
virtual bool isExecutedByInitialThreadOnly(const BasicBlock &) const =0
Check if a basic block is executed only by the initial thread.
StateWrapper< BooleanState, AbstractAttribute > Base
bool isExecutedByInitialThreadOnly(const Instruction &I) const
Check if an instruction is executed only by the initial thread.
static LLVM_ABI AAExecutionDomain & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAExecutionDomain.
const char * getIdAddr() const override
This function should return the address of the ID of the AbstractAttribute.
virtual ExecutionDomainTy getFunctionExecutionDomain() const =0
virtual ExecutionDomainTy getExecutionDomain(const BasicBlock &) const =0
virtual bool isExecutedInAlignedRegion(Attributor &A, const Instruction &I) const =0
Check if the instruction I is executed in an aligned region, that is, the synchronizing effects befor...
AAExecutionDomain(const IRPosition &IRP, Attributor &A)
virtual bool isNoOpFence(const FenceInst &FI) const =0
Helper function to determine if FI is a no-op given the information about its execution from ExecDoma...
StringRef getName() const override
This function should return the name of the AbstractAttribute.
virtual std::pair< ExecutionDomainTy, ExecutionDomainTy > getExecutionDomain(const CallBase &CB) const =0
Return the execution domain with which the call CB is entered and the one with which it is left.
static LLVM_ABI const char ID
Unique ID (due to the unique address)
An abstract interface for llvm::GlobalValue information interference.
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAGlobalValueInfo.
AAGlobalValueInfo(const IRPosition &IRP, Attributor &A)
StringRef getName() const override
This function should return the name of the AbstractAttribute.
static LLVM_ABI AAGlobalValueInfo & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP)
const char * getIdAddr() const override
This function should return the address of the ID of the AbstractAttribute.
static LLVM_ABI const char ID
Unique ID (due to the unique address)
virtual bool isPotentialUse(const Use &U) const =0
Return true iff U is a potential use of the associated global value.
StringRef getName() const override
This function should return the name of the AbstractAttribute.
StateWrapper< BooleanState, AbstractAttribute > Base
const char * getIdAddr() const override
This function should return the address of the ID of the AbstractAttribute.
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAHeapToStack.
virtual bool isAssumedHeapToStack(const CallBase &CB) const =0
Returns true if HeapToStack conversion is assumed to be possible.
virtual bool isAssumedHeapToStackRemovedFree(CallBase &CB) const =0
Returns true if HeapToStack conversion is assumed and the CB is a callsite to a free operation to be ...
static LLVM_ABI const char ID
Unique ID (due to the unique address)
static LLVM_ABI AAHeapToStack & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
AAHeapToStack(const IRPosition &IRP, Attributor &A)
An abstract interface for indirect call information interference.
StringRef getName() const override
This function should return the name of the AbstractAttribute.
virtual bool foreachCallee(function_ref< bool(Function *)> CB) const =0
Call \CB on each potential callee value and return true if all were known and CB returned true on all...
AAIndirectCallInfo(const IRPosition &IRP, Attributor &A)
const char * getIdAddr() const override
This function should return the address of the ID of the AbstractAttribute.
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAIndirectCallInfo This function should ret...
static LLVM_ABI const char ID
Unique ID (due to the unique address)
static LLVM_ABI AAIndirectCallInfo & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP)
An abstract interface to track if a value leaves it's defining function instance.
static LLVM_ABI const char ID
Unique ID (due to the unique address)
StringRef getName() const override
This function should return the name of the AbstractAttribute.
AAInstanceInfo(const IRPosition &IRP, Attributor &A)
bool isAssumedUniqueForAnalysis() const
Return true if we assume that the underlying value is unique in its scope wrt.
static LLVM_ABI AAInstanceInfo & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAInstanceInfo.
const char * getIdAddr() const override
This function should return the address of the ID of the AbstractAttribute.
An abstract Attribute for computing reachability between functions.
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AACallEdges.
static LLVM_ABI AAInterFnReachability & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
static LLVM_ABI const char ID
Unique ID (due to the unique address)
const char * getIdAddr() const override
This function should return the address of the ID of the AbstractAttribute.
bool canReach(Attributor &A, const Function &Fn) const
If the function represented by this possition can reach Fn.
StringRef getName() const override
This function should return the name of the AbstractAttribute.
virtual bool instructionCanReach(Attributor &A, const Instruction &Inst, const Function &Fn, const AA::InstExclusionSetTy *ExclusionSet=nullptr) const =0
Can Inst reach Fn.
AAInterFnReachability(const IRPosition &IRP, Attributor &A)
StateWrapper< BooleanState, AbstractAttribute > Base
An abstract interface to determine reachability of point A to B.
static LLVM_ABI AAIntraFnReachability & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAIntraFnReachability.
AAIntraFnReachability(const IRPosition &IRP, Attributor &A)
StringRef getName() const override
This function should return the name of the AbstractAttribute.
static LLVM_ABI const char ID
Unique ID (due to the unique address)
const char * getIdAddr() const override
This function should return the address of the ID of the AbstractAttribute.
virtual bool isAssumedReachable(Attributor &A, const Instruction &From, const Instruction &To, const AA::InstExclusionSetTy *ExclusionSet=nullptr) const =0
Returns true if 'From' instruction is assumed to reach, 'To' instruction.
StateWrapper< BooleanState, AbstractAttribute > Base
An abstract interface for identifying pointers from which loads can be marked invariant.
virtual bool isAssumedInvariant() const =0
Return true if the pointer's contents are assumed to remain invariant.
static LLVM_ABI AAInvariantLoadPointer & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
virtual bool isAssumedLocallyInvariant() const =0
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAInvariantLoadPointer.
static LLVM_ABI const char ID
Unique ID (due to the unique address).
const char * getIdAddr() const override
This function should return the address of the ID of the AbstractAttribute.
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP)
StringRef getName() const override
This function should return the name of the AbstractAttribute.
virtual bool isKnownInvariant() const =0
Return true if the pointer's contents are known to remain invariant.
AAInvariantLoadPointer(const IRPosition &IRP)
virtual bool isKnownLocallyInvariant() const =0
An abstract interface for liveness abstract attribute.
virtual bool isKnownDead(const BasicBlock *BB) const =0
Returns true if BB is known dead.
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAIsDead.
static LLVM_ABI const char ID
Unique ID (due to the unique address)
virtual bool isKnownDead() const =0
Returns true if the underlying value is known dead.
virtual bool isEdgeDead(const BasicBlock *From, const BasicBlock *To) const
Return if the edge from From BB to To BB is assumed dead.
virtual bool isAssumedDead(const Instruction *I) const =0
Returns true if I is assumed dead.
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP)
StringRef getName() const override
This function should return the name of the AbstractAttribute.
virtual bool isAssumedDead() const =0
The query functions are protected such that other attributes need to go through the Attributor interf...
virtual bool isRemovableStore() const
Return true if the underlying value is a store that is known to be removable.
virtual bool isAssumedDead(const BasicBlock *BB) const =0
Returns true if BB is assumed dead.
const char * getIdAddr() const override
This function should return the address of the ID of the AbstractAttribute.
StateWrapper< BitIntegerState< uint8_t, 3, 0 >, AbstractAttribute > Base
static LLVM_ABI AAIsDead & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
static bool mayCatchAsynchronousExceptions(const Function &F)
Determine if F might catch asynchronous exceptions.
AAIsDead(const IRPosition &IRP, Attributor &A)
virtual bool isKnownDead(const Instruction *I) const =0
Returns true if I is known dead.
An abstract interface for memory access kind related attributes (readnone/readonly/writeonly).
StringRef getName() const override
This function should return the name of the AbstractAttribute.
bool isAssumedReadOnly() const
Return true if we assume that the underlying value is not accessed (=written) in its respective scope...
static LLVM_ABI AAMemoryBehavior & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
static bool hasTrivialInitializer()
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAMemoryBehavior.
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP)
bool isKnownReadNone() const
Return true if we know that the underlying value is not read or accessed in its respective scope.
static LLVM_ABI const char ID
Unique ID (due to the unique address)
bool isKnownWriteOnly() const
Return true if we know that the underlying value is not read in its respective scope.
bool isAssumedReadNone() const
Return true if we assume that the underlying value is not read or accessed in its respective scope.
bool isAssumedWriteOnly() const
Return true if we assume that the underlying value is not read in its respective scope.
AAMemoryBehavior(const IRPosition &IRP, Attributor &A)
const char * getIdAddr() const override
This function should return the address of the ID of the AbstractAttribute.
bool isKnownReadOnly() const
Return true if we know that the underlying value is not accessed (=written) in its respective scope.
An abstract interface for all memory location attributes (readnone/argmemonly/inaccessiblememonly/ina...
StringRef getName() const override
This function should return the name of the AbstractAttribute.
const char * getIdAddr() const override
This function should return the address of the ID of the AbstractAttribute.
bool isAssumedStackOnly() const
Return true if we assume that the associated functions has at most local/stack accesses.
static LLVM_ABI std::string getMemoryLocationsAsStr(MemoryLocationsKind MLK)
Return the locations encoded by MLK as a readable string.
bool isKnownArgMemOnly() const
Return true if we know that the underlying value will only access argument pointees (see Attribute::A...
bool isKnownInaccessibleOrArgMemOnly() const
Return true if we know that the underlying value will only access inaccesible memory or argument poin...
static LLVM_ABI const char ID
Unique ID (due to the unique address)
AAMemoryLocation(const IRPosition &IRP, Attributor &A)
bool isKnownReadNone() const
Return true if we know that the associated functions has no observable accesses.
bool isAssumedSpecifiedMemOnly(MemoryLocationsKind MLK) const
Return true if only the memory locations specififed by MLK are assumed to be accessed by the associat...
bool isAssumedInaccessibleMemOnly() const
Return true if we assume that the underlying value will only access inaccesible memory only (see Attr...
bool isKnownInaccessibleMemOnly() const
Return true if we know that the underlying value will only access inaccesible memory only (see Attrib...
static LLVM_ABI AAMemoryLocation & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
bool isAssumedInaccessibleOrArgMemOnly() const
Return true if we assume that the underlying value will only access inaccesible memory or argument po...
bool isKnowStackOnly() const
Return true if we know that the associated functions has at most local/stack accesses.
static bool requiresCalleeForCallBase()
AccessKind
Simple enum to distinguish read/write/read-write accesses.
StateType::base_t MemoryLocationsKind
MemoryLocationsKind getAssumedNotAccessedLocation() const
Return the locations that are assumed to be not accessed by the associated function,...
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAMemoryLocation.
static bool hasTrivialInitializer()
bool isAssumedReadNone() const
Return true if we assume that the associated functions has no observable accesses.
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP)
virtual bool checkForAllAccessesToMemoryKind(function_ref< bool(const Instruction *, const Value *, AccessKind, MemoryLocationsKind)> Pred, MemoryLocationsKind MLK) const =0
Check Pred on all accesses to the memory kinds specified by MLK.
const std::string getAsStr(Attributor *A) const override
This function should return the "summarized" assumed state as string.
bool mayAccessArgMem() const
Return true if the underlying value may access memory through arguement pointers of the associated fu...
bool isAssumedArgMemOnly() const
Return true if we assume that the underlying value will only access argument pointees (see Attribute:...
static MemoryLocationsKind inverseLocation(MemoryLocationsKind Loc, bool AndLocalMem, bool AndConstMem)
Return the inverse of location Loc, thus for NO_XXX the return describes ONLY_XXX.
An abstract interface for all nonnull attributes.
StringRef getName() const override
This function should return the name of the AbstractAttribute.
bool isKnownMustProgress() const
Return true if we know that underlying value is nonnull.
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAMustProgress.
bool isAssumedMustProgress() const
Return true if we assume that the underlying value is nonnull.
static bool isImpliedByIR(Attributor &A, const IRPosition &IRP, Attribute::AttrKind ImpliedAttributeKind, bool IgnoreSubsumingPositions=false)
const char * getIdAddr() const override
This function should return the address of the ID of the AbstractAttribute.
static LLVM_ABI AAMustProgress & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
static LLVM_ABI const char ID
Unique ID (due to the unique address)
AAMustProgress(const IRPosition &IRP, Attributor &A)
An abstract interface for potential address space information.
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAAssumptionInfo.
static bool requiresCallersForArgOrFunction()
IntervalMap< unsigned, bool > RangeMap
static LLVM_ABI AANoAliasAddrSpace & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP)
static LLVM_ABI const char ID
Unique ID (due to the unique address)
AANoAliasAddrSpace(const IRPosition &IRP, Attributor &A)
const char * getIdAddr() const override
This function should return the address of the ID of the AbstractAttribute.
StateWrapper< BooleanState, AbstractAttribute > Base
RangeMap::Allocator Allocator
StringRef getName() const override
This function should return the name of the AbstractAttribute.
An abstract interface for all noalias attributes.
static LLVM_ABI bool isImpliedByIR(Attributor &A, const IRPosition &IRP, Attribute::AttrKind ImpliedAttributeKind, bool IgnoreSubsumingPositions=false)
---------------------— NoAlias Argument Attribute ---------------------—
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AANoAlias.
StringRef getName() const override
This function should return the name of the AbstractAttribute.
static bool requiresCallersForArgOrFunction()
const char * getIdAddr() const override
This function should return the address of the ID of the AbstractAttribute.
bool isKnownNoAlias() const
Return true if we know that underlying value is noalias.
static LLVM_ABI const char ID
Unique ID (due to the unique address)
bool isAssumedNoAlias() const
Return true if we assume that the underlying value is alias.
static LLVM_ABI AANoAlias & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
AANoAlias(const IRPosition &IRP, Attributor &A)
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP)
An abstract interface for all nocapture attributes.
static LLVM_ABI AANoCapture & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP)
@ NO_CAPTURE_MAYBE_RETURNED
If we do not capture the value in memory or through integers we can only communicate it back as a der...
@ NO_CAPTURE
If we do not capture the value in memory, through integers, or as a derived pointer we know it is not...
const char * getIdAddr() const override
This function should return the address of the ID of the AbstractAttribute.
AANoCapture(const IRPosition &IRP, Attributor &A)
StringRef getName() const override
This function should return the name of the AbstractAttribute.
static LLVM_ABI const char ID
Unique ID (due to the unique address)
bool isAssumedNoCaptureMaybeReturned() const
Return true if we assume that the underlying value is not captured in its respective scope but we all...
bool isKnownNoCapture() const
Return true if we know that the underlying value is not captured in its respective scope.
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AANoCapture.
bool isKnownNoCaptureMaybeReturned() const
Return true if we know that the underlying value is not captured in its respective scope but we allow...
static LLVM_ABI bool isImpliedByIR(Attributor &A, const IRPosition &IRP, Attribute::AttrKind ImpliedAttributeKind, bool IgnoreSubsumingPositions=false)
--------------------— Variable Capturing ------------------------------—
bool isAssumedNoCapture() const
Return true if we assume that the underlying value is not captured in its respective scope.
static LLVM_ABI void determineFunctionCaptureCapabilities(const IRPosition &IRP, const Function &F, BitIntegerState &State)
Update State according to the capture capabilities of F for position IRP.
FPClassTest getAssumedNoFPClass() const
Return the underlying assumed nofpclass.
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP)
AANoFPClass(const IRPosition &IRP, Attributor &A)
StringRef getName() const override
This function should return the name of the AbstractAttribute.
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AANoFPClass.
static LLVM_ABI const char ID
Unique ID (due to the unique address)
const char * getIdAddr() const override
This function should return the address of the ID of the AbstractAttribute.
FPClassTest getKnownNoFPClass() const
Return the underlying known nofpclass.
StateWrapper< BitIntegerState< uint32_t, fcAllFlags, fcNone >, AbstractAttribute > Base
static LLVM_ABI AANoFPClass & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
An AbstractAttribute for nofree.
bool isKnownNoFree() const
Return true if "nofree" is known.
static LLVM_ABI AANoFree & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
AANoFree(const IRPosition &IRP, Attributor &A)
static bool isImpliedByIR(Attributor &A, const IRPosition &IRP, Attribute::AttrKind ImpliedAttributeKind, bool IgnoreSubsumingPositions=false)
bool isAssumedNoFree() const
Return true if "nofree" is assumed.
static LLVM_ABI const char ID
Unique ID (due to the unique address)
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP)
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AANoFree.
StringRef getName() const override
This function should return the name of the AbstractAttribute.
const char * getIdAddr() const override
This function should return the address of the ID of the AbstractAttribute.
An abstract attribute for norecurse.
StringRef getName() const override
This function should return the name of the AbstractAttribute.
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AANoRecurse.
AANoRecurse(const IRPosition &IRP, Attributor &A)
const char * getIdAddr() const override
This function should return the address of the ID of the AbstractAttribute.
bool isAssumedNoRecurse() const
Return true if "norecurse" is assumed.
static LLVM_ABI AANoRecurse & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
bool isKnownNoRecurse() const
Return true if "norecurse" is known.
static LLVM_ABI const char ID
Unique ID (due to the unique address)
An AbstractAttribute for noreturn.
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AANoReturn.
static LLVM_ABI const char ID
Unique ID (due to the unique address)
bool isAssumedNoReturn() const
Return true if the underlying object is assumed to never return.
static LLVM_ABI AANoReturn & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
StringRef getName() const override
This function should return the name of the AbstractAttribute.
AANoReturn(const IRPosition &IRP, Attributor &A)
const char * getIdAddr() const override
This function should return the address of the ID of the AbstractAttribute.
bool isKnownNoReturn() const
Return true if the underlying object is known to never return.
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP)
AANoSync(const IRPosition &IRP, Attributor &A)
const char * getIdAddr() const override
This function should return the address of the ID of the AbstractAttribute.
StringRef getName() const override
This function should return the name of the AbstractAttribute.
static bool isImpliedByIR(Attributor &A, const IRPosition &IRP, Attribute::AttrKind ImpliedAttributeKind, bool IgnoreSubsumingPositions=false)
static LLVM_ABI const char ID
Unique ID (due to the unique address)
static LLVM_ABI bool isAlignedBarrier(const CallBase &CB, bool ExecutedAligned)
Helper function to determine if CB is an aligned (GPU) barrier.
bool isAssumedNoSync() const
Returns true if "nosync" is assumed.
static LLVM_ABI bool isNonRelaxedAtomic(const Instruction *I)
Helper function used to determine whether an instruction is non-relaxed atomic.
bool isKnownNoSync() const
Returns true if "nosync" is known.
static LLVM_ABI AANoSync & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AANoSync.
An abstract interface for all noundef attributes.
bool isKnownNoUndef() const
Return true if we know that underlying value is noundef.
static bool isImpliedByUndef()
StringRef getName() const override
This function should return the name of the AbstractAttribute.
bool isAssumedNoUndef() const
Return true if we assume that the underlying value is noundef.
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AANoUndef.
const char * getIdAddr() const override
This function should return the address of the ID of the AbstractAttribute.
static LLVM_ABI AANoUndef & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
AANoUndef(const IRPosition &IRP, Attributor &A)
static LLVM_ABI const char ID
Unique ID (due to the unique address)
static bool isImpliedByPoison()
static LLVM_ABI bool isImpliedByIR(Attributor &A, const IRPosition &IRP, Attribute::AttrKind ImpliedAttributeKind, bool IgnoreSubsumingPositions=false)
---------------------— NoUndef Attribute ------------------------------—
AANoUnwind(const IRPosition &IRP, Attributor &A)
bool isAssumedNoUnwind() const
Returns true if nounwind is assumed.
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AANoUnwind.
StringRef getName() const override
This function should return the name of the AbstractAttribute.
static LLVM_ABI AANoUnwind & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
static LLVM_ABI const char ID
Unique ID (due to the unique address)
bool isKnownNoUnwind() const
Returns true if nounwind is known.
const char * getIdAddr() const override
This function should return the address of the ID of the AbstractAttribute.
An abstract Attribute for determining the necessity of the convergent attribute.
static LLVM_ABI const char ID
Unique ID (due to the unique address)
const char * getIdAddr() const override
This function should return the address of the ID of the AbstractAttribute.
StateWrapper< BooleanState, AbstractAttribute > Base
static LLVM_ABI AANonConvergent & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
StringRef getName() const override
This function should return the name of the AbstractAttribute.
bool isAssumedNotConvergent() const
Return true if "non-convergent" is assumed.
bool isKnownNotConvergent() const
Return true if "non-convergent" is known.
AANonConvergent(const IRPosition &IRP, Attributor &A)
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AANonConvergent.
An abstract interface for all nonnull attributes.
static bool isImpliedByUndef()
Undef is not necessarily nonnull as nonnull + noundef would cause poison.
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP)
static LLVM_ABI const char ID
Unique ID (due to the unique address)
const char * getIdAddr() const override
This function should return the address of the ID of the AbstractAttribute.
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AANonNull.
static LLVM_ABI AANonNull & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
AANonNull(const IRPosition &IRP, Attributor &A)
StringRef getName() const override
This function should return the name of the AbstractAttribute.
static LLVM_ABI bool isImpliedByIR(Attributor &A, const IRPosition &IRP, Attribute::AttrKind ImpliedAttributeKind, bool IgnoreSubsumingPositions=false)
---------------------— NonNull Argument Attribute ---------------------—
bool isAssumedNonNull() const
Return true if we assume that the underlying value is nonnull.
bool isKnownNonNull() const
Return true if we know that underlying value is nonnull.
static bool hasTrivialInitializer()
bool isWrittenValueUnknown() const
Return true if the value written cannot be determined at all.
const_iterator end() const
bool operator!=(const Access &R) const
std::optional< Value * > getContent() const
Return the written value which can be llvm::null if it is not yet determined.
Access & operator=(const Access &Other)=default
bool isAssumption() const
Return true if this is an assumption access.
const RangeList & getRanges() const
bool isWriteOrAssumption() const
Return true if this is a write access.
bool isRead() const
Return true if this is a read access.
bool isWrite() const
Return true if this is a write access.
Value * getWrittenValue() const
Return the value writen, if any.
Instruction * getLocalInst() const
Return the instruction that causes the access with respect to the local scope of the associated attri...
Access(Instruction *LocalI, Instruction *RemoteI, const RangeList &Ranges, std::optional< Value * > Content, AccessKind K, Type *Ty)
Access(Instruction *LocalI, Instruction *RemoteI, int64_t Offset, int64_t Size, std::optional< Value * > Content, AccessKind Kind, Type *Ty)
Access(Instruction *I, int64_t Offset, int64_t Size, std::optional< Value * > Content, AccessKind Kind, Type *Ty)
Access(const Access &Other)=default
Type * getType() const
Return the type associated with the access, if known.
Access & operator&=(const Access &R)
const_iterator begin() const
RangeList::const_iterator const_iterator
Instruction * getRemoteInst() const
Return the actual instruction that causes the access.
bool operator==(const Access &R) const
bool isMustAccess() const
bool isWrittenValueYetUndetermined() const
Return true if the value written is not known yet.
AccessKind getKind() const
Return the access kind.
A helper containing a list of offsets computed for a Use.
SmallSet< int64_t, 4 > VecTy
VecTy::const_iterator const_iterator
bool isUnassigned() const
bool operator==(const OffsetInfo &RHS) const
bool insert(int64_t Offset)
bool operator!=(const OffsetInfo &RHS) const
const_iterator begin() const
const_iterator end() const
bool merge(const OffsetInfo &R)
Copy offsets from R into the current list.
void addToAll(int64_t Inc)
A container for a list of ranges.
const_iterator end() const
SmallVector< RangeTy > VecTy
void addToAllOffsets(int64_t Inc)
Add the increment Inc to the offset of every range.
bool operator==(const RangeList &OI) const
RangeList(ArrayRef< int64_t > Offsets, int64_t Size)
std::pair< iterator, bool > insert(iterator Pos, const RangeTy &R)
Insert R at the given iterator Pos, and merge if necessary.
RangeList(const RangeTy &R)
bool isUnknown() const
Return true iff the list contains an unknown range.
VecTy::const_iterator const_iterator
const_iterator begin() const
bool isUnassigned() const
Return true if no ranges have been inserted.
static void set_difference(const RangeList &L, const RangeList &R, RangeList &D)
Copy ranges from L that are not in R, into D.
bool merge(const RangeList &RHS)
Merge the ranges in RHS into the current ranges.
iterator setUnknown()
Discard all ranges and insert a single unknown range.
void push_back(const RangeTy &R)
An abstract interface for struct information.
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP)
virtual bool reachesReturn() const =0
StringRef getName() const override
This function should return the name of the AbstractAttribute.
virtual bool forallInterferingAccesses(Attributor &A, const AbstractAttribute &QueryingAA, Instruction &I, bool FindInterferingWrites, bool FindInterferingReads, function_ref< bool(const Access &, bool)> CB, bool &HasBeenWrittenTo, AA::RangeTy &Range, function_ref< bool(const Access &)> SkipCB=nullptr) const =0
Call CB on all accesses that might interfere with I and return true if all such accesses were known a...
virtual void addReturnedOffsetsTo(OffsetInfo &) const =0
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAPointerInfo.
OffsetBinsTy::const_iterator const_bin_iterator
const char * getIdAddr() const override
This function should return the address of the ID of the AbstractAttribute.
virtual const_bin_iterator begin() const =0
DenseMap< AA::RangeTy, SmallSet< unsigned, 4 > > OffsetBinsTy
virtual bool forallInterferingAccesses(AA::RangeTy Range, function_ref< bool(const Access &, bool)> CB) const =0
Call CB on all accesses that might interfere with Range and return true if all such accesses were kno...
virtual const_bin_iterator end() const =0
static LLVM_ABI const char ID
Unique ID (due to the unique address)
static LLVM_ABI AAPointerInfo & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
AAPointerInfo(const IRPosition &IRP)
virtual int64_t numOffsetBins() const =0
An abstract interface for potential values analysis.
PotentialConstantIntValuesState & getState() override
Return the internal abstract state for inspection.
const PotentialConstantIntValuesState & getState() const override
StateWrapper< PotentialConstantIntValuesState, AbstractAttribute, bool, unsigned > Base
static LLVM_ABI const char ID
Unique ID (due to the unique address)
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAPotentialConstantValues.
static bool requiresCallersForArgOrFunction()
unsigned getAssumedMinTrailingZeros() const
Return the minimum trailing zeros of potential constants.
std::optional< Constant * > getAssumedConstant(Attributor &A, const Instruction *CtxI=nullptr) const
Return assumed constant for the associated value.
static LLVM_ABI AAPotentialConstantValues & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
const char * getIdAddr() const override
This function should return the address of the ID of the AbstractAttribute.
LLVM_ABI AAPotentialConstantValues(const IRPosition &IRP, Attributor &A)
---------------— Potential Values Attribute ----------------------—
StringRef getName() const override
This function should return the name of the AbstractAttribute.
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP)
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAPotentialValues.
PotentialLLVMValuesState & getState() override
Return the internal abstract state for inspection.
AAPotentialValues(const IRPosition &IRP, Attributor &A)
static LLVM_ABI AAPotentialValues & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
static bool requiresCallersForArgOrFunction()
StateWrapper< PotentialLLVMValuesState, AbstractAttribute > Base
const PotentialLLVMValuesState & getState() const override
const char * getIdAddr() const override
This function should return the address of the ID of the AbstractAttribute.
static LLVM_ABI const char ID
Unique ID (due to the unique address)
StringRef getName() const override
This function should return the name of the AbstractAttribute.
static LLVM_ABI Value * getSingleValue(Attributor &A, const AbstractAttribute &AA, const IRPosition &IRP, SmallVectorImpl< AA::ValueAndContext > &Values)
Extract the single value in Values if any.
An abstract interface for privatizability.
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP)
bool isAssumedPrivatizablePtr() const
Returns true if pointer privatization is assumed to be possible.
virtual std::optional< Type * > getPrivatizableType() const =0
Return the type we can choose for a private copy of the underlying value.
static LLVM_ABI const char ID
Unique ID (due to the unique address)
StringRef getName() const override
This function should return the name of the AbstractAttribute.
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAPricatizablePtr.
static bool requiresCallersForArgOrFunction()
static LLVM_ABI AAPrivatizablePtr & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
AAPrivatizablePtr(const IRPosition &IRP, Attributor &A)
const char * getIdAddr() const override
This function should return the address of the ID of the AbstractAttribute.
StateWrapper< BooleanState, AbstractAttribute > Base
An abstract attribute for undefined behavior.
static LLVM_ABI AAUndefinedBehavior & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
const char * getIdAddr() const override
This function should return the address of the ID of the AbstractAttribute.
static LLVM_ABI const char ID
Unique ID (due to the unique address)
virtual bool isAssumedToCauseUB(Instruction *I) const =0
Return true if "undefined behavior" is assumed for a specific instruction.
StateWrapper< BooleanState, AbstractAttribute > Base
AAUndefinedBehavior(const IRPosition &IRP, Attributor &A)
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAUndefineBehavior.
StringRef getName() const override
This function should return the name of the AbstractAttribute.
virtual bool isKnownToCauseUB(Instruction *I) const =0
Return true if "undefined behavior" is known for a specific instruction.
An abstract attribute for getting all assumption underlying objects.
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP)
virtual bool forallUnderlyingObjects(function_ref< bool(Value &)> Pred, AA::ValueScope Scope=AA::Interprocedural) const =0
Check Pred on all underlying objects in Scope collected so far.
const char * getIdAddr() const override
This function should return the address of the ID of the AbstractAttribute.
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAUnderlyingObjects.
static LLVM_ABI AAUnderlyingObjects & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute biew for the position IRP.
static LLVM_ABI const char ID
Unique ID (due to the unique address)
AAUnderlyingObjects(const IRPosition &IRP)
static bool requiresCallersForArgOrFunction()
StringRef getName() const override
This function should return the name of the AbstractAttribute.
An abstract interface for range value analysis.
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP)
StringRef getName() const override
This function should return the name of the AbstractAttribute.
std::optional< Constant * > getAssumedConstant(Attributor &A, const Instruction *CtxI=nullptr) const
Return an assumed constant for the associated value a program point CtxI.
virtual ConstantRange getAssumedConstantRange(Attributor &A, const Instruction *CtxI=nullptr) const =0
Return an assumed range for the associated value a program point CtxI.
static LLVM_ABI const char ID
Unique ID (due to the unique address)
static bool requiresCallersForArgOrFunction()
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAValueConstantRange.
AAValueConstantRange(const IRPosition &IRP, Attributor &A)
static LLVM_ABI AAValueConstantRange & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
StateWrapper< IntegerRangeState, AbstractAttribute, uint32_t > Base
const char * getIdAddr() const override
This function should return the address of the ID of the AbstractAttribute.
IntegerRangeState & getState() override
Return the internal abstract state for inspection.
const IntegerRangeState & getState() const override
An abstract interface for value simplify abstract attribute.
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAValueSimplify.
StringRef getName() const override
This function should return the name of the AbstractAttribute.
StateWrapper< ValueSimplifyStateType, AbstractAttribute, Type * > Base
static LLVM_ABI const char ID
Unique ID (due to the unique address)
const char * getIdAddr() const override
This function should return the address of the ID of the AbstractAttribute.
static LLVM_ABI AAValueSimplify & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
AAValueSimplify(const IRPosition &IRP, Attributor &A)
An abstract attribute for willreturn.
bool isKnownWillReturn() const
Return true if "willreturn" is known.
const char * getIdAddr() const override
This function should return the address of the ID of the AbstractAttribute.
static LLVM_ABI const char ID
Unique ID (due to the unique address)
static LLVM_ABI AAWillReturn & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
StringRef getName() const override
This function should return the name of the AbstractAttribute.
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAWillReturn.
AAWillReturn(const IRPosition &IRP, Attributor &A)
static bool isImpliedByMustprogressAndReadonly(Attributor &A, const IRPosition &IRP)
Check for mustprogress and readonly as they imply willreturn.
static bool isImpliedByIR(Attributor &A, const IRPosition &IRP, Attribute::AttrKind ImpliedAttributeKind, bool IgnoreSubsumingPositions=false)
bool isAssumedWillReturn() const
Return true if "willreturn" is assumed.
Helper to represent an access offset and size, with logic to deal with uncertainty and check for over...
bool offsetAndSizeAreUnknown() const
Return true if offset and size are unknown, thus this is the default unknown object.
static constexpr int64_t Unknown
bool offsetOrSizeAreUnknown() const
Return true if offset or size are unknown.
static constexpr int64_t Unassigned
Constants used to represent special offsets or sizes.
RangeTy & operator&=(const RangeTy &R)
static RangeTy getUnknown()
bool isUnassigned() const
Return true if the offset and size are unassigned.
static bool LessThan(const RangeTy &L, const RangeTy &R)
Comparison for sorting ranges.
bool mayOverlap(const RangeTy &Range) const
Return true if this offset and size pair might describe an address that overlaps with Range.
RangeTy(int64_t Offset, int64_t Size)
std::pair< Value *, const Instruction * > Base
ValueAndContext(Value &V, const Instruction *CtxI)
const Instruction * getCtxI() const
ValueAndContext(Value &V, const Instruction &CtxI)
ValueAndContext(const Base &B)
Base struct for all "concrete attribute" deductions.
ChangeStatus update(Attributor &A)
Hook for the Attributor to trigger an update of the internal state.
friend struct Attributor
}
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP)
Return false if an AA should not be created for IRP.
virtual ChangeStatus manifest(Attributor &A)
Hook for the Attributor to trigger the manifestation of the information represented by the abstract a...
static bool classof(const AADepGraphNode *DGN)
This function is used to identify if an DGN is of type AbstractAttribute so that the dyn_cast and cas...
virtual bool isStateAtFixpoint() const
Return true if the state is at a fixpoint, like getState().isAtFixpoint() but with a single virtual c...
static bool requiresCalleeForCallBase()
Return true if this AA requires a "callee" (or an associted function) for a call site positon.
void print(raw_ostream &OS) const
Helper functions, for debug purposes only.
IRPosition & getIRPosition()
virtual StateType & getState()=0
Return the internal abstract state for inspection.
virtual void initialize(Attributor &A)
Initialize the state with the information in the Attributor A.
static bool isValidIRPositionForUpdate(Attributor &A, const IRPosition &IRP)
Return false if an AA should not be updated for IRP.
virtual const std::string getAsStr(Attributor *A) const =0
This function should return the "summarized" assumed state as string.
~AbstractAttribute() override=default
Virtual destructor.
static constexpr Attribute::AttrKind IRAttributeKind
Compile time access to the IR attribute kind.
virtual bool isQueryAA() const
A query AA is always scheduled as long as we do updates because it does lazy computation that cannot ...
virtual const StateType & getState() const =0
AbstractAttribute(const IRPosition &IRP)
static bool requiresNonAsmForCallBase()
Return true if this AA requires non-asm "callee" for a call site positon.
virtual ChangeStatus updateImpl(Attributor &A)=0
The actual update/transfer function which has to be implemented by the derived classes.
virtual void trackStatistics() const =0
Hook to enable custom statistic tracking, called after manifest that resulted in a change if statisti...
static bool requiresCallersForArgOrFunction()
Return true if this AA requires all callees for an argument or function positon.
virtual StringRef getName() const =0
This function should return the name of the AbstractAttribute.
const IRPosition & getIRPosition() const
Return an IR position, see struct IRPosition.
virtual const char * getIdAddr() const =0
This function should return the address of the ID of the AbstractAttribute.
static bool hasTrivialInitializer()
Return false if this AA does anything non-trivial (hence not done by default) in its initializer.
An interface to query the internal state of an abstract attribute.
virtual ~AbstractState()=default
virtual ChangeStatus indicatePessimisticFixpoint()=0
Indicate that the abstract state should converge to the pessimistic state.
virtual bool isAtFixpoint() const =0
Return if this abstract state is fixed, thus does not need to be updated if information changes as it...
virtual bool isValidState() const =0
Return if this abstract state is in a valid state.
virtual ChangeStatus indicateOptimisticFixpoint()=0
Indicate that the abstract state should converge to the optimistic state.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Wrapper for FunctionAnalysisManager.
static constexpr bool HasLegacyWrapper
Analysis::Result * getAnalysis(const Function &F, bool RequestCachedOnly=false)
AnalysisGetter(FunctionAnalysisManager &FAM, bool CachedOnly=false)
void invalidateAnalyses()
Invalidates the analyses. Valid only when using the new pass manager.
AnalysisGetter(Pass *P, bool CachedOnly=false)
LLVM_ABI PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM, LazyCallGraph &CG, CGSCCUpdateResult &UR)
~AttributorCallGraph() override=default
AACallEdgeIterator optimisticEdgesEnd() const override
AttributorCallGraph(Attributor &A)
AACallEdgeIterator optimisticEdgesBegin() const override
void populateAll() const
Force populate the entire call graph.
Configuration for the Attributor.
bool UseLiveness
Flag to determine if we should skip all liveness checks early on.
std::function< void(Attributor &A, const Function &F)> InitializationCallback
Callback function to be invoked on internal functions marked live.
std::optional< unsigned > MaxFixpointIterations
Maximum number of iterations to run until fixpoint.
bool RewriteSignatures
Flag to determine if we rewrite function signatures.
OptimizationRemarkGetter OREGetter
bool DeleteFns
Flag to determine if we can delete functions or keep dead ones around.
std::function< bool(const Function &F)> IPOAmendableCBTy
bool IsClosedWorldModule
Flag to indicate if the entire world is contained in this module, that is, no outside functions exist...
function_ref< OptimizationRemarkEmitter &(Function *)> OptimizationRemarkGetter
A callback function that returns an ORE object from a Function pointer.
CallGraphUpdater & CGUpdater
Helper to update an underlying call graph and to delete functions.
std::optional< AAKindSet > Allowed
If set, the only kinds of abstract attributes to create.
IPOAmendableCBTy IPOAmendableCB
bool IsModulePass
Is the user of the Attributor a module pass or not.
std::function< bool(Attributor &A, const AbstractAttribute &AA, CallBase &CB, Function &AssumedCallee, unsigned NumAssumedCallees)> IndirectCalleeSpecializationCallback
Callback function to determine if an indirect call targets should be made direct call targets (with a...
bool DefaultInitializeLiveInternals
Flag to determine if we want to initialize all default AAs for an internal function marked live.
AttributorConfig(CallGraphUpdater &CGUpdater)
A more lightweight version of the Attributor which only runs attribute inference but no simplificatio...
LLVM_ABI PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM, LazyCallGraph &CG, CGSCCUpdateResult &UR)
A more lightweight version of the Attributor which only runs attribute inference but no simplificatio...
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
Helper struct used in the communication between an abstract attribute (AA) that wants to change the s...
friend struct Attributor
Allow access to the private members from the Attributor.
std::function< void( const ArgumentReplacementInfo &, Function &, Function::arg_iterator)> CalleeRepairCBTy
Callee repair callback type.
unsigned getNumReplacementArgs() const
const Argument & getReplacedArg() const
Attributor & getAttributor() const
Simple getters, see the corresponding members for details.
const Function & getReplacedFn() const
std::function< void(const ArgumentReplacementInfo &, AbstractCallSite, SmallVectorImpl< Value * > &)> ACSRepairCBTy
Abstract call site (ACS) repair callback type.
The fixpoint analysis framework that orchestrates the attribute deduction.
LLVM_ABI bool registerFunctionSignatureRewrite(Argument &Arg, ArrayRef< Type * > ReplacementTypes, ArgumentReplacementInfo::CalleeRepairCBTy &&CalleeRepairCB, ArgumentReplacementInfo::ACSRepairCBTy &&ACSRepairCB)
Register a rewrite for a function signature.
AAType & registerAA(AAType &AA)
Introduce a new abstract attribute into the fixpoint analysis.
const SmallSetVector< Function *, 8 > & getAttrModifiedFunctions()
Return the functions whose attributes, or whose call site attributes, were changed.
LLVM_ABI 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 isModulePass() const
Return true if this is a module pass, false otherwise.
void registerInvokeWithDeadSuccessor(InvokeInst &II)
Record that II has at least one dead successor block.
void registerSimplificationCallback(const IRPosition &IRP, const SimplifictionCallbackTy &CB)
bool changeAfterManifest(const IRPosition IRP, Value &NV, bool ChangeDroppable=true)
Helper function to replace all uses associated with IRP with NV.
LLVM_ABI bool isValidFunctionSignatureRewrite(Argument &Arg, ArrayRef< Type * > ReplacementTypes)
Check if we can rewrite a function signature.
static LLVM_ABI bool isInternalizable(Function &F)
Returns true if the function F can be internalized.
LLVM_ABI ChangeStatus removeAttrs(const IRPosition &IRP, ArrayRef< Attribute::AttrKind > AttrKinds)
Remove all AttrKinds attached to IRP.
void emitRemark(Instruction *I, StringRef RemarkName, RemarkCallBack &&RemarkCB) const
Emit a remark generically.
bool isRunOn(Function &Fn) const
Return true if we derive attributes for Fn.
LLVM_ABI 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.
LLVM_ABI 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.
LLVM_ABI 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 ...
static LLVM_ABI void createShallowWrapper(Function &F)
Create a shallow wrapper for F such that F has internal linkage afterwards.
bool isRunOn(Function *Fn) const
bool isDuringDeduction() const
Return whether attributes can participate in fixed-point deduction.
const AAType * getAAFor(const AbstractAttribute &QueryingAA, const IRPosition &IRP, DepClassTy DepClass)
Lookup an abstract attribute of type AAType at position IRP.
std::function< std::optional< Value * >( const IRPosition &, const AbstractAttribute *, bool &)> SimplifictionCallbackTy
Register CB as a simplification callback.
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 ...
void deleteAfterManifest(Function &F)
Record that F is deleted after information was manifested.
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 nu...
void emitRemark(Function *F, StringRef RemarkName, RemarkCallBack &&RemarkCB) const
Emit a remark on a function.
static LLVM_ABI Function * internalizeFunction(Function &F, bool Force=false)
Make another copy of the function F such that the copied version has internal linkage afterwards and ...
bool isFunctionIPOAmendable(const Function &F)
Determine whether the function F is IPO amendable.
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.
const SmallSetVector< Function *, 8 > & getModifiedFunctions()
LLVM_ABI bool checkForAllReadWriteInstructions(function_ref< bool(Instruction &)> Pred, AbstractAttribute &QueryingAA, bool &UsedAssumedInformation)
Check Pred on all Read/Write instructions.
void changeToUnreachableAfterManifest(Instruction *I)
Record that I is to be replaced with unreachable after information was manifested.
bool hasGlobalVariableSimplificationCallback(const GlobalVariable &GV)
Return true if there is a simplification callback for GV.
std::optional< Constant * > getAssumedConstant(const Value &V, const AbstractAttribute &AA, bool &UsedAssumedInformation)
LLVM_ABI 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 hasSimplificationCallback(const IRPosition &IRP)
Return true if there is a simplification callback for IRP.
std::function< std::optional< Constant * >( const GlobalVariable &, const AbstractAttribute *, bool &)> GlobalVariableSimplifictionCallbackTy
Register CB as a simplification callback.
LLVM_ABI bool isClosedWorldModule() const
Return true if the module contains the whole world, thus, no outside functions exist.
LLVM_ABI 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,...
const AAType * getOrCreateAAFor(const IRPosition &IRP)
LLVM_ABI Attributor(SetVector< Function * > &Functions, InformationCache &InfoCache, AttributorConfig Configuration)
Constructor.
void registerGlobalVariableSimplificationCallback(const GlobalVariable &GV, const GlobalVariableSimplifictionCallbackTy &CB)
const DataLayout & getDataLayout() const
Return the data layout associated with the anchor scope.
LLVM_ABI 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.
InformationCache & getInfoCache()
Return the internal information cache.
bool changeUseAfterManifest(Use &U, Value &NV)
Record that U is to be replaces with NV after information was manifested.
LLVM_ABI 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.
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 markLiveInternalFunction(const Function &F)
Mark the internal function F as live.
void registerManifestAddedBasicBlock(BasicBlock &BB)
void registerVirtualUseCallback(const Value &V, const VirtualUseCallbackTy &CB)
LLVM_ABI 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.
LLVM_ABI 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 alr...
LLVM_ABI 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.
bool canUseBodyFor(const IRPosition &IRP)
Return true if the body of the associated function can be used to derive information for IRP.
LLVM_ABI void registerForUpdate(AbstractAttribute &AA)
Allows a query AA to request an update if a new query was received.
const Module & getModule()
Return the module.
void deleteAfterManifest(Instruction &I)
Record that I is deleted after information was manifested.
std::function< bool(Attributor &, const AbstractAttribute *)> VirtualUseCallbackTy
void deleteAfterManifest(BasicBlock &BB)
Record that BB is deleted after information was manifested.
LLVM_ABI void identifyDefaultAbstractAttributes(Function &F)
Determine opportunities to derive 'default' attributes in F and create abstract attribute objects for...
bool shouldInitialize(const IRPosition &IRP, bool &ShouldUpdateAA)
LLVM_ABI 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.
BumpPtrAllocator & Allocator
The allocator used to allocate memory, e.g. for AbstractAttributes.
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 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.
LLVM_ABI ChangeStatus run()
Run the analyses until a fixpoint is reached or enforced (timeout).
static LLVM_ABI 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 after...
std::optional< Value * > getAssumedSimplified(const Value &V, const AbstractAttribute &AA, bool &UsedAssumedInformation, AA::ValueScope S)
bool shouldUpdateAA(const IRPosition &IRP)
LLVM_ABI bool checkForAllCallSites(function_ref< bool(AbstractCallSite)> Pred, const AbstractAttribute &QueryingAA, bool RequireAllCallSites, bool &UsedAssumedInformation)
Check Pred on all function call sites.
LLVM_ABI 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....
Specialization of the integer state for a bit-wise encoding.
BitIntegerState & removeKnownBits(base_t BitsEncoding)
Remove the bits in BitsEncoding from the "known bits".
BitIntegerState()=default
bool isAssumed(base_t BitsEncoding=BestState) const
Return true if the bits set in BitsEncoding are "assumed bits".
IntegerStateBase< base_ty, BestState, WorstState > super
BitIntegerState(base_t Assumed)
BitIntegerState & removeAssumedBits(base_t BitsEncoding)
Remove the bits in BitsEncoding from the "assumed bits" if not known.
BitIntegerState & intersectAssumedBits(base_t BitsEncoding)
Keep only "assumed bits" also set in BitsEncoding but all known ones.
bool isKnown(base_t BitsEncoding=BestState) const
Return true if the bits set in BitsEncoding are "known bits".
BitIntegerState & addKnownBits(base_t Bits)
Add the bits in BitsEncoding to the "known bits".
Simple wrapper for a single bit (boolean) state.
IntegerStateBase< bool, true, false > super
bool isKnown() const
Return true if the state is known to hold.
void setKnown(bool Value)
Set the known and asssumed value to Value.
IntegerStateBase::base_t base_t
BooleanState(base_t Assumed)
bool isAssumed() const
Return true if the state is assumed to hold.
Support structure for SCC passes to communicate updates the call graph back to the CGSCC pass manager...
static bool isNodeHidden(const AACallGraphNode *Node, const AttributorCallGraph *Graph)
DOTGraphTraits(bool Simple=false)
std::string getNodeLabel(const AACallGraphNode *Node, const AttributorCallGraph *Graph)
DefaultDOTGraphTraits(bool simple=false)
Specialization of the integer state for a decreasing value, hence 0 is the best state and ~0u the wor...
DecIntegerState & takeKnownMinimum(base_t Value)
Take minimum of known and Value.
DecIntegerState & takeAssumedMaximum(base_t Value)
Take maximum of assumed and Value.
static DenormalMode unionAssumed(DenormalMode Callee, DenormalMode Caller)
DenormalState unionWith(DenormalState Caller) const
bool operator!=(const DenormalState Other) const
bool operator==(const DenormalState Other) const
static DenormalMode::DenormalModeKind unionDenormalKind(DenormalMode::DenormalModeKind Callee, DenormalMode::DenormalModeKind Caller)
bool IsAtFixedpoint
Explicitly track whether we've hit a fixed point.
ChangeStatus indicateOptimisticFixpoint() override
Indicate that the abstract state should converge to the optimistic state.
DenormalState getKnown() const
DenormalState getAssumed() const
bool isValidState() const override
Return if this abstract state is in a valid state.
ChangeStatus indicatePessimisticFixpoint() override
Indicate that the abstract state should converge to the pessimistic state.
DenormalFPMathState operator^=(const DenormalFPMathState &Caller)
ChangeStatus indicateFixpoint()
bool isModeFixed() const
Return true if there are no dynamic components to the denormal mode worth specializing.
bool isAtFixpoint() const override
Return if this abstract state is fixed, thus does not need to be updated if information changes as it...
DenormalFPMathState()=default
Represent subnormal handling kind for floating point instruction inputs and outputs.
DenormalModeKind
Represent handled modes for denormal (aka subnormal) modes in the floating point environment.
@ Dynamic
Denormals have unknown treatment.
static constexpr DenormalMode getInvalid()
static bool isEqual(const AA::ValueAndContext &LHS, const AA::ValueAndContext &RHS)
static unsigned getHashValue(const AA::ValueAndContext &VAC)
DenseMapInfo< AA::ValueAndContext::Base > Base
static bool isEqual(const AA::ValueScope &LHS, const AA::ValueScope &RHS)
DenseMapInfo< unsigned char > Base
static unsigned getHashValue(const AA::ValueScope &S)
static bool isEqual(const IRPosition &a, const IRPosition &b)
static unsigned getHashValue(const IRPosition &IRP)
An information struct used to provide DenseMap with the various necessary components for a given valu...
State for dereferenceable attribute.
IncIntegerState DerefBytesState
State representing for dereferenceable bytes.
static DerefState getBestState(const DerefState &)
static DerefState getWorstState()
Return the worst possible representable state.
static DerefState getBestState()
static DerefState getWorstState(const DerefState &)
std::map< int64_t, uint64_t > AccessedBytesMap
Map representing for accessed memory offsets and sizes.
static AACallEdgeIterator child_end(AACallGraphNode *Node)
AACallEdgeIterator ChildIteratorType
AACallGraphNode * NodeRef
static AACallEdgeIterator child_begin(AACallGraphNode *Node)
static AACallGraphNode * getEntryNode(AttributorCallGraph *G)
static AACallEdgeIterator nodes_begin(const AttributorCallGraph *G)
static AACallEdgeIterator nodes_end(const AttributorCallGraph *G)
AACallEdgeIterator nodes_iterator
Attribute::AttrKind getAttrKind() const
Return the kind that identifies the abstract attribute implementation.
static constexpr Attribute::AttrKind IRAttributeKind
Compile time access to the IR attribute kind.
static bool hasTrivialInitializer()
Most boolean IRAttribute AAs don't do anything non-trivial in their initializers while non-boolean on...
static bool isImpliedByUndef()
Return true if the IR attribute(s) associated with this AA are implied for an undef value.
ChangeStatus manifest(Attributor &A) override
static bool isImpliedByPoison()
Return true if the IR attribute(s) associated with this AA are implied for an poison value.
static bool isImpliedByIR(Attributor &A, const IRPosition &IRP, Attribute::AttrKind ImpliedAttributeKind=AK, bool IgnoreSubsumingPositions=false)
IRAttribute(const IRPosition &IRP)
virtual void getDeducedAttributes(Attributor &A, LLVMContext &Ctx, SmallVectorImpl< Attribute > &Attrs) const
Return the deduced attributes in Attrs.
Helper to describe and deal with positions in the LLVM-IR.
Function * getAssociatedFunction() const
Return the associated function, if any.
void setAttrList(const AttributeList &AttrList) const
Update the attributes associated with this function or call site scope.
unsigned getAttrIdx() const
Return the index in the attribute list for this position.
bool hasCallBaseContext() const
Check if the position has any call base context.
static const IRPosition callsite_returned(const CallBase &CB)
Create a position describing the returned value of CB.
static const IRPosition returned(const Function &F, const CallBaseContext *CBContext=nullptr)
Create a position describing the returned value of F.
LLVM_ABI Argument * getAssociatedArgument() const
Return the associated argument, if any.
bool isAnyCallSitePosition() const
bool operator!=(const IRPosition &RHS) const
static const IRPosition value(const Value &V, const CallBaseContext *CBContext=nullptr)
Create a position describing the value of V.
AttributeList getAttrList() const
Return the attributes associated with this function or call site scope.
int getCalleeArgNo() const
Return the callee argument number of the associated value if it is an argument or call site argument,...
static const IRPosition inst(const Instruction &I, const CallBaseContext *CBContext=nullptr)
Create a position describing the instruction I.
static const IRPosition callsite_argument(const CallBase &CB, unsigned ArgNo)
Create a position describing the argument of CB at position ArgNo.
Kind
The positions we distinguish in the IR.
@ IRP_ARGUMENT
An attribute for a function argument.
@ IRP_RETURNED
An attribute for the function return value.
@ IRP_CALL_SITE
An attribute for a call site (function scope).
@ IRP_CALL_SITE_RETURNED
An attribute for a call site return value.
@ IRP_FUNCTION
An attribute for a function (scope).
@ IRP_FLOAT
A position that is not associated with a spot suitable for attributes.
@ IRP_CALL_SITE_ARGUMENT
An attribute for a call site argument.
@ IRP_INVALID
An invalid position.
Instruction * getCtxI() const
Return the context instruction, if any.
static const IRPosition argument(const Argument &Arg, const CallBaseContext *CBContext=nullptr)
Create a position describing the argument Arg.
Type * getAssociatedType() const
Return the type this abstract attribute is associated with.
bool isFunctionScope() const
Return true if this is a function or call site position.
bool operator==(const IRPosition &RHS) const
static const IRPosition callsite_argument(AbstractCallSite ACS, unsigned ArgNo)
Create a position describing the argument of ACS at position ArgNo.
static const IRPosition function(const Function &F, const CallBaseContext *CBContext=nullptr)
Create a position describing the function scope of F.
const CallBaseContext * getCallBaseContext() const
Get the call base context from the position.
Value & getAssociatedValue() const
Return the value this abstract attribute is associated with.
Value & getAnchorValue() const
Return the value this abstract attribute is anchored with.
Value * getAttrListAnchor() const
Return the value attributes are attached to.
int getCallSiteArgNo() const
Return the call site argument number of the associated value if it is an argument or call site argume...
bool isFnInterfaceKind() const
Return true if the position refers to a function interface, that is the function scope,...
static const IRPosition function_scope(const IRPosition &IRP, const CallBaseContext *CBContext=nullptr)
Create a position with function scope matching the "context" of IRP.
IRPosition stripCallBaseContext() const
Return the same position without the call base context.
Kind getPositionKind() const
Return the associated position kind.
bool isArgumentPosition() const
Return true if the position is an argument or call site argument.
static const IRPosition callsite_function(const CallBase &CB)
Create a position describing the function scope of CB.
IRPosition()
Default constructor available to create invalid positions implicitly.
Function * getAnchorScope() const
Return the Function surrounding the anchor value.
Specialization of the integer state for an increasing value, hence ~0u is the best state and 0 the wo...
IntegerStateBase< base_ty, BestState, WorstState > super
static constexpr base_t getBestState(const IncIntegerState< base_ty, BestState, WorstState > &)
IncIntegerState(base_t Assumed)
static constexpr base_t getBestState()
Return the best possible representable state.
IncIntegerState & takeAssumedMinimum(base_t Value)
Take minimum of assumed and Value.
IncIntegerState & takeKnownMaximum(base_t Value)
Take maximum of known and Value.
State for an integer range.
IntegerRangeState operator^=(const IntegerRangeState &R)
"Clamp" this state with R.
IntegerRangeState operator&=(const IntegerRangeState &R)
bool isAtFixpoint() const override
Return if this abstract state is fixed, thus does not need to be updated if information changes as it...
void unionAssumed(const IntegerRangeState &R)
See IntegerRangeState::unionAssumed(..).
ConstantRange Assumed
State representing assumed range, initially set to empty.
IntegerRangeState(const ConstantRange &CR)
IntegerRangeState(uint32_t BitWidth)
bool operator==(const IntegerRangeState &R) const
Equality for IntegerRangeState.
void intersectKnown(const IntegerRangeState &R)
See IntegerRangeState::intersectKnown(..).
static ConstantRange getBestState(const IntegerRangeState &IRS)
bool isValidState() const override
Return if this abstract state is in a valid state.
uint32_t BitWidth
Bitwidth of the associated value.
ConstantRange Known
State representing known range, initially set to [-inf, inf].
void unionAssumed(const ConstantRange &R)
Unite assumed range with the passed state.
ChangeStatus indicatePessimisticFixpoint() override
Indicate that the abstract state should converge to the pessimistic state.
ConstantRange getKnown() const
Return the known state encoding.
void intersectKnown(const ConstantRange &R)
Intersect known range with the passed state.
ConstantRange getAssumed() const
Return the assumed state encoding.
uint32_t getBitWidth() const
Return associated values' bit width.
ChangeStatus indicateOptimisticFixpoint() override
Indicate that the abstract state should converge to the optimistic state.
static ConstantRange getWorstState(uint32_t BitWidth)
Return the worst possible representable state.
static ConstantRange getBestState(uint32_t BitWidth)
Return the best possible representable state.
Simple state with integers encoding.
bool isValidState() const override
NOTE: For now we simply pretend that the worst possible state is invalid.
virtual void handleNewAssumedValue(base_t Value)=0
Handle a new assumed value Value. Subtype dependent.
bool isAtFixpoint() const override
Return if this abstract state is fixed, thus does not need to be updated if information changes as it...
void operator|=(const IntegerStateBase< base_t, BestState, WorstState > &R)
virtual void handleNewKnownValue(base_t Value)=0
Handle a new known value Value. Subtype dependent.
base_t getKnown() const
Return the known state encoding.
ChangeStatus indicateOptimisticFixpoint() override
Indicate that the abstract state should converge to the optimistic state.
void operator^=(const IntegerStateBase< base_t, BestState, WorstState > &R)
"Clamp" this state with R.
virtual void joinOR(base_t AssumedValue, base_t KnownValue)=0
Handle a value Value. Subtype dependent.
virtual void joinAND(base_t AssumedValue, base_t KnownValue)=0
Handle a new assumed value Value. Subtype dependent.
IntegerStateBase(base_t Assumed)
void operator+=(const IntegerStateBase< base_t, BestState, WorstState > &R)
"Clamp" this state with R.
base_t getAssumed() const
Return the assumed state encoding.
static constexpr base_t getWorstState()
Return the worst possible representable state.
static constexpr base_t getBestState()
Return the best possible representable state.
ChangeStatus indicatePessimisticFixpoint() override
Indicate that the abstract state should converge to the pessimistic state.
IntegerStateBase()=default
static constexpr base_t getWorstState(const IntegerStateBase &)
bool operator!=(const IntegerStateBase< base_t, BestState, WorstState > &R) const
Inequality for IntegerStateBase.
bool operator==(const IntegerStateBase< base_t, BestState, WorstState > &R) const
Equality for IntegerStateBase.
void operator&=(const IntegerStateBase< base_t, BestState, WorstState > &R)
static constexpr base_t getBestState(const IntegerStateBase &)
A "must be executed context" for a given program point PP is the set of instructions,...
A CRTP mix-in for passes that can be skipped.
static constexpr int NumLowBitsAvailable
Note, we assume here that void* is related to raw malloc'ed memory and that malloc returns objects at...
static PotentialValuesState getBestState(const PotentialValuesState &PVS)
Return empty set as the best state of potential values.
PotentialValuesState & getAssumed()
Return the assumed state.
PotentialValuesState(bool IsValid, unsigned MaxPotentialValues)
bool undefIsContained() const
Returns whether this state contains an undef value or not.
bool isAtFixpoint() const override
Return if this abstract state is fixed, thus does not need to be updated if information changes as it...
void unionAssumed(const MemberTy &C)
Union assumed set with the passed value.
SmallSetVector< MemberTy, 8 > SetTy
ChangeStatus indicatePessimisticFixpoint() override
Indicate that the abstract state should converge to the pessimistic state.
void unionAssumed(const PotentialValuesState &PVS)
Union assumed set with assumed set of the passed state PVS.
PotentialValuesState(bool IsValid)
bool operator==(const PotentialValuesState &RHS) const
bool isValidState() const override
Return if this abstract state is in a valid state.
PotentialValuesState operator&=(const PotentialValuesState &PVS)
static PotentialValuesState getWorstState()
Return full set as the worst state of potential values.
const PotentialValuesState & getAssumed() const
ChangeStatus indicateOptimisticFixpoint() override
Indicate that the abstract state should converge to the optimistic state.
PotentialValuesState operator^=(const PotentialValuesState &PVS)
"Clamp" this state with PVS.
void unionAssumedWithUndef()
Union assumed set with an undef value.
const SetTy & getAssumedSet() const
Return this set.
A wrapper around a set that has semantics for handling unions and intersections with a "universal" se...
SetContents(bool Universal)
Creates a universal set with no concrete elements or an empty set.
SetContents(bool Universal, const DenseSet< BaseTy > &Assumptions)
bool getIntersection(const SetContents &RHS)
Finds A := A ^ B where A or B could be the "Universal" set which contains every possible attribute.
bool getUnion(const SetContents &RHS)
Finds A := A u B where A or B could be the "Universal" set which contains every possible attribute.
const DenseSet< BaseTy > & getSet() const
SetContents(const DenseSet< BaseTy > &Assumptions)
Creates a non-universal set with concrete values.
bool setContains(const BaseTy &Elem) const
Returns if the set state contains the element.
bool getIntersection(const SetContents &RHS)
Performs the set intersection between this set and RHS.
bool isValidState() const override
Return if this abstract state is in a valid state.
bool isAtFixpoint() const override
Return if this abstract state is fixed, thus does not need to be updated if information changes as it...
const SetContents & getAssumed() const
Return the assumed state encoding.
const SetContents & getKnown() const
Return the known state encoding.
ChangeStatus indicateOptimisticFixpoint() override
Indicate that the abstract state should converge to the optimistic state.
bool getUnion(const SetContents &RHS)
Performs the set union between this set and RHS.
SetState(const DenseSet< BaseTy > &Known)
Initializes the known state with an initial set and initializes the assumed state as universal.
ChangeStatus indicatePessimisticFixpoint() override
Indicate that the abstract state should converge to the pessimistic state.
Helper to tie a abstract state implementation to an abstract attribute.
StateType & getState() override
StateTy StateType
Provide static access to the type of the state.
bool isStateAtFixpoint() const final
StateWrapper(const IRPosition &IRP, Ts... Args)
const StateType & getState() const override
bool isAtFixpoint() const final
static ValueSimplifyStateType getWorstState(Type *Ty)
Return the worst possible representable state.
static ValueSimplifyStateType getBestState(const ValueSimplifyStateType &VS)
LLVM_ABI bool unionAssumed(std::optional< Value * > Other)
Merge Other into the currently assumed simplified value.
ChangeStatus indicateOptimisticFixpoint() override
Indicate that the abstract state should converge to the optimistic state.
ValueSimplifyStateType operator^=(const ValueSimplifyStateType &VS)
"Clamp" this state with PVS.
ChangeStatus indicatePessimisticFixpoint() override
Indicate that the abstract state should converge to the pessimistic state.
ValueSimplifyStateType(Type *Ty)
static ValueSimplifyStateType getBestState(Type *Ty)
bool isAtFixpoint() const override
Return if this abstract state is fixed, thus does not need to be updated if information changes as it...
bool isValidState() const override
Return if this abstract state is in a valid state.
std::optional< Value * > SimplifiedAssociatedValue
An assumed simplified value.
static ValueSimplifyStateType getWorstState(const ValueSimplifyStateType &VS)
BooleanState BS
Helper to track validity and fixpoint.
Type * Ty
The type of the original value.
bool operator==(const ValueSimplifyStateType &RHS) const
ValueSimplifyStateType getAssumed()
Return the assumed state encoding.
const ValueSimplifyStateType & getAssumed() const