From 9e701b1918ccb50908c8dbdb987103284db16a73 Mon Sep 17 00:00:00 2001 From: Santiago Aboy Solanes Date: Mon, 21 Mar 2022 12:46:10 +0000 Subject: Allow to sink code to catch blocks We now allow to sink code to catch blocks, while blocking moving it to blocks that would throw into catch blocks. Bug: 75971227 Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b Change-Id: Iaf5ea647e96170cbfb95c4286c5c37c991cb2113 --- compiler/optimizing/code_sinking.cc | 10 ++++++++-- 1 file changed, 8 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 2b56c88c25..0f336a2b1d 100644 --- a/compiler/optimizing/code_sinking.cc +++ b/compiler/optimizing/code_sinking.cc @@ -217,8 +217,14 @@ static HInstruction* FindIdealPosition(HInstruction* instruction, DCHECK(target_block != nullptr); } - // Bail if the instruction can throw and we are about to move into a catch block. - if (instruction->CanThrow() && target_block->GetTryCatchInformation() != nullptr) { + // Bail if the instruction would throw into a catch block. + if (instruction->CanThrow() && target_block->IsTryBlock()) { + // TODO(solanes): Here we could do something similar to the loop above and move to the first + // dominator, which is not a try block, instead of just returning nullptr. If we do so, we have + // to also make sure we are not in a loop. + // TODO(solanes): Alternatively, we could split the try block at the try boundary having two + // blocks: A and B. Block B would have the try boundary (and xhandler) and therefore block A + // would be the target block available to move the instruction. return nullptr; } -- cgit v1.2.3-59-g8ed1b