diff options
author | Tom Stellard <thomas.stellard@amd.com> | 2014-01-22 19:24:23 +0000 |
---|---|---|
committer | Tom Stellard <thomas.stellard@amd.com> | 2014-01-22 19:24:23 +0000 |
commit | 598f3945c0ce46b1d2690cb1b0a24df90d2fc0b1 (patch) | |
tree | 48d31a1542fda9a5e1a5eed9d488543ef53ddf15 /llvm/lib/Target/R600/AMDGPUFrameLowering.cpp | |
parent | 04c0e9851b7fdf82fa3bfac2db9496bfed23eee8 (diff) | |
download | llvm-598f3945c0ce46b1d2690cb1b0a24df90d2fc0b1.zip llvm-598f3945c0ce46b1d2690cb1b0a24df90d2fc0b1.tar.gz llvm-598f3945c0ce46b1d2690cb1b0a24df90d2fc0b1.tar.bz2 |
R600: Take alignment into account when calculating the stack offset
llvm-svn: 199826
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 40cc908..0325a00 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 * |