1# Copyright (C) 2015 The Android Open Source Project 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15.class public LSsaBuilder; 16.super Ljava/lang/Object; 17 18# Check that a dead phi with a live equivalent is replaced in an environment. The 19# following test case throws an exception and uses v0 afterwards. However, v0 20# contains a phi that is interpreted as int for the environment, and as float for 21# instruction use. SsaBuilder must substitute the int variant before removing it, 22# otherwise running the code with an array short enough to throw will crash at 23# runtime because v0 is undefined. 24 25## CHECK-START: int SsaBuilder.environmentPhi(boolean, int[]) builder (after) 26## CHECK-DAG: <<Cst0:f\d+>> FloatConstant 0 27## CHECK-DAG: <<Cst2:f\d+>> FloatConstant 2 28## CHECK-DAG: <<Phi:f\d+>> Phi [<<Cst0>>,<<Cst2>>] 29## CHECK-DAG: BoundsCheck env:[[<<Phi>>,{{i\d+}},{{z\d+}},{{l\d+}}]] 30 31.method public static environmentPhi(Z[I)I 32 .registers 4 33 34 const v0, 0x0 35 if-eqz p0, :else 36 const v0, 0x40000000 37 :else 38 # v0 = phi that can be both int and float 39 40 :try_start 41 const v1, 0x3 42 aput v1, p1, v1 43 const v0, 0x1 # generate catch phi for v0 44 const v1, 0x4 45 aput v1, p1, v1 46 :try_end 47 .catchall {:try_start .. :try_end} :use_as_float 48 49 :use_as_float 50 float-to-int v0, v0 51 return v0 52.end method