Skip to content

Commit a4ec882

Browse files
harshaduntwalesys_zuul
authored andcommitted
Internal Change
Change-Id: I9c66ac527671d3d53021ef0dcbbe0b05694794dd
1 parent fadc97f commit a4ec882

File tree

3 files changed

+29
-17
lines changed

3 files changed

+29
-17
lines changed

IGC/Compiler/CISACodeGen/CISABuilder.cpp

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3683,24 +3683,26 @@ namespace IGC
36833683
}
36843684
}
36853685

3686-
void CEncoder::InitBuildParams(llvm::SmallVector<const char*, 10>& params)
3686+
void CEncoder::InitBuildParams(llvm::SmallVector<std::unique_ptr< char, std::function<void(char*)>>, 10>& params)
36873687
{
36883688
CodeGenContext* context = m_program->GetContext();
36893689
bool isOptDisabled = context->getModuleMetaData()->compOpt.OptDisable;
3690-
3690+
typedef std::unique_ptr< char, std::function<void(char*)>> param_uptr;
3691+
auto literal_deleter = [](char* val) {};
3692+
auto dup_deleter = [](char* val) {free(val); };
36913693
// create vbuilder->Compile() params
36923694
if (IGC_IS_FLAG_ENABLED(EnableVISADotAll))
36933695
{
3694-
params.push_back("-dotAll");
3696+
params.push_back(param_uptr("-dotAll", literal_deleter));
36953697
}
36963698
if (IGC_IS_FLAG_ENABLED(EnableVISADebug) || isOptDisabled)
36973699
{
3698-
params.push_back("-debug");
3700+
params.push_back(param_uptr("-debug", literal_deleter));
36993701
}
37003702
if (context->getModuleMetaData()->compOpt.FastVISACompile)
37013703
{
3702-
params.push_back("-fasterRA");
3703-
params.push_back("-noLocalSplit");
3704+
params.push_back(param_uptr("-fasterRA", literal_deleter));
3705+
params.push_back(param_uptr("-noLocalSplit", literal_deleter));
37043706
}
37053707
// Ensure VISA_Opts has the same scope as CreateVISABuilder so that valid
37063708
// strings are checked by vISA and freed out of this function.
@@ -3724,7 +3726,7 @@ namespace IGC
37243726
// note that the memory should be freed once
37253727
// params has been read, but since this is only for
37263728
// debugging, do not bother freeing memory.
3727-
params.push_back(_strdup(opt.c_str()));
3729+
params.push_back(param_uptr(_strdup(opt.c_str()), dup_deleter));
37283730
if (opt == "-output" || opt == "-binary" || opt == "-dumpvisa" || opt == "-dumpcommonisa")
37293731
{
37303732
m_enableVISAdump = true;
@@ -3736,11 +3738,11 @@ namespace IGC
37363738
{
37373739
QWORD AssemblyHash = { 0 };
37383740
AssemblyHash = context->hash.getAsmHash();
3739-
params.push_back("-hashmovs");
3741+
params.push_back(param_uptr("-hashmovs", literal_deleter));
37403742
std::string Low = std::to_string((DWORD)AssemblyHash);
37413743
std::string High = std::to_string((DWORD)(AssemblyHash >> 32));
3742-
params.push_back(_strdup(Low.c_str()));
3743-
params.push_back(_strdup(High.c_str()));
3744+
params.push_back(param_uptr(_strdup(Low.c_str()), dup_deleter));
3745+
params.push_back(param_uptr(_strdup(High.c_str()), dup_deleter));
37443746

37453747
QWORD NosHash = { 0 };
37463748
NosHash = context->hash.getNosHash();
@@ -3749,11 +3751,11 @@ namespace IGC
37493751
QWORD hashToUse = NosHash != 0 ? NosHash : PsoHash;
37503752
if (hashToUse)
37513753
{
3752-
params.push_back("-hashmovs1");
3754+
params.push_back(param_uptr("-hashmovs1", literal_deleter));
37533755
std::string Low = std::to_string((DWORD)hashToUse);
37543756
std::string High = std::to_string((DWORD)(hashToUse >> 32));
3755-
params.push_back(_strdup(Low.c_str()));
3756-
params.push_back(_strdup(High.c_str()));
3757+
params.push_back(param_uptr(_strdup(Low.c_str()), dup_deleter));
3758+
params.push_back(param_uptr(_strdup(High.c_str()), dup_deleter));
37573759
}
37583760
}
37593761
}
@@ -4305,10 +4307,15 @@ namespace IGC
43054307
SetVISAWaTable(m_program->m_Platform->getWATable());
43064308

43074309
llvm::SmallVector<const char*, 10> params;
4310+
llvm::SmallVector<std::unique_ptr< char, std::function<void(char*)>>, 10> params2;
43084311
if (!m_hasInlineAsm)
43094312
{
43104313
// Asm text writer mode doesnt need dump params
4311-
InitBuildParams(params);
4314+
InitBuildParams(params2);
4315+
for (size_t i = 0; i < params2.size(); i++)
4316+
{
4317+
params.push_back((params2[i].get()));
4318+
}
43124319
}
43134320

43144321
COMPILER_TIME_START(m_program->GetContext(), TIME_CG_vISACompile);
@@ -4845,7 +4852,12 @@ namespace IGC
48454852
V(vbuilder->WriteVISAHeader());
48464853

48474854
llvm::SmallVector<const char*, 10> params;
4848-
InitBuildParams(params);
4855+
llvm::SmallVector<std::unique_ptr< char, std::function<void( char*)>>, 10> params2;
4856+
InitBuildParams(params2);
4857+
for (size_t i = 0; i < params2.size(); i++)
4858+
{
4859+
params.push_back((params2[i].get()));
4860+
}
48494861

48504862
// Create a new builder for parsing the visaasm
48514863
TARGET_PLATFORM VISAPlatform = GetVISAPlatform(&(context->platform));

IGC/Compiler/CISACodeGen/CISABuilder.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ namespace IGC
130130
{
131131
public:
132132
void InitEncoder(bool canAbortOnSpill, bool hasStackCall);
133-
void InitBuildParams(llvm::SmallVector<const char*, 10> & params);
133+
void InitBuildParams(llvm::SmallVector<std::unique_ptr< char, std::function<void(char*)>>, 10> & params);
134134
void InitVISABuilderOptions(TARGET_PLATFORM VISAPlatform, bool canAbortOnSpill, bool hasStackCall, bool enableVISA_IR);
135135
SEncoderState CopyEncoderState();
136136
void SetEncoderState(SEncoderState& newState);

IGC/common/igc_flags.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ DECLARE_IGC_REGKEY(bool, EnableSplitUnalignedVector, true, "Enable Splitti
177177
DECLARE_IGC_REGKEY(bool, DisableFDivReassociation, false, "Disable reassociation for Fdiv operations to avoid precision difference", false)
178178

179179
DECLARE_IGC_GROUP("Shader debugging")
180-
DECLARE_IGC_REGKEY(bool, ShaderDebugHashCodeInKernel, false, "Append hash code to the binary", false)
180+
DECLARE_IGC_REGKEY(bool, ShaderDebugHashCodeInKernel, true, "Append hash code to the binary", false)
181181
DECLARE_IGC_REGKEY(int, ShaderDebugHashCode, 0, "The driver will set a breakpoint in the first instruction of the shader which has the provided hash code.\
182182
It works only when the value is different then 0 and SystemThreadEnable is set to TRUE.\
183183
Ex: VS_asm2df26246434553ad_nos0000000000000000 , only the LowPart Need \

0 commit comments

Comments
 (0)