[llvm] r365983 - [Attributor] Only return attributes with a valid state
Johannes Doerfert via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 12 18:09:21 PDT 2019
Author: jdoerfert
Date: Fri Jul 12 18:09:21 2019
New Revision: 365983
URL: http://llvm.org/viewvc/llvm-project?rev=365983&view=rev
Log:
[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.
Modified:
llvm/trunk/include/llvm/Transforms/IPO/Attributor.h
llvm/trunk/lib/Transforms/IPO/Attributor.cpp
Modified: llvm/trunk/include/llvm/Transforms/IPO/Attributor.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/IPO/Attributor.h?rev=365983&r1=365982&r2=365983&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Transforms/IPO/Attributor.h (original)
+++ llvm/trunk/include/llvm/Transforms/IPO/Attributor.h Fri Jul 12 18:09:21 2019
@@ -199,8 +199,12 @@ struct Attributor {
const auto &KindToAbstractAttributeMap = AAMap.lookup({&V, ArgNo});
if (AAType *AA = static_cast<AAType *>(
KindToAbstractAttributeMap.lookup(AAType::ID))) {
- QueryMap[AA].insert(&QueryingAA);
- return AA;
+ // Do not return an attribute with an invalid state. This minimizes checks
+ // at the calls sites and allows the fallback below to kick in.
+ if (AA->getState().isValidState()) {
+ QueryMap[AA].insert(&QueryingAA);
+ return AA;
+ }
}
// If no abstract attribute was found and we look for a call site argument,
Modified: llvm/trunk/lib/Transforms/IPO/Attributor.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/Attributor.cpp?rev=365983&r1=365982&r2=365983&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/Attributor.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/Attributor.cpp Fri Jul 12 18:09:21 2019
@@ -655,7 +655,7 @@ ChangeStatus AAReturnedValuesImpl::updat
// Try to find a assumed unique return value for the called function.
auto *RetCSAA = A.getAAFor<AAReturnedValuesImpl>(*this, *RV);
- if (!RetCSAA || !RetCSAA->isValidState()) {
+ if (!RetCSAA) {
HasOverdefinedReturnedCalls = true;
LLVM_DEBUG(dbgs() << "[AAReturnedValues] Returned call site (" << *RV
<< ") with " << (RetCSAA ? "invalid" : "no")
@@ -965,8 +965,7 @@ ChangeStatus AANoFreeFunction::updateImp
auto ICS = ImmutableCallSite(I);
auto *NoFreeAA = A.getAAFor<AANoFreeFunction>(*this, *I);
- if ((!NoFreeAA || !NoFreeAA->isValidState() ||
- !NoFreeAA->isAssumedNoFree()) &&
+ if ((!NoFreeAA || !NoFreeAA->isAssumedNoFree()) &&
!ICS.hasFnAttr(Attribute::NoFree)) {
indicatePessimisticFixpoint();
return ChangeStatus::CHANGED;
More information about the llvm-commits
mailing list