[PATCH] D145512: [Assignment Tracking][NFC] Reuse BlockInfo rather than re-allocating each in iteration

Orlando Cazalet-Hyams via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 7 08:37:03 PST 2023


Orlando created this revision.
Orlando added reviewers: scott.linder, jmorse, StephenTozer.
Orlando added a project: debug-info.
Herald added a subscriber: hiraditya.
Herald added a project: All.
Orlando requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This has a slight positive impact on the CTMark project compile times.


https://reviews.llvm.org/D145512

Files:
  llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp


Index: llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
===================================================================
--- llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
+++ llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
@@ -1034,6 +1034,11 @@
       return LiveLoc.size() == DebugValue.size() &&
              LiveLoc.size() == StackHomeValue.size();
     }
+    void clear() {
+      StackHomeValue.clear();
+      DebugValue.clear();
+      LiveLoc.clear();
+    }
   };
 
   Function &Fn;
@@ -1082,7 +1087,7 @@
   static Assignment joinAssignment(const Assignment &A, const Assignment &B);
   static AssignmentMap joinAssignmentMap(const AssignmentMap &A,
                                          const AssignmentMap &B);
-  static BlockInfo joinBlockInfo(const BlockInfo &A, const BlockInfo &B);
+  static void joinBlockInfo(BlockInfo &Result, const BlockInfo &A, const BlockInfo &B);
   ///@}
 
   /// Process the instructions in \p BB updating \p LiveSet along the way. \p
@@ -1746,15 +1751,14 @@
   return Join;
 }
 
-AssignmentTrackingLowering::BlockInfo
-AssignmentTrackingLowering::joinBlockInfo(const BlockInfo &A,
+void AssignmentTrackingLowering::joinBlockInfo(BlockInfo &Join,
+                                          const BlockInfo &A,
                                           const BlockInfo &B) {
-  BlockInfo Join;
+  Join.clear();
   Join.LiveLoc = joinLocMap(A.LiveLoc, B.LiveLoc);
   Join.StackHomeValue = joinAssignmentMap(A.StackHomeValue, B.StackHomeValue);
   Join.DebugValue = joinAssignmentMap(A.DebugValue, B.DebugValue);
   assert(Join.isValid());
-  return Join;
 }
 
 bool AssignmentTrackingLowering::join(
@@ -1800,7 +1804,8 @@
   assert(VisitedPreds.size() > 1);
   const BlockInfo &PredLiveOut0 = LiveOut.find(VisitedPreds[0])->second;
   const BlockInfo &PredLiveOut1 = LiveOut.find(VisitedPreds[1])->second;
-  BlockInfo BBLiveIn = joinBlockInfo(PredLiveOut0, PredLiveOut1);
+  BlockInfo BBLiveIn;
+  joinBlockInfo(BBLiveIn, PredLiveOut0, PredLiveOut1);
 
   ArrayRef Tail = [&]() {
     auto *It = VisitedPreds.begin();
@@ -1813,7 +1818,7 @@
     const auto &PredLiveOut = LiveOut.find(Pred);
     assert(PredLiveOut != LiveOut.end() &&
            "block should have been processed already");
-    BBLiveIn = joinBlockInfo(std::move(BBLiveIn), PredLiveOut->second);
+    joinBlockInfo(BBLiveIn, std::move(BBLiveIn), PredLiveOut->second);
   }
 
   // Save the joined result for BB.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145512.503062.patch
Type: text/x-patch
Size: 2433 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230307/df68794e/attachment.bin>


More information about the llvm-commits mailing list