AMDGPU/SI: Update LiveIntervals during SIFixSGPRLiveRanges
Does not mark SlotIndexes as reserved, although I think
that might be OK.
LiveVariables still need to be handled.
llvm-svn: 245133
diff --git a/llvm/lib/Target/AMDGPU/SIFixSGPRLiveRanges.cpp b/llvm/lib/Target/AMDGPU/SIFixSGPRLiveRanges.cpp
index b469898..b91649e 100644
--- a/llvm/lib/Target/AMDGPU/SIFixSGPRLiveRanges.cpp
+++ b/llvm/lib/Target/AMDGPU/SIFixSGPRLiveRanges.cpp
@@ -81,6 +81,10 @@
AU.addRequired<LiveIntervals>();
AU.addRequired<MachinePostDominatorTree>();
AU.setPreservesCFG();
+
+ //AU.addPreserved<SlotIndexes>(); // XXX - This might be OK
+ AU.addPreserved<LiveIntervals>();
+
MachineFunctionPass::getAnalysisUsage(AU);
}
};
@@ -181,10 +185,15 @@
// FIXME: Need to figure out how to update LiveRange here so this pass
// will be able to preserve LiveInterval analysis.
- BuildMI(*NCD, NCD->getFirstNonPHI(), DebugLoc(),
- TII->get(AMDGPU::SGPR_USE))
- .addReg(Reg, RegState::Implicit);
- DEBUG(NCD->getFirstNonPHI()->dump());
+ MachineInstr *NCDSGPRUse =
+ BuildMI(*NCD, NCD->getFirstNonPHI(), DebugLoc(),
+ TII->get(AMDGPU::SGPR_USE))
+ .addReg(Reg, RegState::Implicit);
+
+ SlotIndex SI = LIS->InsertMachineInstrInMaps(NCDSGPRUse);
+ LIS->extendToIndices(*LR, SI.getRegSlot());
+
+ DEBUG(NCDSGPRUse->dump());
}
}