diff options
Diffstat (limited to 'llvm/lib/Target/R600/AMDGPUFrameLowering.cpp')
| -rw-r--r-- | llvm/lib/Target/R600/AMDGPUFrameLowering.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/llvm/lib/Target/R600/AMDGPUFrameLowering.cpp b/llvm/lib/Target/R600/AMDGPUFrameLowering.cpp index 40cc9083c00..0325a00c177 100644 --- a/llvm/lib/Target/R600/AMDGPUFrameLowering.cpp +++ b/llvm/lib/Target/R600/AMDGPUFrameLowering.cpp @@ -77,14 +77,21 @@ int AMDGPUFrameLowering::getFrameIndexOffset(const MachineFunction &MF, // Start the offset at 2 so we don't overwrite work group information. // XXX: We should only do this when the shader actually uses this // information. - unsigned Offset = 2; + unsigned OffsetBytes = 2 * (getStackWidth(MF) * 4); int UpperBound = FI == -1 ? MFI->getNumObjects() : FI; for (int i = MFI->getObjectIndexBegin(); i < UpperBound; ++i) { - unsigned Size = MFI->getObjectSize(i); - Offset += (Size / (getStackWidth(MF) * 4)); + OffsetBytes = RoundUpToAlignment(OffsetBytes, MFI->getObjectAlignment(i)); + OffsetBytes += MFI->getObjectSize(i); + // Each regiter holds 4 bytes, so we must always align the offset to at + // least 4 bytes, so that 2 frame objects won't share the same register. + OffsetBytes = RoundUpToAlignment(OffsetBytes, 4); } - return Offset; + + if (FI != -1) + OffsetBytes = RoundUpToAlignment(OffsetBytes, MFI->getObjectAlignment(FI)); + + return OffsetBytes / (getStackWidth(MF) * 4); } const TargetFrameLowering::SpillSlot * |

