[AMDGPU] Fix incorrect register pressure calculation
authorStanislav Mekhanoshin <Stanislav.Mekhanoshin@amd.com>
Thu, 11 May 2017 17:16:55 +0000 (17:16 +0000)
committerStanislav Mekhanoshin <Stanislav.Mekhanoshin@amd.com>
Thu, 11 May 2017 17:16:55 +0000 (17:16 +0000)
Earlier fix D32572 introduced a bug where live-ins were calculated
for basic block instead of scheduling region. This change fixes it.

Differential Revision: https://reviews.llvm.org/D33086

llvm-svn: 302812

llvm/lib/Target/AMDGPU/GCNSchedStrategy.cpp

index 6304426..9f07d28 100644 (file)
@@ -422,9 +422,10 @@ void GCNScheduleDAGMILive::discoverLiveIns() {
   unsigned SGPRs = 0;
   unsigned VGPRs = 0;
 
-  auto &MI = *begin()->getParent()->getFirstNonDebugInstr();
+  auto I = begin();
+  I = skipDebugInstructionsForward(I, I->getParent()->end());
   const SIRegisterInfo *SRI = static_cast<const SIRegisterInfo*>(TRI);
-  SlotIndex SI = LIS->getInstructionIndex(MI).getBaseIndex();
+  SlotIndex SI = LIS->getInstructionIndex(*I).getBaseIndex();
   assert (SI.isValid());
 
   DEBUG(dbgs() << "Region live-ins:");