[PATCH] Speed up creation of live ranges for physical registers by using a segment set

Gerolf Hoflehner ghoflehner at apple.com
Wed Nov 12 17:47:06 PST 2014


================
Comment at: include/llvm/CodeGen/LiveInterval.h:427
@@ -406,3 +426,3 @@
 
     /// extendInBlock - If this range is live before Kill in the basic block
     /// that starts at StartIdx, extend it to be live up to Kill, and return
----------------
We don't repeat the function names in comments anymore.

================
Comment at: include/llvm/CodeGen/LiveIntervalAnalysis.h:386
@@ -385,1 +385,3 @@
+        // use segment set to speed-up initial computation of the live range
+        LR->createSegmentSet();
         computeRegUnitRange(*LR, Unit);
----------------
Since the focus is on speeding up computeRegUnitRange() is seems cleaner to handle both the segment set allocation and flushing locally within that function. This will also remove the asymmetry in your code where some calls are enclosed by createSegment() + flush(), while for others (ok, I only see one more) creation and flush are separate.

================
Comment at: lib/CodeGen/LiveInterval.cpp:55
@@ -54,1 +54,3 @@
   assert(!Def.isDead() && "Cannot define a value at the dead slot");
+
+  // if segmentSet exists use it instead of the vector
----------------
This is for the createDeadDef() call in computeRegUnitRange() only, right? Why not replace the call there directly with the call to the segmentSet function and remove this check?

================
Comment at: lib/CodeGen/LiveInterval.cpp:340
@@ -332,1 +339,3 @@
 VNInfo *LiveRange::extendInBlock(SlotIndex StartIdx, SlotIndex Kill) {
+  // if the segment set exists, use it instead of the segment vector
+  if (segmentSet != NULL) {
----------------
Same as for createDeadDef().

================
Comment at: lib/CodeGen/LiveInterval.cpp:606
@@ +605,3 @@
+// analogous to find, but works with segment set instead of segment vector
+LiveRange::SegmentSet::iterator LiveRange::segsetFind(SlotIndex Pos) {
+  SegmentSet::iterator I = segmentSet->upper_bound(Segment(Pos, Pos.getNextSlot(), NULL));
----------------
I guess you could have templates for some of the segment set/segment utility routines if you wanted to push your design a bit. That would take care of some of the static code bloat.

================
Comment at: lib/CodeGen/LiveInterval.cpp:945
@@ -725,1 +944,3 @@
 
+  // fall back to the regular add method if the live range
+  // is using the segment set instead of the segment vector
----------------
Hm. This looks like more changes than just adding a new data structure to handle live ranges calcs more efficiently. The existing updater checks for coalescing and spilling, while addSegment() does not. Please add a more detailed comment about the differences. Up until this point I was optimistic that the implementation could be cleaned up quite a bit, but now I'm not so sure anymore.

http://reviews.llvm.org/D6013






More information about the llvm-commits mailing list