diff options
author | Tom Stellard <thomas.stellard@amd.com> | 2013-09-05 18:37:57 +0000 |
---|---|---|
committer | Tom Stellard <thomas.stellard@amd.com> | 2013-09-05 18:37:57 +0000 |
commit | 470c451574609adcaab9b279cc74c6ff0f91b00f (patch) | |
tree | 6c97cb8087c7d2a95a5fc784ac0c1232e675c927 /lib | |
parent | 402b8e2175dc926eef664ec03bd61c7922a50447 (diff) | |
download | external_llvm-470c451574609adcaab9b279cc74c6ff0f91b00f.zip external_llvm-470c451574609adcaab9b279cc74c6ff0f91b00f.tar.gz external_llvm-470c451574609adcaab9b279cc74c6ff0f91b00f.tar.bz2 |
R600: Fix incorrect LDS size calculation
GlobalAdderss nodes that appeared in more than one basic block were
being counted twice.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190078 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Target/R600/AMDGPUISelLowering.cpp | 14 | ||||
-rw-r--r-- | lib/Target/R600/AMDGPUMachineFunction.h | 4 |
2 files changed, 14 insertions, 4 deletions
diff --git a/lib/Target/R600/AMDGPUISelLowering.cpp b/lib/Target/R600/AMDGPUISelLowering.cpp index 1237323..d6b7cbe 100644 --- a/lib/Target/R600/AMDGPUISelLowering.cpp +++ b/lib/Target/R600/AMDGPUISelLowering.cpp @@ -246,12 +246,18 @@ SDValue AMDGPUTargetLowering::LowerGlobalAddress(AMDGPUMachineFunction* MFI, assert(G->getOffset() == 0 && "Do not know what to do with an non-zero offset"); - unsigned Offset = MFI->LDSSize; const GlobalValue *GV = G->getGlobal(); - uint64_t Size = TD->getTypeAllocSize(GV->getType()->getElementType()); - // XXX: Account for alignment? - MFI->LDSSize += Size; + unsigned Offset; + if (MFI->LocalMemoryObjects.count(GV) == 0) { + uint64_t Size = TD->getTypeAllocSize(GV->getType()->getElementType()); + Offset = MFI->LDSSize; + MFI->LocalMemoryObjects[GV] = Offset; + // XXX: Account for alignment? + MFI->LDSSize += Size; + } else { + Offset = MFI->LocalMemoryObjects[GV]; + } return DAG.getConstant(Offset, getPointerTy(G->getAddressSpace())); } diff --git a/lib/Target/R600/AMDGPUMachineFunction.h b/lib/Target/R600/AMDGPUMachineFunction.h index 789b96a..fe80ce3 100644 --- a/lib/Target/R600/AMDGPUMachineFunction.h +++ b/lib/Target/R600/AMDGPUMachineFunction.h @@ -14,6 +14,7 @@ #define AMDGPUMACHINEFUNCTION_H #include "llvm/CodeGen/MachineFunction.h" +#include <map> namespace llvm { @@ -21,6 +22,9 @@ class AMDGPUMachineFunction : public MachineFunctionInfo { public: AMDGPUMachineFunction(const MachineFunction &MF); unsigned ShaderType; + /// A map to keep track of local memory objects and their offsets within + /// the local memory space. + std::map<const GlobalValue *, unsigned> LocalMemoryObjects; /// Number of bytes in the LDS that are being used. unsigned LDSSize; }; |