Pārlūkot izejas kodu

Fix region asserts for Leaves converted to Br in non exception finally region

Mark Leaves converted to Br in non excpetion finally region with m_leaveConvToBr bit on BranchInstr in DBG builds,
so that FlowGraph::Destroy asserts correctly for such branches
Meghana Gupta 8 gadi atpakaļ
vecāks
revīzija
b7251c713c
2 mainītis faili ar 13 papildinājumiem un 4 dzēšanām
  1. 11 4
      lib/Backend/FlowGraph.cpp
  2. 2 0
      lib/Backend/IR.h

+ 11 - 4
lib/Backend/FlowGraph.cpp

@@ -515,6 +515,9 @@ FlowGraph::Build(void)
                     Assert(currentLabel->GetRegion()->GetMatchingTryRegion()->GetMatchingFinallyRegion(false) == currentLabel->GetRegion());
                     // Convert Leave to Br because we execute non-excepting Finally in native code
                     instr->m_opcode = Js::OpCode::Br;
+#if DBG
+                    instr->AsBranchInstr()->m_leaveConvToBr = true;
+#endif
                 }
             }
             else if (instr->m_opcode == Js::OpCode::Finally)
@@ -1724,18 +1727,22 @@ FlowGraph::Destroy(void)
                         Assert(region->GetType() == RegionTypeTry || region->GetType() == RegionTypeCatch || region->GetType() == RegionTypeFinally);
                         break;
                     case Js::OpCode::Br:
-                        if (region->GetType() == RegionTypeCatch && region != predRegion)
+                        if (predBlock->GetLastInstr()->AsBranchInstr()->m_leaveConvToBr)
+                        {
+                            // Leave converted to Br in finally region
+                            AssertMsg(region == predRegion->GetParent(), "Bad region prop in finally");
+                        }
+                        else if (region->GetType() == RegionTypeCatch && region != predRegion)
                         {
                             AssertMsg(predRegion->GetType() == RegionTypeTry, "Bad region type for the try");
                         }
                         else if (region->GetType() == RegionTypeFinally && region != predRegion)
                         {
-                            // When we add edge from finally to early exit, and break block removal moves the edge into finally region, we can end up with an edge between finally and non eh region
+                            AssertMsg(predRegion->GetType() == RegionTypeTry, "Bad region type for the try");
                         }
                         else
                         {
-                            // Leave's within non excepting finallys that are not early exit edges are converted to br
-                            AssertMsg((predRegion->IsNonExceptingFinally() && region == predRegion->GetParent()) || region == predRegion, "Bad region propagation through interior block");
+                            AssertMsg(region == predRegion, "Bad region propagation through interior block");
                         }
                         break;
                     default:

+ 2 - 0
lib/Backend/IR.h

@@ -739,6 +739,7 @@ public:
 #if DBG
     bool                 m_isMultiBranch;
     bool                 m_isHelperToNonHelperBranch;
+    bool                 m_leaveConvToBr;
 #endif
 
 public:
@@ -751,6 +752,7 @@ public:
     {
 #if DBG
         m_isMultiBranch = false;
+        m_leaveConvToBr = false;
 #endif
     }