Skip to content

Commit c1c9b84

Browse files
Kotynia, Piotrigcbot
authored andcommitted
Add 0x10000000 bit to SLM addreses
Make sure that high bit indicating non-null offset is added. It is needed for GDB to correctly read from SLM memory.
1 parent 89f23d7 commit c1c9b84

File tree

5 files changed

+11
-12
lines changed

5 files changed

+11
-12
lines changed

IGC/Compiler/DebugInfo/ScalarVISAModule.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ SPDX-License-Identifier: MIT
99
#include "Compiler/DebugInfo/ScalarVISAModule.h"
1010
#include "Compiler/DebugInfo/Utils.h"
1111
#include "Compiler/Optimizer/OpenCLPasses/KernelArgs/KernelArgs.hpp"
12+
#include "Compiler/Optimizer/OpenCLPasses/PrivateMemory/PrivateMemoryToSLM.hpp"
1213
#include "Compiler/CISACodeGen/ShaderCodeGen.hpp"
1314
#include "GenISAIntrinsics/GenIntrinsicInst.h"
1415
#include "common/debug/Debug.hpp"
@@ -491,6 +492,7 @@ ScalarVisaModule::GetVariableLocation(const llvm::Instruction* pInst) const
491492
if (isa<GlobalVariable>(pVal))
492493
{
493494
unsigned int offset = m_pShader->GetSLMMappingValue(pVal);
495+
offset |= VALID_LOCAL_HIGH_BITS;
494496
return VISAVariableLocation(offset, true, this);
495497
}
496498

IGC/Compiler/Optimizer/OpenCLPasses/LocalBuffers/InlineLocalsResolution.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ SPDX-License-Identifier: MIT
88

99
#include "AdaptorCommon/ImplicitArgs.hpp"
1010
#include "Compiler/Optimizer/OpenCLPasses/LocalBuffers/InlineLocalsResolution.hpp"
11+
#include "Compiler/Optimizer/OpenCLPasses/PrivateMemory/PrivateMemoryToSLM.hpp"
1112
#include "Compiler/CodeGenPublic.h"
1213
#include "Compiler/IGCPassSupport.h"
1314
#include "Compiler/CISACodeGen/OpenCLKernelCodeGen.hpp"
@@ -45,8 +46,6 @@ InlineLocalsResolution::InlineLocalsResolution() :
4546
initializeInlineLocalsResolutionPass(*PassRegistry::getPassRegistry());
4647
}
4748

48-
const unsigned int InlineLocalsResolution::VALID_LOCAL_HIGH_BITS = 0x10000000;
49-
5049
static bool useAsPointerOnly(Value* V) {
5150
IGC_ASSERT_MESSAGE(V->getType()->isPointerTy(), "Expect the input value is a pointer!");
5251

IGC/Compiler/Optimizer/OpenCLPasses/LocalBuffers/InlineLocalsResolution.hpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,6 @@ namespace IGC
5858
AU.addRequired<llvm::CallGraphWrapperPass>();
5959
}
6060

61-
// It is convenient to represent the null pointer as the zero
62-
// bit-pattern. However, SLM address 0 is legal, and we want to be able
63-
// to use it.
64-
// To go around this, we use the fact only the low 16 bits ("low nibble")
65-
// of SLM addresses are significant, and set all valid pointers to have
66-
// a non-zero high nibble.
67-
static const unsigned int VALID_LOCAL_HIGH_BITS;
68-
6961
protected:
7062

7163
void filterGlobals(llvm::Module&);

IGC/Compiler/Optimizer/OpenCLPasses/PrivateMemory/PrivateMemoryToSLM.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ IGC_INITIALIZE_PASS_END(PrivateMemoryToSLM, PASS_FLAG, PASS_DESCRIPTION, PASS_CF
4040
namespace IGC
4141
{
4242
char PrivateMemoryToSLM::ID = 0;
43-
const unsigned int PrivateMemoryToSLM::VALID_LOCAL_HIGH_BITS = 0x10000000;
4443
const unsigned int PrivateMemoryToSLM::SLM_LOCAL_VARIABLE_ALIGNMENT = 4;
4544
const unsigned int PrivateMemoryToSLM::SLM_LOCAL_SIZE_ALIGNMENT = 32;
4645

IGC/Compiler/Optimizer/OpenCLPasses/PrivateMemory/PrivateMemoryToSLM.hpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ using namespace llvm;
1818

1919
namespace IGC
2020
{
21+
// It is convenient to represent the null pointer as the zero
22+
// bit-pattern. However, SLM address 0 is legal, and we want to be able
23+
// to use it.
24+
// To go around this, we use the fact only the low 16 bits ("low nibble")
25+
// of SLM addresses are significant, and set all valid pointers to have
26+
// a non-zero high nibble.
27+
static inline const unsigned int VALID_LOCAL_HIGH_BITS = 0x10000000;
28+
2129
// Experimental pass to move private memory allocations to SLM where it's
2230
// profitable. The pass is able to handle Compute and OpenCL shader types.
2331
class PrivateMemoryToSLM : public ModulePass
@@ -47,7 +55,6 @@ namespace IGC
4755

4856
virtual bool runOnModule(Module& M) override;
4957

50-
static const unsigned int VALID_LOCAL_HIGH_BITS;
5158
static const unsigned int SLM_LOCAL_VARIABLE_ALIGNMENT;
5259
static const unsigned int SLM_LOCAL_SIZE_ALIGNMENT;
5360

0 commit comments

Comments
 (0)