1*795d594fSAndroid Build Coastguard Worker /* 2*795d594fSAndroid Build Coastguard Worker * Copyright (C) 2022 The Android Open Source Project 3*795d594fSAndroid Build Coastguard Worker * 4*795d594fSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*795d594fSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*795d594fSAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*795d594fSAndroid Build Coastguard Worker * 8*795d594fSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*795d594fSAndroid Build Coastguard Worker * 10*795d594fSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*795d594fSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*795d594fSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*795d594fSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*795d594fSAndroid Build Coastguard Worker * limitations under the License. 15*795d594fSAndroid Build Coastguard Worker */ 16*795d594fSAndroid Build Coastguard Worker 17*795d594fSAndroid Build Coastguard Worker class TestClass { TestClass()18*795d594fSAndroid Build Coastguard Worker TestClass() {} 19*795d594fSAndroid Build Coastguard Worker int i; 20*795d594fSAndroid Build Coastguard Worker int j; 21*795d594fSAndroid Build Coastguard Worker volatile int vi; 22*795d594fSAndroid Build Coastguard Worker } 23*795d594fSAndroid Build Coastguard Worker 24*795d594fSAndroid Build Coastguard Worker public class Main { main(String[] args)25*795d594fSAndroid Build Coastguard Worker public static void main(String[] args) { 26*795d594fSAndroid Build Coastguard Worker // Volatile accesses. 27*795d594fSAndroid Build Coastguard Worker assertEquals(3, $noinline$testVolatileAccessesMustBeKept(new TestClass())); 28*795d594fSAndroid Build Coastguard Worker assertEquals(3, $noinline$testSingletonVolatileAccessesCanBeRemoved()); 29*795d594fSAndroid Build Coastguard Worker 30*795d594fSAndroid Build Coastguard Worker // Volatile loads - Different fields shouldn't alias. 31*795d594fSAndroid Build Coastguard Worker assertEquals(3, $noinline$testVolatileLoadDifferentFields(new TestClass(), new TestClass())); 32*795d594fSAndroid Build Coastguard Worker assertEquals( 33*795d594fSAndroid Build Coastguard Worker 3, $noinline$testVolatileLoadDifferentFieldsBlocking(new TestClass(), new TestClass())); 34*795d594fSAndroid Build Coastguard Worker 35*795d594fSAndroid Build Coastguard Worker // Volatile loads - Redundant store. 36*795d594fSAndroid Build Coastguard Worker assertEquals(2, $noinline$testVolatileLoadRedundantStore(new TestClass())); 37*795d594fSAndroid Build Coastguard Worker assertEquals(2, $noinline$testVolatileLoadRedundantStoreBlocking(new TestClass())); 38*795d594fSAndroid Build Coastguard Worker assertEquals(2, $noinline$testVolatileLoadRedundantStoreBlockingOnlyLoad(new TestClass())); 39*795d594fSAndroid Build Coastguard Worker 40*795d594fSAndroid Build Coastguard Worker // Volatile loads - Set and merge values. 41*795d594fSAndroid Build Coastguard Worker assertEquals(1, $noinline$testVolatileLoadSetAndMergeValues(new TestClass(), true)); 42*795d594fSAndroid Build Coastguard Worker assertEquals(2, $noinline$testVolatileLoadSetAndMergeValues(new TestClass(), false)); 43*795d594fSAndroid Build Coastguard Worker assertEquals(1, $noinline$testVolatileLoadSetAndMergeValuesBlocking(new TestClass(), true)); 44*795d594fSAndroid Build Coastguard Worker assertEquals(2, $noinline$testVolatileLoadSetAndMergeValuesBlocking(new TestClass(), false)); 45*795d594fSAndroid Build Coastguard Worker 46*795d594fSAndroid Build Coastguard Worker // Volatile loads - Removal - Different fields shouldn't alias. 47*795d594fSAndroid Build Coastguard Worker assertEquals(3, 48*795d594fSAndroid Build Coastguard Worker $noinline$testVolatileLoadDifferentFieldsRemovedSynchronization( 49*795d594fSAndroid Build Coastguard Worker new TestClass(), new TestClass())); 50*795d594fSAndroid Build Coastguard Worker 51*795d594fSAndroid Build Coastguard Worker // Volatile loads - Removal - Redundant store. 52*795d594fSAndroid Build Coastguard Worker assertEquals( 53*795d594fSAndroid Build Coastguard Worker 2, $noinline$testVolatileLoadRedundantStoreRemovedSynchronization(new TestClass())); 54*795d594fSAndroid Build Coastguard Worker 55*795d594fSAndroid Build Coastguard Worker // Volatile loads - Removal - Set and merge values. 56*795d594fSAndroid Build Coastguard Worker assertEquals(1, 57*795d594fSAndroid Build Coastguard Worker $noinline$testVolatileLoadSetAndMergeValuesRemovedSynchronization( 58*795d594fSAndroid Build Coastguard Worker new TestClass(), true)); 59*795d594fSAndroid Build Coastguard Worker assertEquals(2, 60*795d594fSAndroid Build Coastguard Worker $noinline$testVolatileLoadSetAndMergeValuesRemovedSynchronization( 61*795d594fSAndroid Build Coastguard Worker new TestClass(), false)); 62*795d594fSAndroid Build Coastguard Worker 63*795d594fSAndroid Build Coastguard Worker // Volatile loads - Removal - with inlining 64*795d594fSAndroid Build Coastguard Worker assertEquals(2, $noinline$testVolatileLoadInlineMethodWithSynchronizedScope(new TestClass())); 65*795d594fSAndroid Build Coastguard Worker 66*795d594fSAndroid Build Coastguard Worker // Volatile stores - Different fields shouldn't alias. 67*795d594fSAndroid Build Coastguard Worker assertEquals(3, $noinline$testVolatileStoreDifferentFields(new TestClass(), new TestClass())); 68*795d594fSAndroid Build Coastguard Worker assertEquals(3, 69*795d594fSAndroid Build Coastguard Worker $noinline$testVolatileStoreDifferentFieldsBlocking(new TestClass(), new TestClass())); 70*795d594fSAndroid Build Coastguard Worker 71*795d594fSAndroid Build Coastguard Worker // Volatile stores - Redundant store. 72*795d594fSAndroid Build Coastguard Worker assertEquals(2, $noinline$testVolatileStoreRedundantStore(new TestClass())); 73*795d594fSAndroid Build Coastguard Worker assertEquals(2, $noinline$testVolatileStoreRedundantStoreBlocking(new TestClass())); 74*795d594fSAndroid Build Coastguard Worker assertEquals(2, $noinline$testVolatileStoreRedundantStoreBlockingOnlyLoad(new TestClass())); 75*795d594fSAndroid Build Coastguard Worker 76*795d594fSAndroid Build Coastguard Worker // Volatile stores - Set and merge values. 77*795d594fSAndroid Build Coastguard Worker assertEquals(1, $noinline$testVolatileStoreSetAndMergeValues(new TestClass(), true)); 78*795d594fSAndroid Build Coastguard Worker assertEquals(2, $noinline$testVolatileStoreSetAndMergeValues(new TestClass(), false)); 79*795d594fSAndroid Build Coastguard Worker assertEquals(1, $noinline$testVolatileStoreSetAndMergeValuesNotBlocking(new TestClass(), true)); 80*795d594fSAndroid Build Coastguard Worker assertEquals( 81*795d594fSAndroid Build Coastguard Worker 2, $noinline$testVolatileStoreSetAndMergeValuesNotBlocking(new TestClass(), false)); 82*795d594fSAndroid Build Coastguard Worker 83*795d594fSAndroid Build Coastguard Worker // Volatile stores - Removal - Different fields shouldn't alias. 84*795d594fSAndroid Build Coastguard Worker assertEquals(3, 85*795d594fSAndroid Build Coastguard Worker $noinline$testVolatileStoreDifferentFieldsRemovedSynchronization( 86*795d594fSAndroid Build Coastguard Worker new TestClass(), new TestClass())); 87*795d594fSAndroid Build Coastguard Worker 88*795d594fSAndroid Build Coastguard Worker // Volatile stores - Removal - Redundant store. 89*795d594fSAndroid Build Coastguard Worker assertEquals( 90*795d594fSAndroid Build Coastguard Worker 2, $noinline$testVolatileStoreRedundantStoreRemovedSynchronization(new TestClass())); 91*795d594fSAndroid Build Coastguard Worker 92*795d594fSAndroid Build Coastguard Worker // Volatile stores - Removal - Set and merge values. 93*795d594fSAndroid Build Coastguard Worker assertEquals(1, 94*795d594fSAndroid Build Coastguard Worker $noinline$testVolatileStoreSetAndMergeValuesRemovedSynchronization( 95*795d594fSAndroid Build Coastguard Worker new TestClass(), true)); 96*795d594fSAndroid Build Coastguard Worker assertEquals(2, 97*795d594fSAndroid Build Coastguard Worker $noinline$testVolatileStoreSetAndMergeValuesRemovedSynchronization( 98*795d594fSAndroid Build Coastguard Worker new TestClass(), false)); 99*795d594fSAndroid Build Coastguard Worker 100*795d594fSAndroid Build Coastguard Worker // Volatile stores - Removal - with inlining 101*795d594fSAndroid Build Coastguard Worker assertEquals(2, $noinline$testVolatileStoreInlineMethodWithSynchronizedScope(new TestClass())); 102*795d594fSAndroid Build Coastguard Worker 103*795d594fSAndroid Build Coastguard Worker // Monitor Operations - Different fields shouldn't alias. 104*795d594fSAndroid Build Coastguard Worker // Make sure the static variable used for synchronization is non-null. 105*795d594fSAndroid Build Coastguard Worker classForSync = new TestClass(); 106*795d594fSAndroid Build Coastguard Worker 107*795d594fSAndroid Build Coastguard Worker assertEquals( 108*795d594fSAndroid Build Coastguard Worker 3, $noinline$testMonitorOperationDifferentFields(new TestClass(), new TestClass())); 109*795d594fSAndroid Build Coastguard Worker assertEquals(3, 110*795d594fSAndroid Build Coastguard Worker $noinline$testMonitorOperationDifferentFieldsBlocking( 111*795d594fSAndroid Build Coastguard Worker new TestClass(), new TestClass())); 112*795d594fSAndroid Build Coastguard Worker 113*795d594fSAndroid Build Coastguard Worker // Monitor Operations - Redundant store. 114*795d594fSAndroid Build Coastguard Worker assertEquals(2, $noinline$testMonitorOperationRedundantStore(new TestClass())); 115*795d594fSAndroid Build Coastguard Worker assertEquals(2, $noinline$testMonitorOperationRedundantStoreBlocking(new TestClass())); 116*795d594fSAndroid Build Coastguard Worker assertEquals(2, $noinline$testMonitorOperationRedundantStoreBlockingOnlyLoad(new TestClass())); 117*795d594fSAndroid Build Coastguard Worker assertEquals(2, $noinline$testMonitorOperationRedundantStoreBlockingExit(new TestClass())); 118*795d594fSAndroid Build Coastguard Worker 119*795d594fSAndroid Build Coastguard Worker // Monitor Operations - Set and merge values. 120*795d594fSAndroid Build Coastguard Worker assertEquals(1, $noinline$testMonitorOperationSetAndMergeValues(new TestClass(), true)); 121*795d594fSAndroid Build Coastguard Worker assertEquals(2, $noinline$testMonitorOperationSetAndMergeValues(new TestClass(), false)); 122*795d594fSAndroid Build Coastguard Worker assertEquals(1, $noinline$testMonitorOperationSetAndMergeValuesBlocking(new TestClass(), true)); 123*795d594fSAndroid Build Coastguard Worker assertEquals( 124*795d594fSAndroid Build Coastguard Worker 2, $noinline$testMonitorOperationSetAndMergeValuesBlocking(new TestClass(), false)); 125*795d594fSAndroid Build Coastguard Worker 126*795d594fSAndroid Build Coastguard Worker // Monitor Operations - Removal - Different fields shouldn't alias. 127*795d594fSAndroid Build Coastguard Worker assertEquals(3, 128*795d594fSAndroid Build Coastguard Worker $noinline$testMonitorOperationDifferentFieldsRemovedSynchronization( 129*795d594fSAndroid Build Coastguard Worker new TestClass(), new TestClass())); 130*795d594fSAndroid Build Coastguard Worker 131*795d594fSAndroid Build Coastguard Worker // Monitor Operations - Removal - Redundant store. 132*795d594fSAndroid Build Coastguard Worker assertEquals( 133*795d594fSAndroid Build Coastguard Worker 2, $noinline$testMonitorOperationRedundantStoreRemovedSynchronization(new TestClass())); 134*795d594fSAndroid Build Coastguard Worker 135*795d594fSAndroid Build Coastguard Worker // Monitor Operations - Removal - Set and merge values. 136*795d594fSAndroid Build Coastguard Worker assertEquals(1, 137*795d594fSAndroid Build Coastguard Worker $noinline$testMonitorOperationSetAndMergeValuesRemovedSynchronization( 138*795d594fSAndroid Build Coastguard Worker new TestClass(), true)); 139*795d594fSAndroid Build Coastguard Worker assertEquals(2, 140*795d594fSAndroid Build Coastguard Worker $noinline$testMonitorOperationSetAndMergeValuesRemovedSynchronization( 141*795d594fSAndroid Build Coastguard Worker new TestClass(), false)); 142*795d594fSAndroid Build Coastguard Worker 143*795d594fSAndroid Build Coastguard Worker // Monitor Operations - Removal - with inlining 144*795d594fSAndroid Build Coastguard Worker assertEquals(2, $noinline$testMonitorOperationInlineSynchronizedMethod(new TestClass())); 145*795d594fSAndroid Build Coastguard Worker assertEquals( 146*795d594fSAndroid Build Coastguard Worker 2, $noinline$testMonitorOperationInlineMethodWithSynchronizedScope(new TestClass())); 147*795d594fSAndroid Build Coastguard Worker } 148*795d594fSAndroid Build Coastguard Worker assertEquals(int expected, int result)149*795d594fSAndroid Build Coastguard Worker public static void assertEquals(int expected, int result) { 150*795d594fSAndroid Build Coastguard Worker if (expected != result) { 151*795d594fSAndroid Build Coastguard Worker throw new Error("Expected: " + expected + ", found: " + result); 152*795d594fSAndroid Build Coastguard Worker } 153*795d594fSAndroid Build Coastguard Worker } 154*795d594fSAndroid Build Coastguard Worker 155*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileAccessesMustBeKept(TestClass) load_store_elimination (before) 156*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 157*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet 158*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet 159*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 160*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet 161*795d594fSAndroid Build Coastguard Worker 162*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileAccessesMustBeKept(TestClass) load_store_elimination (after) 163*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 164*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet 165*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet 166*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 167*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet $noinline$testVolatileAccessesMustBeKept(TestClass obj1)168*795d594fSAndroid Build Coastguard Worker static int $noinline$testVolatileAccessesMustBeKept(TestClass obj1) { 169*795d594fSAndroid Build Coastguard Worker int result; 170*795d594fSAndroid Build Coastguard Worker obj1.vi = 3; 171*795d594fSAndroid Build Coastguard Worker // Redundant load that has to be kept. 172*795d594fSAndroid Build Coastguard Worker result = obj1.vi; 173*795d594fSAndroid Build Coastguard Worker result = obj1.vi; 174*795d594fSAndroid Build Coastguard Worker // Redundant store that has to be kept. 175*795d594fSAndroid Build Coastguard Worker obj1.vi = 3; 176*795d594fSAndroid Build Coastguard Worker result = obj1.vi; 177*795d594fSAndroid Build Coastguard Worker return result; 178*795d594fSAndroid Build Coastguard Worker } 179*795d594fSAndroid Build Coastguard Worker 180*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testSingletonVolatileAccessesCanBeRemoved() load_store_elimination (before) 181*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 182*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet 183*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet 184*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 185*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet 186*795d594fSAndroid Build Coastguard Worker 187*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testSingletonVolatileAccessesCanBeRemoved() load_store_elimination (after) 188*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldSet 189*795d594fSAndroid Build Coastguard Worker 190*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testSingletonVolatileAccessesCanBeRemoved() load_store_elimination (after) 191*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldGet $noinline$testSingletonVolatileAccessesCanBeRemoved()192*795d594fSAndroid Build Coastguard Worker static int $noinline$testSingletonVolatileAccessesCanBeRemoved() { 193*795d594fSAndroid Build Coastguard Worker Main m = new Main(); 194*795d594fSAndroid Build Coastguard Worker int result; 195*795d594fSAndroid Build Coastguard Worker m.vi = 3; 196*795d594fSAndroid Build Coastguard Worker // Redundant load can be removed. 197*795d594fSAndroid Build Coastguard Worker result = m.vi; 198*795d594fSAndroid Build Coastguard Worker result = m.vi; 199*795d594fSAndroid Build Coastguard Worker // Redundant store can be removed. 200*795d594fSAndroid Build Coastguard Worker m.vi = 3; 201*795d594fSAndroid Build Coastguard Worker result = m.vi; 202*795d594fSAndroid Build Coastguard Worker return result; 203*795d594fSAndroid Build Coastguard Worker } 204*795d594fSAndroid Build Coastguard Worker 205*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileLoadDifferentFields(TestClass, TestClass) load_store_elimination (before) 206*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet field_name:TestClass.vi 207*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 208*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 209*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet field_name:TestClass.i 210*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet field_name:TestClass.j 211*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet field_name:TestClass.vi 212*795d594fSAndroid Build Coastguard Worker 213*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileLoadDifferentFields(TestClass, TestClass) load_store_elimination (after) 214*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet field_name:TestClass.vi 215*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 216*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 217*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet field_name:TestClass.vi 218*795d594fSAndroid Build Coastguard Worker 219*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileLoadDifferentFields(TestClass, TestClass) load_store_elimination (after) 220*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldGet field_name:TestClass.i 221*795d594fSAndroid Build Coastguard Worker 222*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileLoadDifferentFields(TestClass, TestClass) load_store_elimination (after) 223*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldGet field_name:TestClass.j 224*795d594fSAndroid Build Coastguard Worker 225*795d594fSAndroid Build Coastguard Worker // Unrelated volatile loads shouldn't block LSE. $noinline$testVolatileLoadDifferentFields(TestClass obj1, TestClass obj2)226*795d594fSAndroid Build Coastguard Worker static int $noinline$testVolatileLoadDifferentFields(TestClass obj1, TestClass obj2) { 227*795d594fSAndroid Build Coastguard Worker int unused = obj1.vi; 228*795d594fSAndroid Build Coastguard Worker obj1.i = 1; 229*795d594fSAndroid Build Coastguard Worker obj2.j = 2; 230*795d594fSAndroid Build Coastguard Worker int result = obj1.i + obj2.j; 231*795d594fSAndroid Build Coastguard Worker unused = obj1.vi; 232*795d594fSAndroid Build Coastguard Worker return result; 233*795d594fSAndroid Build Coastguard Worker } 234*795d594fSAndroid Build Coastguard Worker 235*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileLoadDifferentFieldsBlocking(TestClass, TestClass) load_store_elimination (before) 236*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 237*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 238*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet 239*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet 240*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet 241*795d594fSAndroid Build Coastguard Worker 242*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileLoadDifferentFieldsBlocking(TestClass, TestClass) load_store_elimination (after) 243*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 244*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 245*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet 246*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet 247*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet 248*795d594fSAndroid Build Coastguard Worker 249*795d594fSAndroid Build Coastguard Worker // A volatile load blocks load elimination. $noinline$testVolatileLoadDifferentFieldsBlocking(TestClass obj1, TestClass obj2)250*795d594fSAndroid Build Coastguard Worker static int $noinline$testVolatileLoadDifferentFieldsBlocking(TestClass obj1, TestClass obj2) { 251*795d594fSAndroid Build Coastguard Worker obj1.i = 1; 252*795d594fSAndroid Build Coastguard Worker obj2.j = 2; 253*795d594fSAndroid Build Coastguard Worker int unused = obj1.vi; 254*795d594fSAndroid Build Coastguard Worker return obj1.i + obj2.j; 255*795d594fSAndroid Build Coastguard Worker } 256*795d594fSAndroid Build Coastguard Worker 257*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileLoadRedundantStore(TestClass) load_store_elimination (before) 258*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet field_name:TestClass.vi 259*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet field_name:TestClass.j 260*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet field_name:TestClass.j 261*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet field_name:TestClass.j 262*795d594fSAndroid Build Coastguard Worker 263*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileLoadRedundantStore(TestClass) load_store_elimination (after) 264*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet field_name:TestClass.vi 265*795d594fSAndroid Build Coastguard Worker 266*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileLoadRedundantStore(TestClass) load_store_elimination (after) 267*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet field_name:TestClass.j 268*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldSet field_name:TestClass.j 269*795d594fSAndroid Build Coastguard Worker 270*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileLoadRedundantStore(TestClass) load_store_elimination (after) 271*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldGet field_name:TestClass.j $noinline$testVolatileLoadRedundantStore(TestClass obj)272*795d594fSAndroid Build Coastguard Worker static int $noinline$testVolatileLoadRedundantStore(TestClass obj) { 273*795d594fSAndroid Build Coastguard Worker int unused = obj.vi; 274*795d594fSAndroid Build Coastguard Worker obj.j = 1; 275*795d594fSAndroid Build Coastguard Worker obj.j = 2; 276*795d594fSAndroid Build Coastguard Worker return obj.j; 277*795d594fSAndroid Build Coastguard Worker } 278*795d594fSAndroid Build Coastguard Worker 279*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileLoadRedundantStoreBlocking(TestClass) load_store_elimination (before) 280*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 281*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet 282*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 283*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet 284*795d594fSAndroid Build Coastguard Worker 285*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileLoadRedundantStoreBlocking(TestClass) load_store_elimination (after) 286*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 287*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet field_name:TestClass.vi 288*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 289*795d594fSAndroid Build Coastguard Worker 290*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileLoadRedundantStoreBlocking(TestClass) load_store_elimination (after) 291*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldGet field_name:TestClass.j $noinline$testVolatileLoadRedundantStoreBlocking(TestClass obj)292*795d594fSAndroid Build Coastguard Worker static int $noinline$testVolatileLoadRedundantStoreBlocking(TestClass obj) { 293*795d594fSAndroid Build Coastguard Worker // This store must be kept due to the volatile load. 294*795d594fSAndroid Build Coastguard Worker obj.j = 1; 295*795d594fSAndroid Build Coastguard Worker int unused = obj.vi; 296*795d594fSAndroid Build Coastguard Worker obj.j = 2; 297*795d594fSAndroid Build Coastguard Worker return obj.j; 298*795d594fSAndroid Build Coastguard Worker } 299*795d594fSAndroid Build Coastguard Worker 300*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileLoadRedundantStoreBlockingOnlyLoad(TestClass) load_store_elimination (before) 301*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 302*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 303*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet 304*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet 305*795d594fSAndroid Build Coastguard Worker 306*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileLoadRedundantStoreBlockingOnlyLoad(TestClass) load_store_elimination (after) 307*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 308*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldSet 309*795d594fSAndroid Build Coastguard Worker 310*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileLoadRedundantStoreBlockingOnlyLoad(TestClass) load_store_elimination (after) 311*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet 312*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet $noinline$testVolatileLoadRedundantStoreBlockingOnlyLoad(TestClass obj)313*795d594fSAndroid Build Coastguard Worker static int $noinline$testVolatileLoadRedundantStoreBlockingOnlyLoad(TestClass obj) { 314*795d594fSAndroid Build Coastguard Worker // This store can be safely removed. 315*795d594fSAndroid Build Coastguard Worker obj.j = 1; 316*795d594fSAndroid Build Coastguard Worker obj.j = 2; 317*795d594fSAndroid Build Coastguard Worker int unused = obj.vi; 318*795d594fSAndroid Build Coastguard Worker // This load remains due to the volatile load in the middle. 319*795d594fSAndroid Build Coastguard Worker return obj.j; 320*795d594fSAndroid Build Coastguard Worker } 321*795d594fSAndroid Build Coastguard Worker 322*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileLoadSetAndMergeValues(TestClass, boolean) load_store_elimination (before) 323*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldSet 324*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldSet 325*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldGet field_name:TestClass.i 326*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldGet field_name:TestClass.vi 327*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldGet field_name:TestClass.vi 328*795d594fSAndroid Build Coastguard Worker 329*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileLoadSetAndMergeValues(TestClass, boolean) load_store_elimination (after) 330*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldSet 331*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldSet 332*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldGet field_name:TestClass.vi 333*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldGet field_name:TestClass.vi 334*795d594fSAndroid Build Coastguard Worker 335*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileLoadSetAndMergeValues(TestClass, boolean) load_store_elimination (after) 336*795d594fSAndroid Build Coastguard Worker /// CHECK: Phi 337*795d594fSAndroid Build Coastguard Worker 338*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileLoadSetAndMergeValues(TestClass, boolean) load_store_elimination (after) 339*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldGet field_name:TestClass.i 340*795d594fSAndroid Build Coastguard Worker $noinline$testVolatileLoadSetAndMergeValues(TestClass obj, boolean b)341*795d594fSAndroid Build Coastguard Worker static int $noinline$testVolatileLoadSetAndMergeValues(TestClass obj, boolean b) { 342*795d594fSAndroid Build Coastguard Worker if (b) { 343*795d594fSAndroid Build Coastguard Worker int unused = obj.vi; 344*795d594fSAndroid Build Coastguard Worker obj.i = 1; 345*795d594fSAndroid Build Coastguard Worker } else { 346*795d594fSAndroid Build Coastguard Worker int unused = obj.vi; 347*795d594fSAndroid Build Coastguard Worker obj.i = 2; 348*795d594fSAndroid Build Coastguard Worker } 349*795d594fSAndroid Build Coastguard Worker return obj.i; 350*795d594fSAndroid Build Coastguard Worker } 351*795d594fSAndroid Build Coastguard Worker 352*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileLoadSetAndMergeValuesBlocking(TestClass, boolean) load_store_elimination (before) 353*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldSet 354*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldSet 355*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldGet field_name:TestClass.i 356*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldGet field_name:TestClass.vi 357*795d594fSAndroid Build Coastguard Worker 358*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileLoadSetAndMergeValuesBlocking(TestClass, boolean) load_store_elimination (after) 359*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldSet 360*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldSet 361*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldGet field_name:TestClass.vi 362*795d594fSAndroid Build Coastguard Worker 363*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileLoadSetAndMergeValuesBlocking(TestClass, boolean) load_store_elimination (after) 364*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Phi 365*795d594fSAndroid Build Coastguard Worker 366*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileLoadSetAndMergeValuesBlocking(TestClass, boolean) load_store_elimination (after) 367*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet 368*795d594fSAndroid Build Coastguard Worker $noinline$testVolatileLoadSetAndMergeValuesBlocking(TestClass obj, boolean b)369*795d594fSAndroid Build Coastguard Worker static int $noinline$testVolatileLoadSetAndMergeValuesBlocking(TestClass obj, boolean b) { 370*795d594fSAndroid Build Coastguard Worker if (b) { 371*795d594fSAndroid Build Coastguard Worker obj.i = 1; 372*795d594fSAndroid Build Coastguard Worker } else { 373*795d594fSAndroid Build Coastguard Worker obj.i = 2; 374*795d594fSAndroid Build Coastguard Worker } 375*795d594fSAndroid Build Coastguard Worker int unused = obj.vi; 376*795d594fSAndroid Build Coastguard Worker return obj.i; 377*795d594fSAndroid Build Coastguard Worker } 378*795d594fSAndroid Build Coastguard Worker 379*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileLoadDifferentFieldsRemovedSynchronization(TestClass, TestClass) load_store_elimination (before) 380*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 381*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 382*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet field_name:Main.vi 383*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet 384*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet 385*795d594fSAndroid Build Coastguard Worker 386*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileLoadDifferentFieldsRemovedSynchronization(TestClass, TestClass) load_store_elimination (after) 387*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldGet field_name:Main.vi 388*795d594fSAndroid Build Coastguard Worker 389*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileLoadDifferentFieldsRemovedSynchronization(TestClass, TestClass) load_store_elimination (after) 390*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 391*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 392*795d594fSAndroid Build Coastguard Worker 393*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileLoadDifferentFieldsRemovedSynchronization(TestClass, TestClass) load_store_elimination (after) 394*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldGet 395*795d594fSAndroid Build Coastguard Worker $noinline$testVolatileLoadDifferentFieldsRemovedSynchronization( TestClass obj1, TestClass obj2)396*795d594fSAndroid Build Coastguard Worker static int $noinline$testVolatileLoadDifferentFieldsRemovedSynchronization( 397*795d594fSAndroid Build Coastguard Worker TestClass obj1, TestClass obj2) { 398*795d594fSAndroid Build Coastguard Worker Main m = new Main(); 399*795d594fSAndroid Build Coastguard Worker 400*795d594fSAndroid Build Coastguard Worker obj1.i = 1; 401*795d594fSAndroid Build Coastguard Worker obj2.j = 2; 402*795d594fSAndroid Build Coastguard Worker int unused = m.vi; 403*795d594fSAndroid Build Coastguard Worker 404*795d594fSAndroid Build Coastguard Worker return obj1.i + obj2.j; 405*795d594fSAndroid Build Coastguard Worker } 406*795d594fSAndroid Build Coastguard Worker 407*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileLoadRedundantStoreRemovedSynchronization(TestClass) load_store_elimination (before) 408*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 409*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet field_name:Main.vi 410*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 411*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet field_name:Main.vi 412*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet 413*795d594fSAndroid Build Coastguard Worker 414*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileLoadRedundantStoreRemovedSynchronization(TestClass) load_store_elimination (after) 415*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldGet field_name:Main.vi 416*795d594fSAndroid Build Coastguard Worker 417*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileLoadRedundantStoreRemovedSynchronization(TestClass) load_store_elimination (after) 418*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 419*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldSet 420*795d594fSAndroid Build Coastguard Worker 421*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileLoadRedundantStoreRemovedSynchronization(TestClass) load_store_elimination (after) 422*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldGet 423*795d594fSAndroid Build Coastguard Worker $noinline$testVolatileLoadRedundantStoreRemovedSynchronization(TestClass obj)424*795d594fSAndroid Build Coastguard Worker static int $noinline$testVolatileLoadRedundantStoreRemovedSynchronization(TestClass obj) { 425*795d594fSAndroid Build Coastguard Worker Main m = new Main(); 426*795d594fSAndroid Build Coastguard Worker 427*795d594fSAndroid Build Coastguard Worker obj.j = 1; 428*795d594fSAndroid Build Coastguard Worker int unused = m.vi; 429*795d594fSAndroid Build Coastguard Worker obj.j = 2; 430*795d594fSAndroid Build Coastguard Worker unused = m.vi; 431*795d594fSAndroid Build Coastguard Worker 432*795d594fSAndroid Build Coastguard Worker return obj.j; 433*795d594fSAndroid Build Coastguard Worker } 434*795d594fSAndroid Build Coastguard Worker 435*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileLoadSetAndMergeValuesRemovedSynchronization(TestClass, boolean) load_store_elimination (before) 436*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldSet 437*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldSet 438*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldGet field_name:Main.vi 439*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldGet 440*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return 441*795d594fSAndroid Build Coastguard Worker 442*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileLoadSetAndMergeValuesRemovedSynchronization(TestClass, boolean) load_store_elimination (after) 443*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldSet 444*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldSet 445*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return 446*795d594fSAndroid Build Coastguard Worker 447*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileLoadSetAndMergeValuesRemovedSynchronization(TestClass, boolean) load_store_elimination (after) 448*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldGet field_name:Main.vi 449*795d594fSAndroid Build Coastguard Worker 450*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileLoadSetAndMergeValuesRemovedSynchronization(TestClass, boolean) load_store_elimination (after) 451*795d594fSAndroid Build Coastguard Worker /// CHECK: Phi 452*795d594fSAndroid Build Coastguard Worker 453*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileLoadSetAndMergeValuesRemovedSynchronization(TestClass, boolean) load_store_elimination (after) 454*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldGet 455*795d594fSAndroid Build Coastguard Worker $noinline$testVolatileLoadSetAndMergeValuesRemovedSynchronization( TestClass obj, boolean b)456*795d594fSAndroid Build Coastguard Worker static int $noinline$testVolatileLoadSetAndMergeValuesRemovedSynchronization( 457*795d594fSAndroid Build Coastguard Worker TestClass obj, boolean b) { 458*795d594fSAndroid Build Coastguard Worker Main m = new Main(); 459*795d594fSAndroid Build Coastguard Worker 460*795d594fSAndroid Build Coastguard Worker if (b) { 461*795d594fSAndroid Build Coastguard Worker obj.i = 1; 462*795d594fSAndroid Build Coastguard Worker } else { 463*795d594fSAndroid Build Coastguard Worker obj.i = 2; 464*795d594fSAndroid Build Coastguard Worker } 465*795d594fSAndroid Build Coastguard Worker int unused = m.vi; 466*795d594fSAndroid Build Coastguard Worker return obj.i; 467*795d594fSAndroid Build Coastguard Worker } 468*795d594fSAndroid Build Coastguard Worker 469*795d594fSAndroid Build Coastguard Worker // Can't eliminate the setters, or volatile getters in this method. 470*795d594fSAndroid Build Coastguard Worker 471*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$inline$SetterWithVolatileLoads(TestClass) load_store_elimination (before) 472*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet field_name:TestClass.j 473*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet field_name:Main.vi 474*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet field_name:TestClass.j 475*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet field_name:Main.vi 476*795d594fSAndroid Build Coastguard Worker 477*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$inline$SetterWithVolatileLoads(TestClass) load_store_elimination (after) 478*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet field_name:TestClass.j 479*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet field_name:Main.vi 480*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet field_name:TestClass.j 481*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet field_name:Main.vi $inline$SetterWithVolatileLoads(TestClass obj)482*795d594fSAndroid Build Coastguard Worker int $inline$SetterWithVolatileLoads(TestClass obj) { 483*795d594fSAndroid Build Coastguard Worker obj.j = 1; 484*795d594fSAndroid Build Coastguard Worker int unused = this.vi; 485*795d594fSAndroid Build Coastguard Worker obj.j = 2; 486*795d594fSAndroid Build Coastguard Worker unused = this.vi; 487*795d594fSAndroid Build Coastguard Worker return obj.j; 488*795d594fSAndroid Build Coastguard Worker } 489*795d594fSAndroid Build Coastguard Worker 490*795d594fSAndroid Build Coastguard Worker // But we can eliminate once inlined. 491*795d594fSAndroid Build Coastguard Worker 492*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileLoadInlineMethodWithSynchronizedScope(TestClass) load_store_elimination (before) 493*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet field_name:TestClass.j 494*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet field_name:Main.vi 495*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet field_name:TestClass.j 496*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet field_name:Main.vi 497*795d594fSAndroid Build Coastguard Worker 498*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileLoadInlineMethodWithSynchronizedScope(TestClass) load_store_elimination (after) 499*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldGet field_name:Main.vi 500*795d594fSAndroid Build Coastguard Worker 501*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileLoadInlineMethodWithSynchronizedScope(TestClass) load_store_elimination (after) 502*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet field_name:TestClass.j 503*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldSet field_name:TestClass.j $noinline$testVolatileLoadInlineMethodWithSynchronizedScope(TestClass obj)504*795d594fSAndroid Build Coastguard Worker static int $noinline$testVolatileLoadInlineMethodWithSynchronizedScope(TestClass obj) { 505*795d594fSAndroid Build Coastguard Worker Main m = new Main(); 506*795d594fSAndroid Build Coastguard Worker return m.$inline$SetterWithVolatileLoads(obj); 507*795d594fSAndroid Build Coastguard Worker } 508*795d594fSAndroid Build Coastguard Worker 509*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileStoreDifferentFields(TestClass, TestClass) load_store_elimination (before) 510*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet field_name:TestClass.vi 511*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 512*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 513*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet field_name:TestClass.i 514*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet field_name:TestClass.j 515*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet field_name:TestClass.vi 516*795d594fSAndroid Build Coastguard Worker 517*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileStoreDifferentFields(TestClass, TestClass) load_store_elimination (after) 518*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet field_name:TestClass.vi 519*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 520*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 521*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet field_name:TestClass.vi 522*795d594fSAndroid Build Coastguard Worker 523*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileStoreDifferentFields(TestClass, TestClass) load_store_elimination (after) 524*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldGet field_name:TestClass.i 525*795d594fSAndroid Build Coastguard Worker 526*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileStoreDifferentFields(TestClass, TestClass) load_store_elimination (after) 527*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldGet field_name:TestClass.j 528*795d594fSAndroid Build Coastguard Worker 529*795d594fSAndroid Build Coastguard Worker // Unrelated volatile stores shouldn't block LSE. $noinline$testVolatileStoreDifferentFields(TestClass obj1, TestClass obj2)530*795d594fSAndroid Build Coastguard Worker static int $noinline$testVolatileStoreDifferentFields(TestClass obj1, TestClass obj2) { 531*795d594fSAndroid Build Coastguard Worker obj1.vi = 123; 532*795d594fSAndroid Build Coastguard Worker obj1.i = 1; 533*795d594fSAndroid Build Coastguard Worker obj2.j = 2; 534*795d594fSAndroid Build Coastguard Worker int result = obj1.i + obj2.j; 535*795d594fSAndroid Build Coastguard Worker obj1.vi = 123; 536*795d594fSAndroid Build Coastguard Worker return result; 537*795d594fSAndroid Build Coastguard Worker } 538*795d594fSAndroid Build Coastguard Worker 539*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileStoreDifferentFieldsBlocking(TestClass, TestClass) load_store_elimination (before) 540*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 541*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 542*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 543*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet 544*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet 545*795d594fSAndroid Build Coastguard Worker 546*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileStoreDifferentFieldsBlocking(TestClass, TestClass) load_store_elimination (after) 547*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 548*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 549*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 550*795d594fSAndroid Build Coastguard Worker 551*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileStoreDifferentFieldsBlocking(TestClass, TestClass) load_store_elimination (after) 552*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldGet 553*795d594fSAndroid Build Coastguard Worker 554*795d594fSAndroid Build Coastguard Worker // A volatile store doesn't block load elimination, as it doesn't clobber existing values. $noinline$testVolatileStoreDifferentFieldsBlocking(TestClass obj1, TestClass obj2)555*795d594fSAndroid Build Coastguard Worker static int $noinline$testVolatileStoreDifferentFieldsBlocking(TestClass obj1, TestClass obj2) { 556*795d594fSAndroid Build Coastguard Worker obj1.i = 1; 557*795d594fSAndroid Build Coastguard Worker obj2.j = 2; 558*795d594fSAndroid Build Coastguard Worker obj1.vi = 123; 559*795d594fSAndroid Build Coastguard Worker return obj1.i + obj2.j; 560*795d594fSAndroid Build Coastguard Worker } 561*795d594fSAndroid Build Coastguard Worker 562*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileStoreRedundantStore(TestClass) load_store_elimination (before) 563*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet field_name:TestClass.vi 564*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet field_name:TestClass.j 565*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet field_name:TestClass.j 566*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet 567*795d594fSAndroid Build Coastguard Worker 568*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileStoreRedundantStore(TestClass) load_store_elimination (after) 569*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet field_name:TestClass.vi 570*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet field_name:TestClass.j 571*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldSet field_name:TestClass.j 572*795d594fSAndroid Build Coastguard Worker 573*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileStoreRedundantStore(TestClass) load_store_elimination (after) 574*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldGet $noinline$testVolatileStoreRedundantStore(TestClass obj)575*795d594fSAndroid Build Coastguard Worker static int $noinline$testVolatileStoreRedundantStore(TestClass obj) { 576*795d594fSAndroid Build Coastguard Worker obj.vi = 123; 577*795d594fSAndroid Build Coastguard Worker obj.j = 1; 578*795d594fSAndroid Build Coastguard Worker obj.j = 2; 579*795d594fSAndroid Build Coastguard Worker return obj.j; 580*795d594fSAndroid Build Coastguard Worker } 581*795d594fSAndroid Build Coastguard Worker 582*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileStoreRedundantStoreBlocking(TestClass) load_store_elimination (before) 583*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 584*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 585*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 586*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet 587*795d594fSAndroid Build Coastguard Worker 588*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileStoreRedundantStoreBlocking(TestClass) load_store_elimination (after) 589*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 590*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 591*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 592*795d594fSAndroid Build Coastguard Worker 593*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileStoreRedundantStoreBlocking(TestClass) load_store_elimination (after) 594*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldGet $noinline$testVolatileStoreRedundantStoreBlocking(TestClass obj)595*795d594fSAndroid Build Coastguard Worker static int $noinline$testVolatileStoreRedundantStoreBlocking(TestClass obj) { 596*795d594fSAndroid Build Coastguard Worker // This store must be kept due to the volatile store. 597*795d594fSAndroid Build Coastguard Worker obj.j = 1; 598*795d594fSAndroid Build Coastguard Worker obj.vi = 123; 599*795d594fSAndroid Build Coastguard Worker obj.j = 2; 600*795d594fSAndroid Build Coastguard Worker return obj.j; 601*795d594fSAndroid Build Coastguard Worker } 602*795d594fSAndroid Build Coastguard Worker 603*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileStoreRedundantStoreBlockingOnlyLoad(TestClass) load_store_elimination (before) 604*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet field_name:TestClass.j 605*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet field_name:TestClass.j 606*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet field_name:TestClass.vi 607*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet 608*795d594fSAndroid Build Coastguard Worker 609*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileStoreRedundantStoreBlockingOnlyLoad(TestClass) load_store_elimination (after) 610*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet field_name:TestClass.j 611*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldSet field_name:TestClass.j 612*795d594fSAndroid Build Coastguard Worker 613*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileStoreRedundantStoreBlockingOnlyLoad(TestClass) load_store_elimination (after) 614*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet field_name:TestClass.vi 615*795d594fSAndroid Build Coastguard Worker 616*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileStoreRedundantStoreBlockingOnlyLoad(TestClass) load_store_elimination (after) 617*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldGet $noinline$testVolatileStoreRedundantStoreBlockingOnlyLoad(TestClass obj)618*795d594fSAndroid Build Coastguard Worker static int $noinline$testVolatileStoreRedundantStoreBlockingOnlyLoad(TestClass obj) { 619*795d594fSAndroid Build Coastguard Worker // This store can be safely removed. 620*795d594fSAndroid Build Coastguard Worker obj.j = 1; 621*795d594fSAndroid Build Coastguard Worker obj.j = 2; 622*795d594fSAndroid Build Coastguard Worker obj.vi = 123; 623*795d594fSAndroid Build Coastguard Worker // This load can also be safely eliminated as the volatile store doesn't clobber values. 624*795d594fSAndroid Build Coastguard Worker return obj.j; 625*795d594fSAndroid Build Coastguard Worker } 626*795d594fSAndroid Build Coastguard Worker 627*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileStoreSetAndMergeValues(TestClass, boolean) load_store_elimination (before) 628*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldSet 629*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldSet 630*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldSet 631*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldSet 632*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldGet 633*795d594fSAndroid Build Coastguard Worker 634*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileStoreSetAndMergeValues(TestClass, boolean) load_store_elimination (after) 635*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldSet 636*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldSet 637*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldSet 638*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldSet 639*795d594fSAndroid Build Coastguard Worker 640*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileStoreSetAndMergeValues(TestClass, boolean) load_store_elimination (after) 641*795d594fSAndroid Build Coastguard Worker /// CHECK: Phi 642*795d594fSAndroid Build Coastguard Worker 643*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileStoreSetAndMergeValues(TestClass, boolean) load_store_elimination (after) 644*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldGet $noinline$testVolatileStoreSetAndMergeValues(TestClass obj, boolean b)645*795d594fSAndroid Build Coastguard Worker static int $noinline$testVolatileStoreSetAndMergeValues(TestClass obj, boolean b) { 646*795d594fSAndroid Build Coastguard Worker if (b) { 647*795d594fSAndroid Build Coastguard Worker obj.vi = 123; 648*795d594fSAndroid Build Coastguard Worker obj.i = 1; 649*795d594fSAndroid Build Coastguard Worker } else { 650*795d594fSAndroid Build Coastguard Worker obj.vi = 123; 651*795d594fSAndroid Build Coastguard Worker obj.i = 2; 652*795d594fSAndroid Build Coastguard Worker } 653*795d594fSAndroid Build Coastguard Worker return obj.i; 654*795d594fSAndroid Build Coastguard Worker } 655*795d594fSAndroid Build Coastguard Worker 656*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileStoreSetAndMergeValuesNotBlocking(TestClass, boolean) load_store_elimination (before) 657*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldSet 658*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldSet 659*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldSet 660*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldGet 661*795d594fSAndroid Build Coastguard Worker 662*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileStoreSetAndMergeValuesNotBlocking(TestClass, boolean) load_store_elimination (after) 663*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldSet 664*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldSet 665*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldSet 666*795d594fSAndroid Build Coastguard Worker 667*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileStoreSetAndMergeValues(TestClass, boolean) load_store_elimination (after) 668*795d594fSAndroid Build Coastguard Worker /// CHECK: Phi 669*795d594fSAndroid Build Coastguard Worker 670*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileStoreSetAndMergeValues(TestClass, boolean) load_store_elimination (after) 671*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldGet $noinline$testVolatileStoreSetAndMergeValuesNotBlocking(TestClass obj, boolean b)672*795d594fSAndroid Build Coastguard Worker static int $noinline$testVolatileStoreSetAndMergeValuesNotBlocking(TestClass obj, boolean b) { 673*795d594fSAndroid Build Coastguard Worker if (b) { 674*795d594fSAndroid Build Coastguard Worker obj.i = 1; 675*795d594fSAndroid Build Coastguard Worker } else { 676*795d594fSAndroid Build Coastguard Worker obj.i = 2; 677*795d594fSAndroid Build Coastguard Worker } 678*795d594fSAndroid Build Coastguard Worker // This volatile store doesn't block the load elimination 679*795d594fSAndroid Build Coastguard Worker obj.vi = 123; 680*795d594fSAndroid Build Coastguard Worker return obj.i; 681*795d594fSAndroid Build Coastguard Worker } 682*795d594fSAndroid Build Coastguard Worker 683*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileStoreDifferentFieldsRemovedSynchronization(TestClass, TestClass) load_store_elimination (before) 684*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 685*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 686*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet field_name:Main.vi 687*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet 688*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet 689*795d594fSAndroid Build Coastguard Worker 690*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileStoreDifferentFieldsRemovedSynchronization(TestClass, TestClass) load_store_elimination (after) 691*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldSet field_name:Main.vi 692*795d594fSAndroid Build Coastguard Worker 693*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileStoreDifferentFieldsRemovedSynchronization(TestClass, TestClass) load_store_elimination (after) 694*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 695*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 696*795d594fSAndroid Build Coastguard Worker 697*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileStoreDifferentFieldsRemovedSynchronization(TestClass, TestClass) load_store_elimination (after) 698*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldGet 699*795d594fSAndroid Build Coastguard Worker $noinline$testVolatileStoreDifferentFieldsRemovedSynchronization( TestClass obj1, TestClass obj2)700*795d594fSAndroid Build Coastguard Worker static int $noinline$testVolatileStoreDifferentFieldsRemovedSynchronization( 701*795d594fSAndroid Build Coastguard Worker TestClass obj1, TestClass obj2) { 702*795d594fSAndroid Build Coastguard Worker Main m = new Main(); 703*795d594fSAndroid Build Coastguard Worker 704*795d594fSAndroid Build Coastguard Worker obj1.i = 1; 705*795d594fSAndroid Build Coastguard Worker obj2.j = 2; 706*795d594fSAndroid Build Coastguard Worker m.vi = 123; 707*795d594fSAndroid Build Coastguard Worker 708*795d594fSAndroid Build Coastguard Worker return obj1.i + obj2.j; 709*795d594fSAndroid Build Coastguard Worker } 710*795d594fSAndroid Build Coastguard Worker 711*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileStoreRedundantStoreRemovedSynchronization(TestClass) load_store_elimination (before) 712*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 713*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 714*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 715*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 716*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet 717*795d594fSAndroid Build Coastguard Worker 718*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileStoreRedundantStoreRemovedSynchronization(TestClass) load_store_elimination (after) 719*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldSet field_name:Main.vi 720*795d594fSAndroid Build Coastguard Worker 721*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileStoreRedundantStoreRemovedSynchronization(TestClass) load_store_elimination (after) 722*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 723*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldSet 724*795d594fSAndroid Build Coastguard Worker 725*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileStoreRedundantStoreRemovedSynchronization(TestClass) load_store_elimination (after) 726*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldGet 727*795d594fSAndroid Build Coastguard Worker $noinline$testVolatileStoreRedundantStoreRemovedSynchronization(TestClass obj)728*795d594fSAndroid Build Coastguard Worker static int $noinline$testVolatileStoreRedundantStoreRemovedSynchronization(TestClass obj) { 729*795d594fSAndroid Build Coastguard Worker Main m = new Main(); 730*795d594fSAndroid Build Coastguard Worker 731*795d594fSAndroid Build Coastguard Worker obj.j = 1; 732*795d594fSAndroid Build Coastguard Worker m.vi = 123; 733*795d594fSAndroid Build Coastguard Worker obj.j = 2; 734*795d594fSAndroid Build Coastguard Worker m.vi = 123; 735*795d594fSAndroid Build Coastguard Worker 736*795d594fSAndroid Build Coastguard Worker return obj.j; 737*795d594fSAndroid Build Coastguard Worker } 738*795d594fSAndroid Build Coastguard Worker 739*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileStoreSetAndMergeValuesRemovedSynchronization(TestClass, boolean) load_store_elimination (before) 740*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldSet 741*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldSet 742*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldSet 743*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldGet 744*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return 745*795d594fSAndroid Build Coastguard Worker 746*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileStoreSetAndMergeValuesRemovedSynchronization(TestClass, boolean) load_store_elimination (after) 747*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldSet 748*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldSet 749*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return 750*795d594fSAndroid Build Coastguard Worker 751*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileStoreSetAndMergeValuesRemovedSynchronization(TestClass, boolean) load_store_elimination (after) 752*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldSet field_name:Main.vi 753*795d594fSAndroid Build Coastguard Worker 754*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileStoreSetAndMergeValuesRemovedSynchronization(TestClass, boolean) load_store_elimination (after) 755*795d594fSAndroid Build Coastguard Worker /// CHECK: Phi 756*795d594fSAndroid Build Coastguard Worker 757*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileStoreSetAndMergeValuesRemovedSynchronization(TestClass, boolean) load_store_elimination (after) 758*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldGet 759*795d594fSAndroid Build Coastguard Worker $noinline$testVolatileStoreSetAndMergeValuesRemovedSynchronization( TestClass obj, boolean b)760*795d594fSAndroid Build Coastguard Worker static int $noinline$testVolatileStoreSetAndMergeValuesRemovedSynchronization( 761*795d594fSAndroid Build Coastguard Worker TestClass obj, boolean b) { 762*795d594fSAndroid Build Coastguard Worker Main m = new Main(); 763*795d594fSAndroid Build Coastguard Worker 764*795d594fSAndroid Build Coastguard Worker if (b) { 765*795d594fSAndroid Build Coastguard Worker obj.i = 1; 766*795d594fSAndroid Build Coastguard Worker } else { 767*795d594fSAndroid Build Coastguard Worker obj.i = 2; 768*795d594fSAndroid Build Coastguard Worker } 769*795d594fSAndroid Build Coastguard Worker m.vi = 123; 770*795d594fSAndroid Build Coastguard Worker return obj.i; 771*795d594fSAndroid Build Coastguard Worker } 772*795d594fSAndroid Build Coastguard Worker 773*795d594fSAndroid Build Coastguard Worker // Can't eliminate the setters in this method. 774*795d594fSAndroid Build Coastguard Worker 775*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$inline$SetterWithVolatileStores(TestClass) load_store_elimination (before) 776*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet field_name:TestClass.j 777*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet field_name:Main.vi 778*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet field_name:TestClass.j 779*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet field_name:Main.vi 780*795d594fSAndroid Build Coastguard Worker 781*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$inline$SetterWithVolatileStores(TestClass) load_store_elimination (after) 782*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet field_name:TestClass.j 783*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet field_name:Main.vi 784*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet field_name:TestClass.j 785*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet field_name:Main.vi $inline$SetterWithVolatileStores(TestClass obj)786*795d594fSAndroid Build Coastguard Worker int $inline$SetterWithVolatileStores(TestClass obj) { 787*795d594fSAndroid Build Coastguard Worker obj.j = 1; 788*795d594fSAndroid Build Coastguard Worker this.vi = 123; 789*795d594fSAndroid Build Coastguard Worker obj.j = 2; 790*795d594fSAndroid Build Coastguard Worker this.vi = 123; 791*795d594fSAndroid Build Coastguard Worker return obj.j; 792*795d594fSAndroid Build Coastguard Worker } 793*795d594fSAndroid Build Coastguard Worker 794*795d594fSAndroid Build Coastguard Worker // But we can eliminate once inlined. 795*795d594fSAndroid Build Coastguard Worker 796*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileStoreInlineMethodWithSynchronizedScope(TestClass) load_store_elimination (before) 797*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet field_name:TestClass.j 798*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet field_name:Main.vi 799*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet field_name:TestClass.j 800*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet field_name:Main.vi 801*795d594fSAndroid Build Coastguard Worker 802*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileStoreInlineMethodWithSynchronizedScope(TestClass) load_store_elimination (after) 803*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldSet field_name:Main.vi 804*795d594fSAndroid Build Coastguard Worker 805*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testVolatileStoreInlineMethodWithSynchronizedScope(TestClass) load_store_elimination (after) 806*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet field_name:TestClass.j 807*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldSet field_name:TestClass.j $noinline$testVolatileStoreInlineMethodWithSynchronizedScope(TestClass obj)808*795d594fSAndroid Build Coastguard Worker static int $noinline$testVolatileStoreInlineMethodWithSynchronizedScope(TestClass obj) { 809*795d594fSAndroid Build Coastguard Worker Main m = new Main(); 810*795d594fSAndroid Build Coastguard Worker return m.$inline$SetterWithVolatileStores(obj); 811*795d594fSAndroid Build Coastguard Worker } 812*795d594fSAndroid Build Coastguard Worker 813*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationDifferentFields(TestClass, TestClass) load_store_elimination (before) 814*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 815*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 816*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet 817*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet 818*795d594fSAndroid Build Coastguard Worker 819*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationDifferentFields(TestClass, TestClass) load_store_elimination (before) 820*795d594fSAndroid Build Coastguard Worker /// CHECK: MonitorOperation kind:enter 821*795d594fSAndroid Build Coastguard Worker /// CHECK: MonitorOperation kind:exit 822*795d594fSAndroid Build Coastguard Worker /// CHECK: MonitorOperation kind:enter 823*795d594fSAndroid Build Coastguard Worker /// CHECK: MonitorOperation kind:exit 824*795d594fSAndroid Build Coastguard Worker 825*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationDifferentFields(TestClass, TestClass) load_store_elimination (after) 826*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 827*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 828*795d594fSAndroid Build Coastguard Worker 829*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationDifferentFields(TestClass, TestClass) load_store_elimination (after) 830*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldGet 831*795d594fSAndroid Build Coastguard Worker 832*795d594fSAndroid Build Coastguard Worker // Unrelated monitor operations shouldn't block LSE. $noinline$testMonitorOperationDifferentFields(TestClass obj1, TestClass obj2)833*795d594fSAndroid Build Coastguard Worker static int $noinline$testMonitorOperationDifferentFields(TestClass obj1, TestClass obj2) { 834*795d594fSAndroid Build Coastguard Worker synchronized (classForSync) {} 835*795d594fSAndroid Build Coastguard Worker obj1.i = 1; 836*795d594fSAndroid Build Coastguard Worker obj2.j = 2; 837*795d594fSAndroid Build Coastguard Worker int result = obj1.i + obj2.j; 838*795d594fSAndroid Build Coastguard Worker synchronized (classForSync) {} 839*795d594fSAndroid Build Coastguard Worker return result; 840*795d594fSAndroid Build Coastguard Worker } 841*795d594fSAndroid Build Coastguard Worker 842*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationDifferentFieldsBlocking(TestClass, TestClass) load_store_elimination (before) 843*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 844*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 845*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet 846*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet 847*795d594fSAndroid Build Coastguard Worker 848*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationDifferentFieldsBlocking(TestClass, TestClass) load_store_elimination (before) 849*795d594fSAndroid Build Coastguard Worker /// CHECK: MonitorOperation kind:enter 850*795d594fSAndroid Build Coastguard Worker /// CHECK: MonitorOperation kind:exit 851*795d594fSAndroid Build Coastguard Worker 852*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationDifferentFieldsBlocking(TestClass, TestClass) load_store_elimination (after) 853*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 854*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 855*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet 856*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet 857*795d594fSAndroid Build Coastguard Worker 858*795d594fSAndroid Build Coastguard Worker // A synchronized operation blocks loads. $noinline$testMonitorOperationDifferentFieldsBlocking(TestClass obj1, TestClass obj2)859*795d594fSAndroid Build Coastguard Worker static int $noinline$testMonitorOperationDifferentFieldsBlocking(TestClass obj1, TestClass obj2) { 860*795d594fSAndroid Build Coastguard Worker obj1.i = 1; 861*795d594fSAndroid Build Coastguard Worker obj2.j = 2; 862*795d594fSAndroid Build Coastguard Worker synchronized (classForSync) { 863*795d594fSAndroid Build Coastguard Worker return obj1.i + obj2.j; 864*795d594fSAndroid Build Coastguard Worker } 865*795d594fSAndroid Build Coastguard Worker } 866*795d594fSAndroid Build Coastguard Worker 867*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationRedundantStore(TestClass) load_store_elimination (before) 868*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 869*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 870*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet 871*795d594fSAndroid Build Coastguard Worker 872*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationRedundantStore(TestClass) load_store_elimination (before) 873*795d594fSAndroid Build Coastguard Worker /// CHECK: MonitorOperation kind:enter 874*795d594fSAndroid Build Coastguard Worker /// CHECK: MonitorOperation kind:exit 875*795d594fSAndroid Build Coastguard Worker 876*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationRedundantStore(TestClass) load_store_elimination (after) 877*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 878*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldSet 879*795d594fSAndroid Build Coastguard Worker 880*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationRedundantStore(TestClass) load_store_elimination (after) 881*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldGet 882*795d594fSAndroid Build Coastguard Worker $noinline$testMonitorOperationRedundantStore(TestClass obj)883*795d594fSAndroid Build Coastguard Worker static int $noinline$testMonitorOperationRedundantStore(TestClass obj) { 884*795d594fSAndroid Build Coastguard Worker synchronized (classForSync) { 885*795d594fSAndroid Build Coastguard Worker obj.j = 1; 886*795d594fSAndroid Build Coastguard Worker obj.j = 2; 887*795d594fSAndroid Build Coastguard Worker } 888*795d594fSAndroid Build Coastguard Worker return obj.j; 889*795d594fSAndroid Build Coastguard Worker } 890*795d594fSAndroid Build Coastguard Worker 891*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationRedundantStoreBlocking(TestClass) load_store_elimination (before) 892*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 893*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 894*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet 895*795d594fSAndroid Build Coastguard Worker 896*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationRedundantStoreBlocking(TestClass) load_store_elimination (before) 897*795d594fSAndroid Build Coastguard Worker /// CHECK: MonitorOperation kind:enter 898*795d594fSAndroid Build Coastguard Worker /// CHECK: MonitorOperation kind:exit 899*795d594fSAndroid Build Coastguard Worker 900*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationRedundantStoreBlocking(TestClass) load_store_elimination (after) 901*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 902*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 903*795d594fSAndroid Build Coastguard Worker 904*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationRedundantStoreBlocking(TestClass) load_store_elimination (after) 905*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldGet 906*795d594fSAndroid Build Coastguard Worker $noinline$testMonitorOperationRedundantStoreBlocking(TestClass obj)907*795d594fSAndroid Build Coastguard Worker static int $noinline$testMonitorOperationRedundantStoreBlocking(TestClass obj) { 908*795d594fSAndroid Build Coastguard Worker // This store must be kept due to the monitor operation. 909*795d594fSAndroid Build Coastguard Worker obj.j = 1; 910*795d594fSAndroid Build Coastguard Worker synchronized (classForSync) {} 911*795d594fSAndroid Build Coastguard Worker obj.j = 2; 912*795d594fSAndroid Build Coastguard Worker return obj.j; 913*795d594fSAndroid Build Coastguard Worker } 914*795d594fSAndroid Build Coastguard Worker 915*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationRedundantStoreBlockingOnlyLoad(TestClass) load_store_elimination (before) 916*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 917*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 918*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet 919*795d594fSAndroid Build Coastguard Worker 920*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationRedundantStoreBlockingOnlyLoad(TestClass) load_store_elimination (before) 921*795d594fSAndroid Build Coastguard Worker /// CHECK: MonitorOperation kind:enter 922*795d594fSAndroid Build Coastguard Worker /// CHECK: MonitorOperation kind:exit 923*795d594fSAndroid Build Coastguard Worker 924*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationRedundantStoreBlockingOnlyLoad(TestClass) load_store_elimination (after) 925*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 926*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldSet 927*795d594fSAndroid Build Coastguard Worker 928*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationRedundantStoreBlockingOnlyLoad(TestClass) load_store_elimination (after) 929*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet 930*795d594fSAndroid Build Coastguard Worker $noinline$testMonitorOperationRedundantStoreBlockingOnlyLoad(TestClass obj)931*795d594fSAndroid Build Coastguard Worker static int $noinline$testMonitorOperationRedundantStoreBlockingOnlyLoad(TestClass obj) { 932*795d594fSAndroid Build Coastguard Worker // This store can be safely removed. 933*795d594fSAndroid Build Coastguard Worker obj.j = 1; 934*795d594fSAndroid Build Coastguard Worker obj.j = 2; 935*795d594fSAndroid Build Coastguard Worker synchronized (classForSync) {} 936*795d594fSAndroid Build Coastguard Worker // This load remains due to the monitor operation. 937*795d594fSAndroid Build Coastguard Worker return obj.j; 938*795d594fSAndroid Build Coastguard Worker } 939*795d594fSAndroid Build Coastguard Worker 940*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationRedundantStoreBlockingExit(TestClass) load_store_elimination (before) 941*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 942*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 943*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 944*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet 945*795d594fSAndroid Build Coastguard Worker 946*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationRedundantStoreBlockingExit(TestClass) load_store_elimination (before) 947*795d594fSAndroid Build Coastguard Worker /// CHECK: MonitorOperation kind:enter 948*795d594fSAndroid Build Coastguard Worker /// CHECK: MonitorOperation kind:exit 949*795d594fSAndroid Build Coastguard Worker 950*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationRedundantStoreBlockingExit(TestClass) load_store_elimination (after) 951*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 952*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 953*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldSet 954*795d594fSAndroid Build Coastguard Worker 955*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationRedundantStoreBlockingExit(TestClass) load_store_elimination (after) 956*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldGet 957*795d594fSAndroid Build Coastguard Worker $noinline$testMonitorOperationRedundantStoreBlockingExit(TestClass obj)958*795d594fSAndroid Build Coastguard Worker static int $noinline$testMonitorOperationRedundantStoreBlockingExit(TestClass obj) { 959*795d594fSAndroid Build Coastguard Worker synchronized (classForSync) { 960*795d594fSAndroid Build Coastguard Worker // This store can be removed. 961*795d594fSAndroid Build Coastguard Worker obj.j = 0; 962*795d594fSAndroid Build Coastguard Worker // This store must be kept due to the monitor exit operation. 963*795d594fSAndroid Build Coastguard Worker obj.j = 1; 964*795d594fSAndroid Build Coastguard Worker } 965*795d594fSAndroid Build Coastguard Worker obj.j = 2; 966*795d594fSAndroid Build Coastguard Worker return obj.j; 967*795d594fSAndroid Build Coastguard Worker } 968*795d594fSAndroid Build Coastguard Worker 969*795d594fSAndroid Build Coastguard Worker 970*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationSetAndMergeValues(TestClass, boolean) load_store_elimination (before) 971*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldSet 972*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldSet 973*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldGet 974*795d594fSAndroid Build Coastguard Worker 975*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationSetAndMergeValues(TestClass, boolean) load_store_elimination (after) 976*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldSet 977*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldSet 978*795d594fSAndroid Build Coastguard Worker 979*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationSetAndMergeValues(TestClass, boolean) load_store_elimination (before) 980*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: MonitorOperation kind:enter 981*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: MonitorOperation kind:exit 982*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: MonitorOperation kind:enter 983*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: MonitorOperation kind:exit 984*795d594fSAndroid Build Coastguard Worker 985*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationSetAndMergeValues(TestClass, boolean) load_store_elimination (after) 986*795d594fSAndroid Build Coastguard Worker /// CHECK: Phi 987*795d594fSAndroid Build Coastguard Worker 988*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationSetAndMergeValues(TestClass, boolean) load_store_elimination (after) 989*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldGet 990*795d594fSAndroid Build Coastguard Worker $noinline$testMonitorOperationSetAndMergeValues(TestClass obj, boolean b)991*795d594fSAndroid Build Coastguard Worker static int $noinline$testMonitorOperationSetAndMergeValues(TestClass obj, boolean b) { 992*795d594fSAndroid Build Coastguard Worker if (b) { 993*795d594fSAndroid Build Coastguard Worker synchronized (classForSync) {} 994*795d594fSAndroid Build Coastguard Worker obj.i = 1; 995*795d594fSAndroid Build Coastguard Worker } else { 996*795d594fSAndroid Build Coastguard Worker synchronized (classForSync) {} 997*795d594fSAndroid Build Coastguard Worker obj.i = 2; 998*795d594fSAndroid Build Coastguard Worker } 999*795d594fSAndroid Build Coastguard Worker return obj.i; 1000*795d594fSAndroid Build Coastguard Worker } 1001*795d594fSAndroid Build Coastguard Worker 1002*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationSetAndMergeValuesBlocking(TestClass, boolean) load_store_elimination (before) 1003*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldSet 1004*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldSet 1005*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldGet 1006*795d594fSAndroid Build Coastguard Worker 1007*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationSetAndMergeValuesBlocking(TestClass, boolean) load_store_elimination (after) 1008*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldSet 1009*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldSet 1010*795d594fSAndroid Build Coastguard Worker 1011*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationSetAndMergeValuesBlocking(TestClass, boolean) load_store_elimination (before) 1012*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: MonitorOperation kind:enter 1013*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: MonitorOperation kind:exit 1014*795d594fSAndroid Build Coastguard Worker 1015*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationSetAndMergeValuesBlocking(TestClass, boolean) load_store_elimination (after) 1016*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Phi 1017*795d594fSAndroid Build Coastguard Worker 1018*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationSetAndMergeValuesBlocking(TestClass, boolean) load_store_elimination (after) 1019*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet 1020*795d594fSAndroid Build Coastguard Worker $noinline$testMonitorOperationSetAndMergeValuesBlocking(TestClass obj, boolean b)1021*795d594fSAndroid Build Coastguard Worker static int $noinline$testMonitorOperationSetAndMergeValuesBlocking(TestClass obj, boolean b) { 1022*795d594fSAndroid Build Coastguard Worker if (b) { 1023*795d594fSAndroid Build Coastguard Worker obj.i = 1; 1024*795d594fSAndroid Build Coastguard Worker } else { 1025*795d594fSAndroid Build Coastguard Worker obj.i = 2; 1026*795d594fSAndroid Build Coastguard Worker } 1027*795d594fSAndroid Build Coastguard Worker synchronized (classForSync) {} 1028*795d594fSAndroid Build Coastguard Worker return obj.i; 1029*795d594fSAndroid Build Coastguard Worker } 1030*795d594fSAndroid Build Coastguard Worker 1031*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationDifferentFieldsRemovedSynchronization(TestClass, TestClass) load_store_elimination (before) 1032*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 1033*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 1034*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet 1035*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet 1036*795d594fSAndroid Build Coastguard Worker 1037*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationDifferentFieldsRemovedSynchronization(TestClass, TestClass) load_store_elimination (before) 1038*795d594fSAndroid Build Coastguard Worker /// CHECK: MonitorOperation kind:enter 1039*795d594fSAndroid Build Coastguard Worker /// CHECK: MonitorOperation kind:exit 1040*795d594fSAndroid Build Coastguard Worker 1041*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationDifferentFieldsRemovedSynchronization(TestClass, TestClass) load_store_elimination (after) 1042*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: MonitorOperation 1043*795d594fSAndroid Build Coastguard Worker 1044*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationDifferentFieldsRemovedSynchronization(TestClass, TestClass) load_store_elimination (after) 1045*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 1046*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 1047*795d594fSAndroid Build Coastguard Worker 1048*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationDifferentFieldsRemovedSynchronization(TestClass, TestClass) load_store_elimination (after) 1049*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldGet 1050*795d594fSAndroid Build Coastguard Worker $noinline$testMonitorOperationDifferentFieldsRemovedSynchronization( TestClass obj1, TestClass obj2)1051*795d594fSAndroid Build Coastguard Worker static int $noinline$testMonitorOperationDifferentFieldsRemovedSynchronization( 1052*795d594fSAndroid Build Coastguard Worker TestClass obj1, TestClass obj2) { 1053*795d594fSAndroid Build Coastguard Worker Main m = new Main(); 1054*795d594fSAndroid Build Coastguard Worker 1055*795d594fSAndroid Build Coastguard Worker obj1.i = 1; 1056*795d594fSAndroid Build Coastguard Worker obj2.j = 2; 1057*795d594fSAndroid Build Coastguard Worker synchronized (m) {} 1058*795d594fSAndroid Build Coastguard Worker 1059*795d594fSAndroid Build Coastguard Worker return obj1.i + obj2.j; 1060*795d594fSAndroid Build Coastguard Worker } 1061*795d594fSAndroid Build Coastguard Worker 1062*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationRedundantStoreRemovedSynchronization(TestClass) load_store_elimination (before) 1063*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 1064*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 1065*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldGet 1066*795d594fSAndroid Build Coastguard Worker 1067*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationRedundantStoreRemovedSynchronization(TestClass) load_store_elimination (before) 1068*795d594fSAndroid Build Coastguard Worker /// CHECK: MonitorOperation kind:enter 1069*795d594fSAndroid Build Coastguard Worker /// CHECK: MonitorOperation kind:exit 1070*795d594fSAndroid Build Coastguard Worker /// CHECK: MonitorOperation kind:enter 1071*795d594fSAndroid Build Coastguard Worker /// CHECK: MonitorOperation kind:exit 1072*795d594fSAndroid Build Coastguard Worker 1073*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationRedundantStoreRemovedSynchronization(TestClass) load_store_elimination (after) 1074*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: MonitorOperation 1075*795d594fSAndroid Build Coastguard Worker 1076*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationRedundantStoreRemovedSynchronization(TestClass) load_store_elimination (after) 1077*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 1078*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldSet 1079*795d594fSAndroid Build Coastguard Worker 1080*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationRedundantStoreRemovedSynchronization(TestClass) load_store_elimination (after) 1081*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldGet $noinline$testMonitorOperationRedundantStoreRemovedSynchronization(TestClass obj)1082*795d594fSAndroid Build Coastguard Worker static int $noinline$testMonitorOperationRedundantStoreRemovedSynchronization(TestClass obj) { 1083*795d594fSAndroid Build Coastguard Worker Main m = new Main(); 1084*795d594fSAndroid Build Coastguard Worker 1085*795d594fSAndroid Build Coastguard Worker obj.j = 1; 1086*795d594fSAndroid Build Coastguard Worker synchronized (m) {} 1087*795d594fSAndroid Build Coastguard Worker obj.j = 2; 1088*795d594fSAndroid Build Coastguard Worker synchronized (m) {} 1089*795d594fSAndroid Build Coastguard Worker 1090*795d594fSAndroid Build Coastguard Worker return obj.j; 1091*795d594fSAndroid Build Coastguard Worker } 1092*795d594fSAndroid Build Coastguard Worker 1093*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationSetAndMergeValuesRemovedSynchronization(TestClass, boolean) load_store_elimination (before) 1094*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldSet 1095*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldSet 1096*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldGet 1097*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return 1098*795d594fSAndroid Build Coastguard Worker 1099*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationSetAndMergeValuesRemovedSynchronization(TestClass, boolean) load_store_elimination (after) 1100*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldSet 1101*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: InstanceFieldSet 1102*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return 1103*795d594fSAndroid Build Coastguard Worker 1104*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationSetAndMergeValuesRemovedSynchronization(TestClass, boolean) load_store_elimination (before) 1105*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: MonitorOperation kind:enter 1106*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: MonitorOperation kind:exit 1107*795d594fSAndroid Build Coastguard Worker 1108*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationSetAndMergeValuesRemovedSynchronization(TestClass, boolean) load_store_elimination (after) 1109*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: MonitorOperation 1110*795d594fSAndroid Build Coastguard Worker 1111*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationSetAndMergeValuesRemovedSynchronization(TestClass, boolean) load_store_elimination (after) 1112*795d594fSAndroid Build Coastguard Worker /// CHECK: Phi 1113*795d594fSAndroid Build Coastguard Worker 1114*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationSetAndMergeValuesRemovedSynchronization(TestClass, boolean) load_store_elimination (after) 1115*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldGet $noinline$testMonitorOperationSetAndMergeValuesRemovedSynchronization( TestClass obj, boolean b)1116*795d594fSAndroid Build Coastguard Worker static int $noinline$testMonitorOperationSetAndMergeValuesRemovedSynchronization( 1117*795d594fSAndroid Build Coastguard Worker TestClass obj, boolean b) { 1118*795d594fSAndroid Build Coastguard Worker Main m = new Main(); 1119*795d594fSAndroid Build Coastguard Worker 1120*795d594fSAndroid Build Coastguard Worker if (b) { 1121*795d594fSAndroid Build Coastguard Worker obj.i = 1; 1122*795d594fSAndroid Build Coastguard Worker } else { 1123*795d594fSAndroid Build Coastguard Worker obj.i = 2; 1124*795d594fSAndroid Build Coastguard Worker } 1125*795d594fSAndroid Build Coastguard Worker synchronized (m) {} 1126*795d594fSAndroid Build Coastguard Worker return obj.i; 1127*795d594fSAndroid Build Coastguard Worker } 1128*795d594fSAndroid Build Coastguard Worker $inline$synchronizedSetter(TestClass obj)1129*795d594fSAndroid Build Coastguard Worker synchronized int $inline$synchronizedSetter(TestClass obj) { 1130*795d594fSAndroid Build Coastguard Worker obj.j = 1; 1131*795d594fSAndroid Build Coastguard Worker obj.j = 2; 1132*795d594fSAndroid Build Coastguard Worker return obj.j; 1133*795d594fSAndroid Build Coastguard Worker } 1134*795d594fSAndroid Build Coastguard Worker 1135*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationInlineSynchronizedMethod(TestClass) inliner (before) 1136*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: MonitorOperation 1137*795d594fSAndroid Build Coastguard Worker 1138*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationInlineSynchronizedMethod(TestClass) inliner (after) 1139*795d594fSAndroid Build Coastguard Worker /// CHECK: MonitorOperation kind:enter 1140*795d594fSAndroid Build Coastguard Worker /// CHECK: MonitorOperation kind:exit 1141*795d594fSAndroid Build Coastguard Worker 1142*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationInlineSynchronizedMethod(TestClass) load_store_elimination (before) 1143*795d594fSAndroid Build Coastguard Worker /// CHECK: MonitorOperation kind:enter 1144*795d594fSAndroid Build Coastguard Worker /// CHECK: MonitorOperation kind:exit 1145*795d594fSAndroid Build Coastguard Worker 1146*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationInlineSynchronizedMethod(TestClass) load_store_elimination (before) 1147*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 1148*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 1149*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldSet 1150*795d594fSAndroid Build Coastguard Worker 1151*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationInlineSynchronizedMethod(TestClass) load_store_elimination (after) 1152*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: MonitorOperation 1153*795d594fSAndroid Build Coastguard Worker 1154*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationInlineSynchronizedMethod(TestClass) load_store_elimination (after) 1155*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 1156*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldSet $noinline$testMonitorOperationInlineSynchronizedMethod(TestClass obj)1157*795d594fSAndroid Build Coastguard Worker static int $noinline$testMonitorOperationInlineSynchronizedMethod(TestClass obj) { 1158*795d594fSAndroid Build Coastguard Worker Main m = new Main(); 1159*795d594fSAndroid Build Coastguard Worker return m.$inline$synchronizedSetter(obj); 1160*795d594fSAndroid Build Coastguard Worker } 1161*795d594fSAndroid Build Coastguard Worker $inline$SetterWithSynchronizedScope(TestClass obj)1162*795d594fSAndroid Build Coastguard Worker int $inline$SetterWithSynchronizedScope(TestClass obj) { 1163*795d594fSAndroid Build Coastguard Worker synchronized (this) { 1164*795d594fSAndroid Build Coastguard Worker obj.j = 1; 1165*795d594fSAndroid Build Coastguard Worker obj.j = 2; 1166*795d594fSAndroid Build Coastguard Worker return obj.j; 1167*795d594fSAndroid Build Coastguard Worker } 1168*795d594fSAndroid Build Coastguard Worker } 1169*795d594fSAndroid Build Coastguard Worker 1170*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationInlineMethodWithSynchronizedScope(TestClass) inliner (before) 1171*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: MonitorOperation 1172*795d594fSAndroid Build Coastguard Worker 1173*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationInlineMethodWithSynchronizedScope(TestClass) inliner (after) 1174*795d594fSAndroid Build Coastguard Worker /// CHECK: MonitorOperation kind:enter 1175*795d594fSAndroid Build Coastguard Worker /// CHECK: MonitorOperation kind:exit 1176*795d594fSAndroid Build Coastguard Worker 1177*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationInlineMethodWithSynchronizedScope(TestClass) load_store_elimination (before) 1178*795d594fSAndroid Build Coastguard Worker /// CHECK: MonitorOperation kind:enter 1179*795d594fSAndroid Build Coastguard Worker /// CHECK: MonitorOperation kind:exit 1180*795d594fSAndroid Build Coastguard Worker 1181*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationInlineMethodWithSynchronizedScope(TestClass) load_store_elimination (before) 1182*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 1183*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 1184*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldSet 1185*795d594fSAndroid Build Coastguard Worker 1186*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationInlineMethodWithSynchronizedScope(TestClass) load_store_elimination (after) 1187*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: MonitorOperation 1188*795d594fSAndroid Build Coastguard Worker 1189*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testMonitorOperationInlineMethodWithSynchronizedScope(TestClass) load_store_elimination (after) 1190*795d594fSAndroid Build Coastguard Worker /// CHECK: InstanceFieldSet 1191*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InstanceFieldSet $noinline$testMonitorOperationInlineMethodWithSynchronizedScope(TestClass obj)1192*795d594fSAndroid Build Coastguard Worker static int $noinline$testMonitorOperationInlineMethodWithSynchronizedScope(TestClass obj) { 1193*795d594fSAndroid Build Coastguard Worker Main m = new Main(); 1194*795d594fSAndroid Build Coastguard Worker return m.$inline$SetterWithSynchronizedScope(obj); 1195*795d594fSAndroid Build Coastguard Worker } 1196*795d594fSAndroid Build Coastguard Worker 1197*795d594fSAndroid Build Coastguard Worker static TestClass classForSync; 1198*795d594fSAndroid Build Coastguard Worker volatile int vi; 1199*795d594fSAndroid Build Coastguard Worker } 1200