1*9880d681SAndroid Build Coastguard Worker; RUN: opt -S -dse < %s | FileCheck %s 2*9880d681SAndroid Build Coastguard Worker 3*9880d681SAndroid Build Coastguard Workerdeclare void @f() 4*9880d681SAndroid Build Coastguard Workerdeclare noalias i8* @malloc(i32) nounwind 5*9880d681SAndroid Build Coastguard Worker 6*9880d681SAndroid Build Coastguard Workerdefine void @test_0() { 7*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @test_0( 8*9880d681SAndroid Build Coastguard Worker %m = call i8* @malloc(i32 24) 9*9880d681SAndroid Build Coastguard Worker tail call void @f() [ "unknown"(i8* %m) ] 10*9880d681SAndroid Build Coastguard Worker; CHECK: store i8 -19, i8* %m 11*9880d681SAndroid Build Coastguard Worker store i8 -19, i8* %m 12*9880d681SAndroid Build Coastguard Worker ret void 13*9880d681SAndroid Build Coastguard Worker} 14*9880d681SAndroid Build Coastguard Worker 15*9880d681SAndroid Build Coastguard Workerdefine i8* @test_1() { 16*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @test_1( 17*9880d681SAndroid Build Coastguard Worker %m = call i8* @malloc(i32 24) 18*9880d681SAndroid Build Coastguard Worker tail call void @f() [ "unknown"(i8* %m) ] 19*9880d681SAndroid Build Coastguard Worker store i8 -19, i8* %m 20*9880d681SAndroid Build Coastguard Worker tail call void @f() 21*9880d681SAndroid Build Coastguard Worker store i8 101, i8* %m 22*9880d681SAndroid Build Coastguard Worker 23*9880d681SAndroid Build Coastguard Worker; CHECK: tail call void @f() [ "unknown"(i8* %m) ] 24*9880d681SAndroid Build Coastguard Worker; CHECK: store i8 -19, i8* %m 25*9880d681SAndroid Build Coastguard Worker; CHECK: tail call void @f() 26*9880d681SAndroid Build Coastguard Worker; CHECK: store i8 101, i8* %m 27*9880d681SAndroid Build Coastguard Worker 28*9880d681SAndroid Build Coastguard Worker ret i8* %m 29*9880d681SAndroid Build Coastguard Worker} 30*9880d681SAndroid Build Coastguard Worker 31*9880d681SAndroid Build Coastguard Workerdefine void @test_2() { 32*9880d681SAndroid Build Coastguard Worker; Since the deopt operand bundle does not escape %m (see caveat below), it is 33*9880d681SAndroid Build Coastguard Worker; legal to elide the final store that location. 34*9880d681SAndroid Build Coastguard Worker 35*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @test_2( 36*9880d681SAndroid Build Coastguard Worker %m = call i8* @malloc(i32 24) 37*9880d681SAndroid Build Coastguard Worker tail call void @f() [ "deopt"(i8* %m) ] 38*9880d681SAndroid Build Coastguard Worker store i8 -19, i8* %m 39*9880d681SAndroid Build Coastguard Worker ret void 40*9880d681SAndroid Build Coastguard Worker 41*9880d681SAndroid Build Coastguard Worker; CHECK: tail call void @f() [ "deopt"(i8* %m) ] 42*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT ret void 43*9880d681SAndroid Build Coastguard Worker} 44*9880d681SAndroid Build Coastguard Worker 45*9880d681SAndroid Build Coastguard Workerdefine i8* @test_3() { 46*9880d681SAndroid Build Coastguard Worker; Since the deopt operand bundle does not escape %m (see caveat below), @f 47*9880d681SAndroid Build Coastguard Worker; cannot observe the stores to %m 48*9880d681SAndroid Build Coastguard Worker 49*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @test_3( 50*9880d681SAndroid Build Coastguard Worker %m = call i8* @malloc(i32 24) 51*9880d681SAndroid Build Coastguard Worker tail call void @f() [ "deopt"(i8* %m) ] 52*9880d681SAndroid Build Coastguard Worker store i8 -19, i8* %m 53*9880d681SAndroid Build Coastguard Worker tail call void @f() 54*9880d681SAndroid Build Coastguard Worker store i8 101, i8* %m 55*9880d681SAndroid Build Coastguard Worker ret i8* %m 56*9880d681SAndroid Build Coastguard Worker} 57*9880d681SAndroid Build Coastguard Worker 58*9880d681SAndroid Build Coastguard Worker 59*9880d681SAndroid Build Coastguard Worker; Caveat: technically, %m can only escape if the calling function is deoptimized 60*9880d681SAndroid Build Coastguard Worker; at the call site (i.e. the call returns to the "deopt" continuation). Since 61*9880d681SAndroid Build Coastguard Worker; the calling function body will be invalidated in that case, the calling 62*9880d681SAndroid Build Coastguard Worker; function can be optimized under the assumption that %m does not escape. 63