Nicolas Geoffray | 5790260 | 2015-04-21 14:28:41 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 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 | |
| 18 | public class Main { |
| 19 | |
| 20 | // CHECK-START: void Main.loop1(boolean) liveness (after) |
David Brazdil | c7a2485 | 2015-05-15 16:44:05 +0100 | [diff] [blame^] | 21 | // CHECK: ParameterValue liveness:2 ranges:{[2,22)} uses:[17,22] |
David Brazdil | c7465286 | 2015-05-13 17:50:09 +0100 | [diff] [blame] | 22 | // CHECK: Goto liveness:20 |
Nicolas Geoffray | 5790260 | 2015-04-21 14:28:41 +0100 | [diff] [blame] | 23 | public static void loop1(boolean incoming) { |
| 24 | while (incoming) {} |
| 25 | } |
| 26 | |
| 27 | // CHECK-START: void Main.loop2(boolean) liveness (after) |
David Brazdil | c7a2485 | 2015-05-15 16:44:05 +0100 | [diff] [blame^] | 28 | // CHECK: ParameterValue liveness:2 ranges:{[2,42)} uses:[33,38,42] |
David Brazdil | c7465286 | 2015-05-13 17:50:09 +0100 | [diff] [blame] | 29 | // CHECK: Goto liveness:36 |
| 30 | // CHECK: Goto liveness:40 |
Nicolas Geoffray | 5790260 | 2015-04-21 14:28:41 +0100 | [diff] [blame] | 31 | public static void loop2(boolean incoming) { |
| 32 | while (true) { |
| 33 | System.out.println("foo"); |
| 34 | while (incoming) {} |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | // CHECK-START: void Main.loop3(boolean) liveness (after) |
David Brazdil | c7a2485 | 2015-05-15 16:44:05 +0100 | [diff] [blame^] | 39 | // CHECK: ParameterValue liveness:2 ranges:{[2,60)} uses:[56,60] |
David Brazdil | c7465286 | 2015-05-13 17:50:09 +0100 | [diff] [blame] | 40 | // CHECK: Goto liveness:58 |
Nicolas Geoffray | 5790260 | 2015-04-21 14:28:41 +0100 | [diff] [blame] | 41 | |
| 42 | // CHECK-START: void Main.loop3(boolean) liveness (after) |
David Brazdil | c7465286 | 2015-05-13 17:50:09 +0100 | [diff] [blame] | 43 | // CHECK-NOT: Goto liveness:54 |
Nicolas Geoffray | 5790260 | 2015-04-21 14:28:41 +0100 | [diff] [blame] | 44 | public static void loop3(boolean incoming) { |
| 45 | // 'incoming' only needs a use at the outer loop's back edge. |
| 46 | while (System.currentTimeMillis() != 42) { |
| 47 | while (Runtime.getRuntime() != null) {} |
| 48 | System.out.println(incoming); |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | // CHECK-START: void Main.loop4(boolean) liveness (after) |
David Brazdil | c7a2485 | 2015-05-15 16:44:05 +0100 | [diff] [blame^] | 53 | // CHECK: ParameterValue liveness:2 ranges:{[2,22)} uses:[22] |
Nicolas Geoffray | 5790260 | 2015-04-21 14:28:41 +0100 | [diff] [blame] | 54 | |
| 55 | // CHECK-START: void Main.loop4(boolean) liveness (after) |
David Brazdil | c7465286 | 2015-05-13 17:50:09 +0100 | [diff] [blame] | 56 | // CHECK-NOT: Goto liveness:20 |
Nicolas Geoffray | 5790260 | 2015-04-21 14:28:41 +0100 | [diff] [blame] | 57 | public static void loop4(boolean incoming) { |
| 58 | // 'incoming' has no loop use, so should not have back edge uses. |
| 59 | System.out.println(incoming); |
| 60 | while (System.currentTimeMillis() != 42) { |
| 61 | while (Runtime.getRuntime() != null) {} |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | // CHECK-START: void Main.loop5(boolean) liveness (after) |
David Brazdil | c7a2485 | 2015-05-15 16:44:05 +0100 | [diff] [blame^] | 66 | // CHECK: ParameterValue liveness:2 ranges:{[2,50)} uses:[33,42,46,50] |
David Brazdil | c7465286 | 2015-05-13 17:50:09 +0100 | [diff] [blame] | 67 | // CHECK: Goto liveness:44 |
| 68 | // CHECK: Goto liveness:48 |
Nicolas Geoffray | 5790260 | 2015-04-21 14:28:41 +0100 | [diff] [blame] | 69 | public static void loop5(boolean incoming) { |
| 70 | // 'incoming' must have a use at both back edges. |
| 71 | while (Runtime.getRuntime() != null) { |
| 72 | while (incoming) { |
| 73 | System.out.println(incoming); |
| 74 | } |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | // CHECK-START: void Main.loop6(boolean) liveness (after) |
David Brazdil | c7a2485 | 2015-05-15 16:44:05 +0100 | [diff] [blame^] | 79 | // CHECK ParameterValue liveness:2 ranges:{[2,46)} uses:[24,46] |
David Brazdil | c7465286 | 2015-05-13 17:50:09 +0100 | [diff] [blame] | 80 | // CHECK: Goto liveness:44 |
Nicolas Geoffray | 5790260 | 2015-04-21 14:28:41 +0100 | [diff] [blame] | 81 | |
| 82 | // CHECK-START: void Main.loop6(boolean) liveness (after) |
David Brazdil | c7465286 | 2015-05-13 17:50:09 +0100 | [diff] [blame] | 83 | // CHECK-NOT: Goto liveness:22 |
Nicolas Geoffray | 5790260 | 2015-04-21 14:28:41 +0100 | [diff] [blame] | 84 | public static void loop6(boolean incoming) { |
| 85 | // 'incoming' must have a use only at the first loop's back edge. |
| 86 | while (true) { |
| 87 | System.out.println(incoming); |
| 88 | while (Runtime.getRuntime() != null) {} |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | // CHECK-START: void Main.loop7(boolean) liveness (after) |
David Brazdil | c7a2485 | 2015-05-15 16:44:05 +0100 | [diff] [blame^] | 93 | // CHECK: ParameterValue liveness:2 ranges:{[2,50)} uses:[32,41,46,50] |
David Brazdil | c7465286 | 2015-05-13 17:50:09 +0100 | [diff] [blame] | 94 | // CHECK: Goto liveness:44 |
| 95 | // CHECK: Goto liveness:48 |
Nicolas Geoffray | 5790260 | 2015-04-21 14:28:41 +0100 | [diff] [blame] | 96 | public static void loop7(boolean incoming) { |
| 97 | // 'incoming' must have a use at both back edges. |
| 98 | while (Runtime.getRuntime() != null) { |
| 99 | System.out.println(incoming); |
| 100 | while (incoming) {} |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | // CHECK-START: void Main.loop8() liveness (after) |
David Brazdil | c7a2485 | 2015-05-15 16:44:05 +0100 | [diff] [blame^] | 105 | // CHECK: StaticFieldGet liveness:12 ranges:{[12,44)} uses:[35,40,44] |
David Brazdil | c7465286 | 2015-05-13 17:50:09 +0100 | [diff] [blame] | 106 | // CHECK: Goto liveness:38 |
| 107 | // CHECK: Goto liveness:42 |
Nicolas Geoffray | 5790260 | 2015-04-21 14:28:41 +0100 | [diff] [blame] | 108 | public static void loop8() { |
| 109 | // 'incoming' must have a use at both back edges. |
| 110 | boolean incoming = field; |
| 111 | while (Runtime.getRuntime() != null) { |
| 112 | while (incoming) {} |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | // CHECK-START: void Main.loop9() liveness (after) |
David Brazdil | c7a2485 | 2015-05-15 16:44:05 +0100 | [diff] [blame^] | 117 | // CHECK: StaticFieldGet liveness:22 ranges:{[22,36)} uses:[31,36] |
David Brazdil | c7465286 | 2015-05-13 17:50:09 +0100 | [diff] [blame] | 118 | // CHECK: Goto liveness:38 |
Nicolas Geoffray | 5790260 | 2015-04-21 14:28:41 +0100 | [diff] [blame] | 119 | public static void loop9() { |
| 120 | while (Runtime.getRuntime() != null) { |
| 121 | // 'incoming' must only have a use in the inner loop. |
| 122 | boolean incoming = field; |
| 123 | while (incoming) {} |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | public static void main(String[] args) { |
| 128 | } |
| 129 | |
| 130 | static boolean field; |
| 131 | } |