[llvm] r369770 - [Attributor][NFCI] Avoid lookups when resolving returned values
Johannes Doerfert via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 23 08:42:20 PDT 2019
Author: jdoerfert
Date: Fri Aug 23 08:42:19 2019
New Revision: 369770
URL: http://llvm.org/viewvc/llvm-project?rev=369770&view=rev
Log:
[Attributor][NFCI] Avoid lookups when resolving returned values
If the number of potentially returned values not change since the last
traversal we do not need to visit the returned values again. This works
as we only add values to the returned values set now.
Differential Revision: https://reviews.llvm.org/D66484
Modified:
llvm/trunk/lib/Transforms/IPO/Attributor.cpp
Modified: llvm/trunk/lib/Transforms/IPO/Attributor.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/Attributor.cpp?rev=369770&r1=369769&r2=369770&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/Attributor.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/Attributor.cpp Fri Aug 23 08:42:19 2019
@@ -682,13 +682,18 @@ class AAReturnedValuesImpl : public AARe
/// return instructions that might return them.
DenseMap<Value *, SmallSetVector<ReturnInst *, 4>> ReturnedValues;
+ /// Mapping to remember the number of returned values for a call site such
+ /// that we can avoid updates if nothing changed.
+ DenseMap<const CallBase *, unsigned> NumReturnedValuesPerKnownAA;
+
+ /// Set of unresolved calls returned by the associated function.
SmallSetVector<CallBase *, 4> UnresolvedCalls;
/// State flags
///
///{
- bool IsFixed;
- bool IsValidState;
+ bool IsFixed = false;
+ bool IsValidState = true;
///}
public:
@@ -774,7 +779,6 @@ public:
/// See AbstractState::indicateOptimisticFixpoint(...).
ChangeStatus indicateOptimisticFixpoint() override {
IsFixed = true;
- IsValidState &= true;
return ChangeStatus::UNCHANGED;
}
@@ -974,6 +978,15 @@ ChangeStatus AAReturnedValuesImpl::updat
if (Unresolved)
continue;
+ // Now track transitively returned values.
+ unsigned &NumRetAA = NumReturnedValuesPerKnownAA[CB];
+ if (NumRetAA == RetValAA.getNumReturnValues()) {
+ LLVM_DEBUG(dbgs() << "[AAReturnedValues] Skip call as it has not "
+ "changed since it was seen last\n");
+ continue;
+ }
+ NumRetAA = RetValAA.getNumReturnValues();
+
for (auto &RetValAAIt : RetValAA.returned_values()) {
Value *RetVal = RetValAAIt.first;
if (Argument *Arg = dyn_cast<Argument>(RetVal)) {
More information about the llvm-commits
mailing list