Skip to content

Commit 16ce861

Browse files
scottp101igcbot
authored andcommitted
small refactor
1 parent b03ee45 commit 16ce861

File tree

1 file changed

+18
-22
lines changed

1 file changed

+18
-22
lines changed

IGC/Compiler/CISACodeGen/CISABuilder.cpp

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3650,7 +3650,7 @@ namespace IGC
36503650
{
36513651
CodeGenContext* context = m_program->GetContext();
36523652
bool isOptDisabled = context->getModuleMetaData()->compOpt.OptDisable;
3653-
typedef std::unique_ptr< char, std::function<void(char*)>> param_uptr;
3653+
using param_uptr = std::unique_ptr<char, std::function<void(char*)>>;
36543654
auto literal_deleter = [](char* val) {};
36553655
auto dup_deleter = [](char* val) {free(val); };
36563656
// create vbuilder->Compile() params
@@ -3702,30 +3702,26 @@ namespace IGC
37023702
}
37033703
}
37043704
if (IGC_IS_FLAG_DISABLED(ForceDisableShaderDebugHashCodeInKernel) &&
3705-
(context->m_DriverInfo.EnableShaderDebugHashCodeInKernel() ||
3706-
IGC_IS_FLAG_ENABLED(ShaderDebugHashCodeInKernel)))
3707-
{
3708-
QWORD AssemblyHash = { 0 };
3709-
AssemblyHash = context->hash.getAsmHash();
3710-
params.push_back(param_uptr("-hashmovs", literal_deleter));
3711-
std::string Low = std::to_string((DWORD)AssemblyHash);
3712-
std::string High = std::to_string((DWORD)(AssemblyHash >> 32));
3713-
params.push_back(param_uptr(_strdup(Low.c_str()), dup_deleter));
3714-
params.push_back(param_uptr(_strdup(High.c_str()), dup_deleter));
3715-
3716-
QWORD NosHash = { 0 };
3717-
NosHash = context->hash.getNosHash();
3718-
QWORD PsoHash = { 0 };
3719-
PsoHash = context->hash.getPsoHash();
3720-
QWORD hashToUse = NosHash != 0 ? NosHash : PsoHash;
3721-
if (hashToUse)
3705+
(context->m_DriverInfo.EnableShaderDebugHashCodeInKernel() ||
3706+
IGC_IS_FLAG_ENABLED(ShaderDebugHashCodeInKernel)))
3707+
{
3708+
auto addHash = [&](char* OptName, QWORD Hash)
37223709
{
3723-
params.push_back(param_uptr("-hashmovs1", literal_deleter));
3724-
std::string Low = std::to_string((DWORD)hashToUse);
3725-
std::string High = std::to_string((DWORD)(hashToUse >> 32));
3710+
params.push_back(param_uptr(OptName, literal_deleter));
3711+
std::string Low = std::to_string((DWORD)Hash);
3712+
std::string High = std::to_string((DWORD)(Hash >> 32));
37263713
params.push_back(param_uptr(_strdup(Low.c_str()), dup_deleter));
37273714
params.push_back(param_uptr(_strdup(High.c_str()), dup_deleter));
3728-
}
3715+
};
3716+
3717+
QWORD AssemblyHash = context->hash.getAsmHash();
3718+
addHash("-hashmovs", AssemblyHash);
3719+
3720+
QWORD NosHash = context->hash.getNosHash();
3721+
QWORD PsoHash = context->hash.getPsoHash();
3722+
QWORD hashToUse = NosHash != 0 ? NosHash : PsoHash;
3723+
if (hashToUse)
3724+
addHash("-hashmovs1", hashToUse);
37293725
}
37303726
}
37313727
void CEncoder::InitVISABuilderOptions(TARGET_PLATFORM VISAPlatform, bool canAbortOnSpill, bool hasStackCall, bool enableVISA_IR)

0 commit comments

Comments
 (0)