From da4d81170796a20e1739032897f6ed975c4821f9 Mon Sep 17 00:00:00 2001 From: Johannes Doerfert Date: Thu, 1 Aug 2019 16:21:54 +0000 Subject: [PATCH] [Attributor][FIX] Indicate a missing update change User of AAReturnedValues need to know if HasOverdefinedReturnedCalls changed from false to true as it will impact the result of the return value traversal (calls are not ignored anymore). This will be tested with the tests in D59978. llvm-svn: 367581 --- llvm/lib/Transforms/IPO/Attributor.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp index 6a7e76a..d8b8fe2 100644 --- a/llvm/lib/Transforms/IPO/Attributor.cpp +++ b/llvm/lib/Transforms/IPO/Attributor.cpp @@ -722,6 +722,9 @@ ChangeStatus AAReturnedValuesImpl::updateImpl(Attributor &A) { decltype(ReturnedValues) AddRVs; bool HasCallSite = false; + // Keep track of any change to trigger updates on dependent attributes. + ChangeStatus Changed = ChangeStatus::UNCHANGED; + // Look at all returned call sites. for (auto &It : ReturnedValues) { SmallPtrSet &ReturnInsts = It.second; @@ -742,6 +745,8 @@ ChangeStatus AAReturnedValuesImpl::updateImpl(Attributor &A) { // Try to find a assumed unique return value for the called function. auto *RetCSAA = A.getAAFor(*this, *RV); if (!RetCSAA) { + if (!HasOverdefinedReturnedCalls) + Changed = ChangeStatus::CHANGED; HasOverdefinedReturnedCalls = true; LLVM_DEBUG(dbgs() << "[AAReturnedValues] Returned call site (" << *RV << ") with " << (RetCSAA ? "invalid" : "no") @@ -763,6 +768,8 @@ ChangeStatus AAReturnedValuesImpl::updateImpl(Attributor &A) { // If multiple, non-refinable values were found, there cannot be a unique // return value for the called function. The returned call is overdefined! if (!AssumedUniqueRV.getValue()) { + if (!HasOverdefinedReturnedCalls) + Changed = ChangeStatus::CHANGED; HasOverdefinedReturnedCalls = true; LLVM_DEBUG(dbgs() << "[AAReturnedValues] Returned call site has multiple " "potentially returned values\n"); @@ -791,9 +798,6 @@ ChangeStatus AAReturnedValuesImpl::updateImpl(Attributor &A) { AddRVs[AssumedRetVal].insert(ReturnInsts.begin(), ReturnInsts.end()); } - // Keep track of any change to trigger updates on dependent attributes. - ChangeStatus Changed = ChangeStatus::UNCHANGED; - for (auto &It : AddRVs) { assert(!It.second.empty() && "Entry does not add anything."); auto &ReturnInsts = ReturnedValues[It.first]; -- 2.7.4