Skip to content

Commit b3dbdfd

Browse files
weiyu-chensys_zuul
authored andcommitted
Abort compilation if inline asm parsing fails.
Change-Id: Iba0251b10bc7f179a51b1272aa68b459549f6ff8
1 parent 3dfff5b commit b3dbdfd

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

IGC/Compiler/CISACodeGen/CISABuilder.cpp

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4961,6 +4961,7 @@ namespace IGC
49614961
// Use the same build options as before
49624962
SetBuilderOptions(vAsmTextBuilder);
49634963

4964+
bool vISAAsmParseError = false;
49644965
// Parse the generated VISA text
49654966
if (visaAsmOverride)
49664967
{
@@ -4969,9 +4970,10 @@ namespace IGC
49694970
asmName.pop_back();
49704971
vAsmTextBuilder->SetOption(VISA_AsmFileNameUser, true);
49714972
vAsmTextBuilder->SetOption(VISA_AsmFileName, asmName.c_str());
4972-
V(vAsmTextBuilder->ParseVISAText(visaAsmOverrideFile));
4973+
auto result = vAsmTextBuilder->ParseVISAText(visaAsmOverrideFile);
49734974
asmName = asmName + ".visaasm";
49744975
appendToShaderOverrideLogFile(asmName, "OVERRIDEN: ");
4976+
vISAAsmParseError = (result != 0);
49754977
}
49764978
else
49774979
{
@@ -4983,11 +4985,20 @@ namespace IGC
49834985
raw_string_ostream S(output);
49844986
S << "parsing vISA inline assembly failed:\t" << vAsmTextBuilder->GetCriticalMsg();
49854987
context->EmitError(output.c_str());
4988+
vISAAsmParseError = true;
49864989
}
49874990
}
49884991

4989-
pMainKernel = vAsmTextBuilder->GetVISAKernel();
4990-
vIsaCompile = vAsmTextBuilder->Compile(m_enableVISAdump ? GetDumpFileName("isa").c_str() : "");
4992+
if (vISAAsmParseError)
4993+
{
4994+
COMPILER_TIME_END(m_program->GetContext(), TIME_CG_vISACompile);
4995+
return;
4996+
}
4997+
else
4998+
{
4999+
pMainKernel = vAsmTextBuilder->GetVISAKernel();
5000+
vIsaCompile = vAsmTextBuilder->Compile(m_enableVISAdump ? GetDumpFileName("isa").c_str() : "");
5001+
}
49915002
}
49925003
//Compile to generate the V-ISA binary
49935004
else
@@ -4996,7 +5007,17 @@ namespace IGC
49965007
vIsaCompile = vbuilder->Compile(m_enableVISAdump ? GetDumpFileName("isa").c_str() : "");
49975008
}
49985009

4999-
FINALIZER_INFO* jitInfo;
5010+
COMPILER_TIME_END(m_program->GetContext(), TIME_CG_vISACompile);
5011+
5012+
#if GET_TIME_STATS
5013+
// handle the vISA time counters differently here
5014+
if (context->m_compilerTimeStats)
5015+
{
5016+
context->m_compilerTimeStats->recordVISATimers();
5017+
}
5018+
#endif
5019+
5020+
FINALIZER_INFO* jitInfo = nullptr;
50005021
pMainKernel->GetJitInfo(jitInfo);
50015022
if (jitInfo->isSpill)
50025023
{
@@ -5007,15 +5028,6 @@ namespace IGC
50075028

50085029
context->m_retryManager.numInstructions = jitInfo->numAsmCount;
50095030
}
5010-
COMPILER_TIME_END(m_program->GetContext(), TIME_CG_vISACompile);
5011-
5012-
#if GET_TIME_STATS
5013-
// handle the vISA time counters differently here
5014-
if (context->m_compilerTimeStats)
5015-
{
5016-
context->m_compilerTimeStats->recordVISATimers();
5017-
}
5018-
#endif
50195031

50205032
if (IGC_IS_FLAG_ENABLED(DumpCompilerStats))
50215033
{

0 commit comments

Comments
 (0)