[PATCH] D13185: Scheduler / Regalloc: use unique_ptr[] instead of std::vector

Matthias Braun via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 25 17:42:28 PDT 2015


MatzeB added a comment.

Given that the vectors are fixed size I don't see why we would need the additional complexity of std::vector (it has to manage the size and capacity, ...).  To me this change looks good with the nitpicks below addressed.

Of course it's bad that llvm doesn't get the vector initialisation optimized, but this is a separate issue, would you agree David?


================
Comment at: lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp:1221
@@ -1220,3 +1220,3 @@
 static void CheckForLiveRegDef(SUnit *SU, unsigned Reg,
-                               std::vector<SUnit*> &LiveRegDefs,
+                               std::unique_ptr<SUnit*[]> &LiveRegDefs,
                                SmallSet<unsigned, 4> &RegAdded,
----------------
This can be a simple SUnit * now.

================
Comment at: lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp:1243-1246
@@ -1242,5 +1242,6 @@
 static void CheckForLiveRegDefMasked(SUnit *SU, const uint32_t *RegMask,
-                                     std::vector<SUnit*> &LiveRegDefs,
+                                     std::unique_ptr<SUnit*[]> &LiveRegDefs,
                                      SmallSet<unsigned, 4> &RegAdded,
-                                     SmallVectorImpl<unsigned> &LRegs) {
+                                     SmallVectorImpl<unsigned> &LRegs,
+                                     unsigned NumRegs) {
   // Look at all live registers. Skip Reg0 and the special CallResource.
----------------
This could use an ArrayRef<SUnit*> instead of std::unique_ptr reference + NumRegs.


Repository:
  rL LLVM

http://reviews.llvm.org/D13185





More information about the llvm-commits mailing list