Index: lib/Target/AMDGPU/SIFixSGPRLiveRanges.cpp =================================================================== --- lib/Target/AMDGPU/SIFixSGPRLiveRanges.cpp +++ lib/Target/AMDGPU/SIFixSGPRLiveRanges.cpp @@ -81,6 +81,10 @@ AU.addRequired(); AU.addRequired(); AU.setPreservesCFG(); + + //AU.addPreserved(); // XXX - This might be OK + AU.addPreserved(); + MachineFunctionPass::getAnalysisUsage(AU); } }; @@ -194,10 +198,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()); } }