From 3fcfd7303a7a0683e334d0509b17d65d773b3d71 Mon Sep 17 00:00:00 2001 From: Santiago Aboy Solanes Date: Wed, 7 Sep 2022 10:31:59 +0000 Subject: Reland "Add an environment to the beginning of catch blocks" This reverts commit 37fe26288aaacae0f26873131dd92704796e09ec. Reason for revert: Pattern match fix Bug: 227283224 Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b --debuggable 565-checker-condition-liveness (also for --target) Change-Id: Iaf784c12fb6229df6cfbd9a1b43467f5ed43c4d4 --- compiler/optimizing/code_sinking.cc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'compiler/optimizing/code_sinking.cc') diff --git a/compiler/optimizing/code_sinking.cc b/compiler/optimizing/code_sinking.cc index 766bb01978..930675b401 100644 --- a/compiler/optimizing/code_sinking.cc +++ b/compiler/optimizing/code_sinking.cc @@ -271,10 +271,21 @@ static HInstruction* FindIdealPosition(HInstruction* instruction, } } for (const HUseListNode& use : instruction->GetEnvUses()) { - HInstruction* user = use.GetUser()->GetHolder(); + HEnvironment* env = use.GetUser(); + HInstruction* user = env->GetHolder(); if (user->GetBlock() == target_block && (insert_pos == nullptr || user->StrictlyDominates(insert_pos))) { - insert_pos = user; + if (target_block->IsCatchBlock() && target_block->GetFirstInstruction() == user) { + // We can sink the instructions past the environment setting Nop. If we do that, we have to + // remove said instruction from the environment. Since we know that we will be sinking the + // instruction to this block and there are no more instructions to consider, we can safely + // remove it from the environment now. + DCHECK(target_block->GetFirstInstruction()->IsNop()); + env->RemoveAsUserOfInput(use.GetIndex()); + env->SetRawEnvAt(use.GetIndex(), /*instruction=*/ nullptr); + } else { + insert_pos = user; + } } } if (insert_pos == nullptr) { -- cgit v1.2.3-59-g8ed1b