Просмотр исходного кода

[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.
Nhat Nguyen 6 лет назад
Родитель
Сommit
6f0989551b
2 измененных файлов с 29 добавлено и 0 удалено
  1. 14 0
      lib/Backend/LinearScan.cpp
  2. 15 0
      lib/Backend/Peeps.cpp

+ 14 - 0
lib/Backend/LinearScan.cpp

@@ -4059,6 +4059,20 @@ LinearScan::InsertSecondChanceCompensation(Lifetime ** branchRegContent, Lifetim
         {
             if (insertionInstr->m_prev->AsLabelInstr()->isOpHelper && !insertionInstr->AsLabelInstr()->isOpHelper)
             {
+                // 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 
+#if DBG
+                if (insertionInstr->m_prev->AsLabelInstr()->isOpHelper)
+                {
+                    insertionInstr->m_prev->AsLabelInstr()->m_noHelperAssert = true;
+                }
+#endif
                 insertionInstr->m_prev->AsLabelInstr()->isOpHelper = false;
             }
         }

+ 15 - 0
lib/Backend/Peeps.cpp

@@ -453,6 +453,21 @@ Peeps::PeepBranch(IR::BranchInstr *branchInstr, bool *const peepedRef)
             else
             {
                 IR::Instr *instrTmp = instrSkip;
+
+                // 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
+                //
+                // Propagating the "isOpHelper" flag can potentially make this block a non-helper,
+                // and that makes this block only reachable through helper blocks, thus failing the assert 
+#if DBG
+                if (instrNext->AsLabelInstr()->isOpHelper != instrSkip->AsLabelInstr()->isOpHelper)
+                {
+                    instrNext->AsLabelInstr()->m_noHelperAssert = true;
+                }
+#endif
                 instrNext->AsLabelInstr()->isOpHelper = instrSkip->AsLabelInstr()->isOpHelper;
                 instrSkip = instrNext;
                 instrNext = instrTmp;