From b2d364d0eee1d6df4b49e3a7d5b3c4c11af3b3ca Mon Sep 17 00:00:00 2001 From: Santiago Aboy Solanes Date: Thu, 10 Nov 2022 10:26:31 +0000 Subject: Remove tries which don't contain throwing instructions If nothing can throw within a TryBoundary, we are safe to eliminate it. We were already doing this at the builder stage, but this CL takes care of subsequent passes (e.g. we might remove DivZeroCheck instructions which means that now we know we can't throw). Sometimes this means we are able to eliminate catch blocks which brings some code size improvements. Locally on a Pixel 5 compiling with `speed`: * AGSA -684K (0.2%) * services.jar -100K (0.2%) * SystemUIGoogle -88K (0.3%) Bug: 229249867 Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b Change-Id: I36d5880be99c1f1109c94266b1be583de8d6cf72 --- compiler/optimizing/nodes.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'compiler/optimizing/nodes.cc') diff --git a/compiler/optimizing/nodes.cc b/compiler/optimizing/nodes.cc index d40ce7a717..841576a5e5 100644 --- a/compiler/optimizing/nodes.cc +++ b/compiler/optimizing/nodes.cc @@ -2885,7 +2885,10 @@ HInstruction* HGraph::InlineInto(HGraph* outer_graph, HInvoke* invoke) { // At this point we might either have: // A) Return/ReturnVoid/Throw as the last instruction // B) `Return/ReturnVoid->TryBoundary->Goto` as the last instruction chain - // C) `Throw->TryBoundary` as the last instruction chain + // C) `Return/ReturnVoid->Goto` as the last instruction chain. This exists when we added the + // extra Goto because we had a TryBoundary which we could eliminate in DCE after + // substituting arguments. + // D) `Throw->TryBoundary` as the last instruction chain const bool saw_goto = last->IsGoto(); if (saw_goto) { @@ -2903,7 +2906,6 @@ HInstruction* HGraph::InlineInto(HGraph* outer_graph, HInvoke* invoke) { } // Check that if we have an instruction chain, it is one of the allowed ones. - DCHECK_IMPLIES(saw_goto, saw_try_boundary); DCHECK_IMPLIES(saw_goto, last->IsReturnVoid() || last->IsReturn()); if (last->IsThrow()) { -- cgit v1.2.3-59-g8ed1b