Преглед на файлове

Fix style issues and reorganize code.

Derek Morris преди 9 години
родител
ревизия
dc1b868da7
променени са 2 файла, в които са добавени 24 реда и са изтрити 23 реда
  1. 11 10
      lib/Backend/BackwardPass.cpp
  2. 13 13
      lib/Backend/GlobOpt.cpp

+ 11 - 10
lib/Backend/BackwardPass.cpp

@@ -7064,29 +7064,30 @@ BackwardPass::ProcessBailOnNoProfile(IR::Instr *instr, BasicBlock *block)
     }
 
     // Save the head instruction for later use.
-    IR::Instr *blockHeadInstr = curInstr;
+    IR::LabelInstr *blockHeadInstr = curInstr->AsLabelInstr();
 
     // We can't bail in the middle of a "tmp = CmEq s1, s2; BrTrue tmp" turned into a "BrEq s1, s2",
     // because the bailout wouldn't be able to restore tmp.
     IR::Instr *curNext = curInstr->GetNextRealInstrOrLabel();
     IR::Instr *instrNope = nullptr;
-    if (curNext->m_opcode == Js::OpCode::Ld_A && curNext->GetDst()->IsRegOpnd() && curNext->GetDst()->AsRegOpnd()->m_fgPeepTmp)
+    while (curNext->m_opcode == Js::OpCode::Ld_A && curNext->GetDst()->IsRegOpnd() && curNext->GetDst()->AsRegOpnd()->m_fgPeepTmp)
     {
         // Instead of just giving up, we can be a little trickier. We can instead treat the tmp declaration(s) as a
         // part of the block prefix, and put the bailonnoprofile immediately after them. This has the added benefit
         // that we can still merge up blocks beginning with bailonnoprofile, even if they would otherwise not allow
         // us to, due to the fact that these tmp declarations would be pre-empted by the higher-level bailout.
-        while (curNext->m_opcode == Js::OpCode::Ld_A && curNext->GetDst()->IsRegOpnd() && curNext->GetDst()->AsRegOpnd()->m_fgPeepTmp)
-        {
-            instrNope = curNext;
-            curNext = curNext->GetNextRealInstrOrLabel();
-        }
+        instrNope = curNext;
+        curNext = curNext->GetNextRealInstrOrLabel();
+    }
+
+    if (instrNope != nullptr)
+    {
         instrNope = curNext;
     }
 
     curInstr = instr->m_prev;
 
-    // Move to top of block.
+    // Move to top of block (but just below any fgpeeptemp lds).
     while(!curInstr->StartsBasicBlock() && curInstr != instrNope)
     {
         // Delete redundant BailOnNoProfile
@@ -7175,9 +7176,9 @@ BackwardPass::ProcessBailOnNoProfile(IR::Instr *instr, BasicBlock *block)
     // and throw case should be rare enough that it won't matter for perf.
     if (block->GetBlockNum() != 0)
     {
-        blockHeadInstr->AsLabelInstr()->isOpHelper = true;
+        blockHeadInstr->isOpHelper = true;
 #if DBG
-        blockHeadInstr->AsLabelInstr()->m_noHelperAssert = true;
+        blockHeadInstr->m_noHelperAssert = true;
 #endif
         block->beginsBailOnNoProfile = true;
 

+ 13 - 13
lib/Backend/GlobOpt.cpp

@@ -4287,26 +4287,26 @@ GlobOpt::MarkArgumentsUsedForBranch(IR::Instr * instr)
         IR::Opnd *src1 = bInstr->GetSrc1();
         IR::Opnd *src2 = bInstr->GetSrc2();
         // These are used because we don't want to rely on src1 or src2 to always be the register/constant
-        IR::RegOpnd *regopnd = nullptr;
-        IR::Opnd *constopnd = nullptr;
-        if (!src2 && (instr->m_opcode == Js::OpCode::BrFalse_A || instr->m_opcode == Js::OpCode::BrTrue_A) && src1->IsRegOpnd()) {
-            regopnd = src1->AsRegOpnd();
+        IR::RegOpnd *regOpnd = nullptr;
+        if (!src2 && (instr->m_opcode == Js::OpCode::BrFalse_A || instr->m_opcode == Js::OpCode::BrTrue_A) && src1->IsRegOpnd())
+        {
+            regOpnd = src1->AsRegOpnd();
         }
         // We need to check for (0===arg) and (arg===0); this is especially important since some minifiers
         // change all instances of one to the other.
-        else if (src2 && src2->IsConstOpnd() && src1->IsRegOpnd()) {
-            regopnd = src1->AsRegOpnd();
-            constopnd = src2;
+        else if (src2 && src2->IsConstOpnd() && src1->IsRegOpnd())
+        {
+            regOpnd = src1->AsRegOpnd();
         }
-        else if (src2 && src2->IsRegOpnd() && src1->IsConstOpnd()) {
-            regopnd = src2->AsRegOpnd();
-            constopnd = src1;
+        else if (src2 && src2->IsRegOpnd() && src1->IsConstOpnd())
+        {
+            regOpnd = src2->AsRegOpnd();
         }
-        if (regopnd != nullptr)
+        if (regOpnd != nullptr)
         {
-            if (regopnd->m_sym->IsSingleDef())
+            if (regOpnd->m_sym->IsSingleDef())
             {
-                IR::Instr * defInst = regopnd->m_sym->GetInstrDef();
+                IR::Instr * defInst = regOpnd->m_sym->GetInstrDef();
                 IR::Opnd *defSym = defInst->GetSrc1();
                 if (defSym && defSym->IsSymOpnd() && defSym->AsSymOpnd()->m_sym->IsStackSym()
                     && defSym->AsSymOpnd()->m_sym->AsStackSym()->IsParamSlotSym())