]> granicus.if.org Git - llvm/commitdiff
[AMDGPU] Fix Livereg computation during epilogue insertion
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Wed, 26 Jun 2019 20:35:18 +0000 (20:35 +0000)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Wed, 26 Jun 2019 20:35:18 +0000 (20:35 +0000)
The LivePhysRegs calculated in order to find a scratch register in the
epilogue code wrongly uses 'LiveIns'. Instead, it should use the
'Liveout' sets.  For the liveness, also considering the operands of
the terminator (return) instruction which is the insertion point for
the scratch-exec-copy instruction.

Patch by Christudasan Devadasan

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

lib/Target/AMDGPU/SIFrameLowering.cpp
test/CodeGen/AMDGPU/callee-special-input-sgprs.ll

index 098152b23aac283695fae7f1321baf81d17532d3..3ed6d75c045d4ba337af8591713f1a7d0ef3399c 100644 (file)
@@ -678,7 +678,8 @@ void SIFrameLowering::emitEpilogue(MachineFunction &MF,
     if (ScratchExecCopy == AMDGPU::NoRegister) {
       // See emitPrologue
       LivePhysRegs LiveRegs(*ST.getRegisterInfo());
-      LiveRegs.addLiveIns(MBB);
+      LiveRegs.addLiveOuts(MBB);
+      LiveRegs.stepBackward(*MBBI);
 
       ScratchExecCopy
         = findScratchNonCalleeSaveRegister(MF, LiveRegs,
index 5368eb20300b13e70c00f0b0ca23e55262dd632a..ba099c33fc2b8eb6e0ed0e48ce2631a84a801b22 100644 (file)
@@ -489,6 +489,7 @@ define amdgpu_kernel void @kern_indirect_use_every_sgpr_input() #1 {
 ; GCN-NOT: s[8:9]
 ; GCN-NOT: s[10:11]
 ; GCN-NOT: s[12:13]
+; GCN: s_or_saveexec_b64 s[6:7], -1
 define hidden void @func_indirect_use_every_sgpr_input() #1 {
   call void @use_every_sgpr_input()
   ret void