1 /* 2 * Copyright (C) 2024 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 public class Main { 18 static int field; 19 static long checksum; 20 $noinline$testDoNotPeelLoop()21 static void $noinline$testDoNotPeelLoop() { 22 int to_add_to_checksum = 112; 23 int[] iArr1 = new int[256]; 24 try { 25 for (int i = 10; i < 187; i++) { 26 try { 27 int i20 = field % iArr1[i]; 28 } catch (ArithmeticException ae) { 29 } 30 // This loop won't be fully unrolled, since `to_add_to_checksum` is part of the 31 // outer catch phi. 32 // This part of the code can't throw and therefore we eliminate the TryBoundary 33 // instructions related to it. However, we still have the value used in the outer 34 // catch phi as we don't remove it from there. SuperblockCloner doesn't deal with 35 // blocks in a try/catch but this is not considered to be part of a try/catch and 36 // therefore it used to try to peel this loop, resulting in errors. 37 for (int j = 1; j < 2; j++) { 38 to_add_to_checksum += 209; 39 field -= field; 40 } 41 } 42 } catch (Throwable e) { 43 } 44 checksum += to_add_to_checksum; 45 } 46 main(String[] strArr)47 public static void main(String[] strArr) { 48 for (int i = 0; i < 10; ++i) { 49 $noinline$testDoNotPeelLoop(); 50 System.out.println(checksum); 51 } 52 } 53 } 54