[StatepointLowering] Update StatepointMaxSlotsRequired correctly
authorSanjoy Das <sanjoy@playingwithpointers.com>
Fri, 19 Feb 2016 18:15:56 +0000 (18:15 +0000)
committerSanjoy Das <sanjoy@playingwithpointers.com>
Fri, 19 Feb 2016 18:15:56 +0000 (18:15 +0000)
Now that we don't always add an element to AllocatedStackSlots if we
don't find a pre-existing unallocated stack slot, bumping
StatepointMaxSlotsRequired to `NumSlots + 1` is not correct.  Instead
bump the statistic near the push_back, to
Builder.FuncInfo.StatepointStackSlots.size().

llvm-svn: 261348

llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp

index 37f74cb9d7004179cb9d214e034769446533ec60..1e9d0ef794cdb2c807de31e9ee8b620e95ad9ccb 100644 (file)
@@ -99,14 +99,15 @@ StatepointLoweringState::allocateStackSlot(EVT ValueType,
 
   // Couldn't find a free slot, so create a new one:
 
-  StatepointMaxSlotsRequired =
-       std::max<unsigned long>(StatepointMaxSlotsRequired, NumSlots + 1);
-
   SDValue SpillSlot = Builder.DAG.CreateStackTemporary(ValueType);
   const unsigned FI = cast<FrameIndexSDNode>(SpillSlot)->getIndex();
   MFI->markAsStatepointSpillSlotObjectIndex(FI);
 
   Builder.FuncInfo.StatepointStackSlots.push_back(FI);
+
+  StatepointMaxSlotsRequired = std::max<unsigned long>(
+      StatepointMaxSlotsRequired, Builder.FuncInfo.StatepointStackSlots.size());
+
   return SpillSlot;
 }