llvm.org GIT mirror llvm / 3c9c819
[Attributor] Only return attributes with a valid state Attributor::getAAFor will now only return AbstractAttributes with a valid AbstractState. This simplifies call sites as they only need to check if the returned pointer is non-null. It also reduces the potential for accidental misuse. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@365983 91177308-0d34-0410-b5e6-96231b3b80d8 Johannes Doerfert a month ago
2 changed file(s) with 8 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
198198 const auto &KindToAbstractAttributeMap = AAMap.lookup({&V, ArgNo});
199199 if (AAType *AA = static_cast(
200200 KindToAbstractAttributeMap.lookup(AAType::ID))) {
201 QueryMap[AA].insert(&QueryingAA);
202 return AA;
201 // Do not return an attribute with an invalid state. This minimizes checks
202 // at the calls sites and allows the fallback below to kick in.
203 if (AA->getState().isValidState()) {
204 QueryMap[AA].insert(&QueryingAA);
205 return AA;
206 }
203207 }
204208
205209 // If no abstract attribute was found and we look for a call site argument,
654654
655655 // Try to find a assumed unique return value for the called function.
656656 auto *RetCSAA = A.getAAFor(*this, *RV);
657 if (!RetCSAA || !RetCSAA->isValidState()) {
657 if (!RetCSAA) {
658658 HasOverdefinedReturnedCalls = true;
659659 LLVM_DEBUG(dbgs() << "[AAReturnedValues] Returned call site (" << *RV
660660 << ") with " << (RetCSAA ? "invalid" : "no")
964964 auto ICS = ImmutableCallSite(I);
965965 auto *NoFreeAA = A.getAAFor(*this, *I);
966966
967 if ((!NoFreeAA || !NoFreeAA->isValidState() ||
968 !NoFreeAA->isAssumedNoFree()) &&
967 if ((!NoFreeAA || !NoFreeAA->isAssumedNoFree()) &&
969968 !ICS.hasFnAttr(Attribute::NoFree)) {
970969 indicatePessimisticFixpoint();
971970 return ChangeStatus::CHANGED;