Skip to content

Commit 9a5cdc1

Browse files
weiyu-chensys_zuul
authored andcommitted
Fix a break in subroutine returns.
Change-Id: I42949b528b83e7575f27db8a1731080ae784a79f
1 parent a58dd6d commit 9a5cdc1

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

visa/BuildIR.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@ class IR_Builder {
415415
FINALIZER_INFO* metaData;
416416
CompilerStats compilerStats;
417417

418+
int subroutineId = -1; // the kernel itself has id 0, as we always emit a subroutine label for kernel too
418419
bool isKernel;
419420

420421
// pre-defined declare that binds to R0 (the entire GRF)

visa/CISA.l

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,7 @@ V0 {
876876
return NULL_VAR;
877877
}
878878

879-
[a-zA-Z][a-zA-Z0-9_]* {
879+
[a-zA-Z_][a-zA-Z0-9_]* {
880880
TRACE("\n** VAR ");
881881
CISAlval.string = strdup(yytext);
882882
return VAR;

visa/TranslationInterface.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2238,6 +2238,11 @@ int IR_Builder::translateVISACFLabelInst(G4_Label* lab)
22382238
#endif
22392239
createLabelInst(lab, true);
22402240

2241+
if (lab->isFuncLabel())
2242+
{
2243+
subroutineId++;
2244+
}
2245+
22412246
#if defined(MEASURE_COMPILATION_TIME) && defined(TIME_IR_CONSTRUCTION)
22422247
stopTimer(TIMER_VISA_BUILDER_IR_CONSTRUCTION);
22432248
#endif
@@ -2513,7 +2518,7 @@ int IR_Builder::translateVISACFRetInst(VISA_Exec_Size executionSize, VISA_EMask_
25132518
}
25142519
else
25152520
{
2516-
createCFInst(predOpnd, getIsKernel() ? G4_pseudo_exit : GetGenOpcodeFromVISAOpcode(ISA_RET), exsize,
2521+
createCFInst(predOpnd, subroutineId == 0 ? G4_pseudo_exit : GetGenOpcodeFromVISAOpcode(ISA_RET), exsize,
25172522
nullptr, nullptr, instOpt);
25182523
}
25192524

0 commit comments

Comments
 (0)