Skip to content

Commit 6f09895

Browse files
committed
[MERGE #6115 @nhat-nguyen] Allow empty airlock blocks to be reached through 2 helper blocks
Merge pull request #6115 from nhat-nguyen:airlock Ignore assertion error for cases where we insert an "airlock" helper block for a Branch instruction's helper path that: 1) ends up being empty 2) comes after a helper block from another instruction 3) is followed by a non-helper block Currently we would mark this block as a non-helper, but that makes this block only reachable through helper blocks, thus failing the assert.
2 parents 16fc8ac + b10d55f commit 6f09895

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

lib/Backend/LinearScan.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4059,6 +4059,20 @@ LinearScan::InsertSecondChanceCompensation(Lifetime ** branchRegContent, Lifetim
40594059
{
40604060
if (insertionInstr->m_prev->AsLabelInstr()->isOpHelper && !insertionInstr->AsLabelInstr()->isOpHelper)
40614061
{
4062+
// Ignore assertion error for cases where we insert an "airlock" helper block
4063+
// for a Branch instruction's helper path that:
4064+
// 1) ends up being empty
4065+
// 2) comes after a helper block from another instruction
4066+
// 3) is followed by a non-helper block
4067+
//
4068+
// Currently we would mark this block as a non-helper, but that makes
4069+
// this block only reachable through helper blocks, thus failing the assert
4070+
#if DBG
4071+
if (insertionInstr->m_prev->AsLabelInstr()->isOpHelper)
4072+
{
4073+
insertionInstr->m_prev->AsLabelInstr()->m_noHelperAssert = true;
4074+
}
4075+
#endif
40624076
insertionInstr->m_prev->AsLabelInstr()->isOpHelper = false;
40634077
}
40644078
}

lib/Backend/Peeps.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,21 @@ Peeps::PeepBranch(IR::BranchInstr *branchInstr, bool *const peepedRef)
453453
else
454454
{
455455
IR::Instr *instrTmp = instrSkip;
456+
457+
// Ignore assertion error for cases where we insert an "airlock" helper block
458+
// for a Branch instruction's helper path that:
459+
// 1) ends up being empty
460+
// 2) comes after a helper block from another instruction
461+
// 3) is followed by a non-helper block
462+
//
463+
// Propagating the "isOpHelper" flag can potentially make this block a non-helper,
464+
// and that makes this block only reachable through helper blocks, thus failing the assert
465+
#if DBG
466+
if (instrNext->AsLabelInstr()->isOpHelper != instrSkip->AsLabelInstr()->isOpHelper)
467+
{
468+
instrNext->AsLabelInstr()->m_noHelperAssert = true;
469+
}
470+
#endif
456471
instrNext->AsLabelInstr()->isOpHelper = instrSkip->AsLabelInstr()->isOpHelper;
457472
instrSkip = instrNext;
458473
instrNext = instrTmp;

0 commit comments

Comments
 (0)