AMDGPU/SI: Update LiveIntervals during SIFixSGPRLiveRanges
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Sat, 15 Aug 2015 00:12:35 +0000 (00:12 +0000)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Sat, 15 Aug 2015 00:12:35 +0000 (00:12 +0000)
Does not mark SlotIndexes as reserved, although I think
that might be OK.

LiveVariables still need to be handled.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@245133 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/AMDGPU/SIFixSGPRLiveRanges.cpp

index b469898bef514af31153dfcb7460dc6b821297b8..b91649e54f94513684df2f1cb8f3c3c7157ce003 100644 (file)
@@ -81,6 +81,10 @@ public:
     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 @@ bool SIFixSGPRLiveRanges::runOnMachineFunction(MachineFunction &MF) {
 
       // 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());
     }
   }