Incorrect handling of guaranteed ArrayIndexOutOfBoundsException by EscapeTransformations causes IR verification failure

Description

The attached test case produces an incorrect message when compiled with the optimizing compiler, e.g. by using the command line

1 rvm -X:aos:initial_compiler=opt -X:aos:enable_recompilation=false IncorrectIndexWithOptCompiler

The array index is reported as 0 but it should be 5. Enabling paranoid IR verification and looking at the IR shows that the problem occurs in EscapeTransformations: the int_aload is removed but the resulting temporary is still used later.

One way to fix this would be to optimize the trap_if into an unconditional trap and then run a global dead code elimination pass. AFAIK we don't have such a pass yet.

Environment

None

Status

Assignee

Unassigned

Reporter

Erik Brangs

Labels

None

External issue ID

None

Components

Fix versions

Priority

High
Configure