Skip to content

Commit 5596ef9

Browse files
mtargowsigcbot
authored andcommitted
[Autobackout][FuncReg]Revert of change: b4ebf95
Enable __ocl_dbg_* variables in -O2 -g. If not used in a program, then __ocl_dbg_* variables could be available in -O0 -g compilation only. Now it is enabled also in -O2 -g compilation when -cl-kernel-debug-enable is set.
1 parent 8b5752f commit 5596ef9

File tree

14 files changed

+12
-319
lines changed

14 files changed

+12
-319
lines changed

IGC/AdaptorOCL/UnifyIROCL.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ SPDX-License-Identifier: MIT
4747
#include "Compiler/Optimizer/CodeAssumption.hpp"
4848
#include "Compiler/Optimizer/Scalarizer.h"
4949
#include "Compiler/Optimizer/OpenCLPasses/DebuggerSupport/ImplicitGIDPass.hpp"
50-
#include "Compiler/Optimizer/OpenCLPasses/DebuggerSupport/ImplicitGIDRestoring.hpp"
5150
#include "Compiler/Optimizer/OpenCLPasses/ExtenstionFuncs/ExtensionArgAnalysis.hpp"
5251
#include "Compiler/Optimizer/OpenCLPasses/ExtenstionFuncs/ExtensionFuncsAnalysis.hpp"
5352
#include "Compiler/Optimizer/OpenCLPasses/ExtenstionFuncs/ExtensionFuncResolution.hpp"
@@ -531,10 +530,6 @@ static void CommonOCLBasedPasses(
531530
// TODO: Run CheckInstrTypes after builtin import to determine if builtins have allocas.
532531
mpm.add(createSROAPass());
533532
mpm.add(createIGCInstructionCombiningPass());
534-
if (pContext->m_InternalOptions.KernelDebugEnable)
535-
{
536-
mpm.add(new ImplicitGIDRestoring());
537-
}
538533
// See the comment above (it's copied as is).
539534
// Instcombine can create constant expressions, which are not handled by the program scope constant resolution pass.
540535
// For example, in InsertDummyKernelForSymbolTablePass addresses of indirectly called functions

IGC/Compiler/CISACodeGen/CodeSinking.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -726,11 +726,8 @@ namespace IGC {
726726
// which is not really a local-code-motion
727727
if (def->getNextNode() != use && !isa<PHINode>(use))
728728
{
729-
if (!def->getMetadata("implicitGlobalID"))
730-
{
731-
def->moveBefore(use);
732-
madeChange = true;
733-
}
729+
def->moveBefore(use);
730+
madeChange = true;
734731
}
735732
localInstSet.erase(def);
736733
}

IGC/Compiler/CISACodeGen/DebugInfo.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -377,10 +377,6 @@ void DebugInfoData::markOutputVar(CShader* pShader, IDebugEmitter* pDebugEmitter
377377
IGC_ASSERT_MESSAGE(IGC_IS_FLAG_ENABLED(UseOffsetInLocation), "UseOffsetInLocation not enabled");
378378
IGC_ASSERT_MESSAGE(pInst, "Missing instruction");
379379

380-
// No dummy instruction needs to be marked with "Output"
381-
if (dyn_cast<GenIntrinsicInst>(pValue))
382-
return;
383-
384380
CVariable* pVar = pShader->GetSymbol(pValue);
385381
if (pVar->GetVarType() == EVARTYPE_GENERAL)
386382
{
@@ -391,8 +387,7 @@ void DebugInfoData::markOutputVar(CShader* pShader, IDebugEmitter* pDebugEmitter
391387
// This will help debugger examine their values anywhere in the code till they
392388
// are in scope. However, emit "Output" attribute when -g and -cl-opt-disable
393389
// are both passed -g by itself shouldnt alter generated code.
394-
if (static_cast<OpenCLProgramContext*>(pShader->GetContext())->m_InternalOptions.KernelDebugEnable ||
395-
pShader->GetContext()->getModuleMetaData()->compOpt.OptDisable)
390+
if (pShader->GetContext()->getModuleMetaData()->compOpt.OptDisable)
396391
{
397392
// If "Output" attribute is emitted for perThreadOffset variable(s)
398393
// then debug info emission is preserved for this:

IGC/Compiler/CISACodeGen/EmitVISAPass.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9630,8 +9630,6 @@ void EmitPass::EmitGenIntrinsicMessage(llvm::GenIntrinsicInst* inst)
96309630
case GenISAIntrinsic::GenISA_dummyInst:
96319631
emitDummyInst(inst);
96329632
break;
9633-
case GenISAIntrinsic::GenISA_dummyInstID:
9634-
break; // pseudo instruction, do nothing
96359633
case GenISAIntrinsic::GenISA_vectorUniform:
96369634
break; // pseudo instruction, do nothing
96379635
case GenISAIntrinsic::GenISA_staticConstantPatchValue:

IGC/Compiler/CISACodeGen/ShaderCodeGen.cpp

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ SPDX-License-Identifier: MIT
6767

6868
#include "Compiler/CISACodeGen/SLMConstProp.hpp"
6969
#include "Compiler/Optimizer/OpenCLPasses/DebuggerSupport/ImplicitGIDPass.hpp"
70-
#include "Compiler/Optimizer/OpenCLPasses/DebuggerSupport/ImplicitGIDRestoring.hpp"
7170
#include "Compiler/Optimizer/OpenCLPasses/GenericAddressResolution/GenericAddressDynamicResolution.hpp"
7271
#include "Compiler/Optimizer/OpenCLPasses/PrivateMemory/PrivateMemoryUsageAnalysis.hpp"
7372
#include "Compiler/Optimizer/OpenCLPasses/PrivateMemory/PrivateMemoryResolution.hpp"
@@ -667,11 +666,6 @@ static void AddLegalizationPasses(CodeGenContext& ctx, IGCPassManager& mpm, PSSi
667666
ctx.type == ShaderType::OPENCL_SHADER;
668667
mpm.add(createMemOptPass(AllowNegativeSymPtrsForLoad));
669668
mpm.add(createIGCInstructionCombiningPass());
670-
if (ctx.type == ShaderType::OPENCL_SHADER &&
671-
static_cast<OpenCLProgramContext&>(ctx).m_InternalOptions.KernelDebugEnable)
672-
{
673-
mpm.add(new ImplicitGIDRestoring());
674-
}
675669
}
676670

677671
if (ctx.type == ShaderType::OPENCL_SHADER &&
@@ -764,11 +758,6 @@ static void AddLegalizationPasses(CodeGenContext& ctx, IGCPassManager& mpm, PSSi
764758
if (!fastCompile && !highAllocaPressure && !isPotentialHPCKernel)
765759
{
766760
mpm.add(createIGCInstructionCombiningPass());
767-
if (ctx.type == ShaderType::OPENCL_SHADER &&
768-
static_cast<OpenCLProgramContext&>(ctx).m_InternalOptions.KernelDebugEnable)
769-
{
770-
mpm.add(new ImplicitGIDRestoring());
771-
}
772761
}
773762
mpm.add(new GenSpecificPattern());
774763
// Cases with DPDivSqrtEmu grow significantly.
@@ -1836,11 +1825,6 @@ void OptimizeIR(CodeGenContext* const pContext)
18361825
}
18371826

18381827
mpm.add(createIGCInstructionCombiningPass());
1839-
if (pContext->type == ShaderType::OPENCL_SHADER &&
1840-
static_cast<OpenCLProgramContext*>(pContext)->m_InternalOptions.KernelDebugEnable)
1841-
{
1842-
mpm.add(new ImplicitGIDRestoring());
1843-
}
18441828
mpm.add(new FCmpPaternMatch());
18451829
mpm.add(llvm::createDeadCodeEliminationPass()); // this should be done both before/after constant propagation
18461830

@@ -1898,11 +1882,6 @@ void OptimizeIR(CodeGenContext* const pContext)
18981882
}
18991883

19001884
mpm.add(createIGCInstructionCombiningPass());
1901-
if (pContext->type == ShaderType::OPENCL_SHADER &&
1902-
static_cast<OpenCLProgramContext*>(pContext)->m_InternalOptions.KernelDebugEnable)
1903-
{
1904-
mpm.add(new ImplicitGIDRestoring());
1905-
}
19061885
if (IGC_IS_FLAG_ENABLED(EnableAdvCodeMotion) &&
19071886
pContext->type == ShaderType::OPENCL_SHADER &&
19081887
!pContext->m_instrTypes.hasSwitch)
@@ -2040,11 +2019,6 @@ void OptimizeIR(CodeGenContext* const pContext)
20402019

20412020
// run instruction combining to clean up the code after CFG optimizations
20422021
mpm.add(createIGCInstructionCombiningPass());
2043-
if (pContext->type == ShaderType::OPENCL_SHADER &&
2044-
static_cast<OpenCLProgramContext*>(pContext)->m_InternalOptions.KernelDebugEnable)
2045-
{
2046-
mpm.add(new ImplicitGIDRestoring());
2047-
}
20482022

20492023
mpm.add(llvm::createDeadCodeEliminationPass());
20502024
mpm.add(llvm::createEarlyCSEPass());

IGC/Compiler/DebugInfo/Utils.cpp

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -117,33 +117,6 @@ namespace Utils {
117117
return nullptr;
118118
}
119119

120-
unsigned int GetSpecialDebugVariableHash(const std::string& name)
121-
{
122-
// Calculate hash index for OCL special debug variables:
123-
// 0 for __ocl_dbg_gid0
124-
// 1 for __ocl_dbg_gid1
125-
// 2 for __ocl_dbg_gid2
126-
// 3 for __ocl_dbg_lid0
127-
// 4 for __ocl_dbg_lid1
128-
// 5 for __ocl_dbg_lid2
129-
// 6 for __ocl_dbg_grid0
130-
// 7 for __ocl_dbg_grid1
131-
// 8 for __ocl_dbg_grid2
132-
133-
unsigned int idx = 0;
134-
135-
// 0 for ocl_dbg_gid*, so at position size-4 check only 'l' for lid and 'r' for grid
136-
size_t significantCharPos = name.size() - 4;
137-
if (name.at(significantCharPos) == 'l')
138-
idx = 3;
139-
else if (name.at(significantCharPos) == 'r')
140-
idx = 6;
141-
142-
idx += std::strtoul(name.substr(name.size() - 1).data(), nullptr, 0);
143-
144-
return idx;
145-
}
146-
147120
bool IsSpecialDebugVariable(const std::string& name)
148121
{
149122
// Check for OCL special debug variable such as:
@@ -154,26 +127,5 @@ namespace Utils {
154127
return (name.find("__ocl_dbg", 0) == 0);
155128
}
156129

157-
std::string GetSpecialVariableMetaName(const llvm::Instruction* inst)
158-
{
159-
// Check for OCL special debug variable such as in metadata
160-
// "preserve__ocl_dbg_gid0"
161-
// "preserve__ocl_dbg_gid1"
162-
// "preserve__ocl_dbg_gid2"
163-
std::string names[__OCL_DBG_VARIABLES] =
164-
{
165-
"__ocl_dbg_gid0", "__ocl_dbg_gid1", "__ocl_dbg_gid2",
166-
"__ocl_dbg_lid0", "__ocl_dbg_lid1", "__ocl_dbg_lid2",
167-
"__ocl_dbg_grid0", "__ocl_dbg_grid1", "__ocl_dbg_grid2"
168-
};
169-
170-
for (int i = 0; i < __OCL_DBG_VARIABLES; i++)
171-
{
172-
if (inst->getMetadata(names[i]))
173-
return names[i];
174-
}
175-
176-
return "";
177-
}
178130
} // namespace Utils
179131
} // namespace IGC

IGC/Compiler/DebugInfo/Utils.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ SPDX-License-Identifier: MIT
1919
namespace IGC {
2020
namespace Utils {
2121

22-
#define __OCL_DBG_VARIABLES 9
23-
2422
/// @brief return true if given module contain debug info
2523
/// @param M The LLVM module.
2624
/// @return true if given module contain debug info
@@ -38,9 +36,7 @@ namespace Utils {
3836
llvm::GlobalVariable* pGlobalVar, llvm::Value* pNewVal,
3937
llvm::Instruction* pEntryPoint, bool isIndirect);
4038

41-
unsigned int GetSpecialDebugVariableHash(const std::string& name);
4239
bool IsSpecialDebugVariable(const std::string& name);
43-
std::string GetSpecialVariableMetaName(const llvm::Instruction* CI);
4440

4541
} // namespace Utils
4642
} // namespace IGC

IGC/Compiler/InitializePasses.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,3 @@ void initializeBreakdownIntrinsicPassPass(llvm::PassRegistry&);
162162
void initializeCatchAllLineNumberPass(llvm::PassRegistry&);
163163
void initializePromoteConstantStructsPass(llvm::PassRegistry&);
164164
void initializeLowerInvokeSIMDPass(llvm::PassRegistry&);
165-
void initializeImplicitGIDRestoringPass(llvm::PassRegistry&);

IGC/Compiler/Optimizer/OpenCLPasses/DebuggerSupport/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@ include_directories("${CMAKE_CURRENT_SOURCE_DIR}")
1111

1212
set(IGC_BUILD__SRC__DebuggerSupport
1313
"${CMAKE_CURRENT_SOURCE_DIR}/ImplicitGIDPass.cpp"
14-
"${CMAKE_CURRENT_SOURCE_DIR}/ImplicitGIDRestoring.cpp"
1514
)
1615
set(IGC_BUILD__SRC__OpenCLPasses_DebuggerSupport ${IGC_BUILD__SRC__DebuggerSupport} PARENT_SCOPE)
1716

1817
set(IGC_BUILD__HDR__DebuggerSupport
1918
"${CMAKE_CURRENT_SOURCE_DIR}/ImplicitGIDPass.hpp"
20-
"${CMAKE_CURRENT_SOURCE_DIR}/ImplicitGIDRestoring.hpp"
2119
)
2220
set(IGC_BUILD__HDR__OpenCLPasses_DebuggerSupport ${IGC_BUILD__HDR__DebuggerSupport} PARENT_SCOPE)
2321

@@ -28,4 +26,4 @@ igc_sg_register(
2826
FILES
2927
${IGC_BUILD__SRC__DebuggerSupport}
3028
${IGC_BUILD__HDR__DebuggerSupport}
31-
)
29+
)

0 commit comments

Comments
 (0)