]> granicus.if.org Git - llvm/commit
AMDGPU: Invert frame index offset interpretation
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Wed, 5 Jun 2019 22:20:47 +0000 (22:20 +0000)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Wed, 5 Jun 2019 22:20:47 +0000 (22:20 +0000)
commit63ff74f3d0911d9f0accf96e4ae3228c5e95e628
treea0102bb941762d25f0b0bfee9d36e230f0a0e131
parent7d91dcd8cbe174603404684c1626afa442b87e2e
AMDGPU: Invert frame index offset interpretation

Since the beginning, the offset of a frame index has been consistently
interpreted backwards. It was treating it as an offset from the
scratch wave offset register as a frame register. The correct
interpretation is the offset from the SP on entry to the function,
before the prolog. Frame index elimination then should select either
SP or another register as an FP.

Treat the scratch wave offset on kernel entry as the pre-incremented
SP. Rely more heavily on the standard hasFP and frame pointer
elimination logic, and clean up the private reservation code. This
saves a copy in most callee functions.

The kernel prolog emission code is still kind of a mess relying on
checking the uses of physical registers, which I would prefer to
eliminate.

Currently selection directly emits MUBUF instructions, which require
using a reference to some register. Use the register chosen for SP,
and then ignore this later. This should probably be cleaned up to use
pseudos that don't refer to any specific base register until frame
index elimination.

Add a workaround for shaders using large numbers of SGPRs. I'm not
sure these cases were ever working correctly, since as far as I can
tell the logic for figuring out which SGPR is the scratch wave offset
doesn't match up with the shader input initialization in the shader
programming guide.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362661 91177308-0d34-0410-b5e6-96231b3b80d8
30 files changed:
lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp
lib/Target/AMDGPU/AMDGPURegisterInfo.cpp
lib/Target/AMDGPU/SIFrameLowering.cpp
lib/Target/AMDGPU/SIFrameLowering.h
lib/Target/AMDGPU/SIISelLowering.cpp
lib/Target/AMDGPU/SIInstrInfo.cpp
lib/Target/AMDGPU/SIMachineFunctionInfo.h
lib/Target/AMDGPU/SIRegisterInfo.cpp
lib/Target/AMDGPU/SIRegisterInfo.h
test/CodeGen/AMDGPU/byval-frame-setup.ll
test/CodeGen/AMDGPU/call-argument-types.ll
test/CodeGen/AMDGPU/callee-frame-setup.ll
test/CodeGen/AMDGPU/callee-special-input-sgprs.ll
test/CodeGen/AMDGPU/callee-special-input-vgprs.ll
test/CodeGen/AMDGPU/frame-index-elimination.ll
test/CodeGen/AMDGPU/function-args.ll
test/CodeGen/AMDGPU/load-hi16.ll
test/CodeGen/AMDGPU/load-lo16.ll
test/CodeGen/AMDGPU/mubuf-legalize-operands.ll
test/CodeGen/AMDGPU/pei-reg-scavenger-position.mir
test/CodeGen/AMDGPU/sgpr-spill-wrong-stack-id.mir
test/CodeGen/AMDGPU/sibling-call.ll
test/CodeGen/AMDGPU/sp-too-many-input-sgprs.ll [new file with mode: 0644]
test/CodeGen/AMDGPU/spill-empty-live-interval.mir
test/CodeGen/AMDGPU/spill-offset-calculation.ll
test/CodeGen/AMDGPU/stack-realign.ll
test/CodeGen/AMDGPU/stack-slot-color-sgpr-vgpr-spills.mir
test/CodeGen/AMDGPU/store-hi16.ll
test/CodeGen/AMDGPU/subreg-split-live-in-error.mir
test/CodeGen/MIR/AMDGPU/machine-function-info.ll