[PATCH] D66484: [Attributor][NFCI] Avoid lookups when resolving returned values

Johannes Doerfert via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 23 08:43:47 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL369770: [Attributor][NFCI] Avoid lookups when resolving returned values (authored by jdoerfert, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D66484?vs=216473&id=216868#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66484/new/

https://reviews.llvm.org/D66484

Files:
  llvm/trunk/lib/Transforms/IPO/Attributor.cpp


Index: llvm/trunk/lib/Transforms/IPO/Attributor.cpp
===================================================================
--- llvm/trunk/lib/Transforms/IPO/Attributor.cpp
+++ llvm/trunk/lib/Transforms/IPO/Attributor.cpp
@@ -682,13 +682,18 @@
   /// 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 @@
   /// See AbstractState::indicateOptimisticFixpoint(...).
   ChangeStatus indicateOptimisticFixpoint() override {
     IsFixed = true;
-    IsValidState &= true;
     return ChangeStatus::UNCHANGED;
   }
 
@@ -974,6 +978,15 @@
     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)) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66484.216868.patch
Type: text/x-patch
Size: 1649 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190823/fe97a313/attachment.bin>


More information about the llvm-commits mailing list