1*9880d681SAndroid Build Coastguard Worker; RUN: llc -filetype=asm -mtriple=mipsel-none-linux -relocation-model=static \ 2*9880d681SAndroid Build Coastguard Worker; RUN: -O3 < %s | FileCheck %s 3*9880d681SAndroid Build Coastguard Worker 4*9880d681SAndroid Build Coastguard Worker; RUN: llc -filetype=asm -mtriple=mipsel-none-nacl -relocation-model=static \ 5*9880d681SAndroid Build Coastguard Worker; RUN: -O3 < %s | FileCheck %s -check-prefix=CHECK-NACL 6*9880d681SAndroid Build Coastguard Worker 7*9880d681SAndroid Build Coastguard Worker@x = global i32 0, align 4 8*9880d681SAndroid Build Coastguard Workerdeclare void @f1(i32) 9*9880d681SAndroid Build Coastguard Workerdeclare void @f2() 10*9880d681SAndroid Build Coastguard Worker 11*9880d681SAndroid Build Coastguard Worker 12*9880d681SAndroid Build Coastguard Workerdefine void @test1() { 13*9880d681SAndroid Build Coastguard Worker %1 = load i32, i32* @x, align 4 14*9880d681SAndroid Build Coastguard Worker call void @f1(i32 %1) 15*9880d681SAndroid Build Coastguard Worker ret void 16*9880d681SAndroid Build Coastguard Worker 17*9880d681SAndroid Build Coastguard Worker 18*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test1 19*9880d681SAndroid Build Coastguard Worker 20*9880d681SAndroid Build Coastguard Worker; We first make sure that for non-NaCl targets branch-delay slot contains 21*9880d681SAndroid Build Coastguard Worker; dangerous instructions. 22*9880d681SAndroid Build Coastguard Worker 23*9880d681SAndroid Build Coastguard Worker; Check that branch-delay slot is used to load argument from x before function 24*9880d681SAndroid Build Coastguard Worker; call. 25*9880d681SAndroid Build Coastguard Worker 26*9880d681SAndroid Build Coastguard Worker; CHECK: jal 27*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: lw $4, %lo(x)(${{[0-9]+}}) 28*9880d681SAndroid Build Coastguard Worker 29*9880d681SAndroid Build Coastguard Worker; Check that branch-delay slot is used for adjusting sp before return. 30*9880d681SAndroid Build Coastguard Worker 31*9880d681SAndroid Build Coastguard Worker; CHECK: jr $ra 32*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: addiu $sp, $sp, {{[0-9]+}} 33*9880d681SAndroid Build Coastguard Worker 34*9880d681SAndroid Build Coastguard Worker 35*9880d681SAndroid Build Coastguard Worker; For NaCl, check that branch-delay slot doesn't contain dangerous instructions. 36*9880d681SAndroid Build Coastguard Worker 37*9880d681SAndroid Build Coastguard Worker; CHECK-NACL: jal 38*9880d681SAndroid Build Coastguard Worker; CHECK-NACL-NEXT: nop 39*9880d681SAndroid Build Coastguard Worker 40*9880d681SAndroid Build Coastguard Worker; CHECK-NACL: jr $ra 41*9880d681SAndroid Build Coastguard Worker; CHECK-NACL-NEXT: nop 42*9880d681SAndroid Build Coastguard Worker} 43*9880d681SAndroid Build Coastguard Worker 44*9880d681SAndroid Build Coastguard Worker 45*9880d681SAndroid Build Coastguard Workerdefine void @test2() { 46*9880d681SAndroid Build Coastguard Worker store i32 1, i32* @x, align 4 47*9880d681SAndroid Build Coastguard Worker tail call void @f2() 48*9880d681SAndroid Build Coastguard Worker ret void 49*9880d681SAndroid Build Coastguard Worker 50*9880d681SAndroid Build Coastguard Worker 51*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test2 52*9880d681SAndroid Build Coastguard Worker 53*9880d681SAndroid Build Coastguard Worker; Check that branch-delay slot is used for storing to x before function call. 54*9880d681SAndroid Build Coastguard Worker 55*9880d681SAndroid Build Coastguard Worker; CHECK: jal 56*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: sw ${{[0-9]+}}, %lo(x)(${{[0-9]+}}) 57*9880d681SAndroid Build Coastguard Worker 58*9880d681SAndroid Build Coastguard Worker; Check that branch-delay slot is used for adjusting sp before return. 59*9880d681SAndroid Build Coastguard Worker 60*9880d681SAndroid Build Coastguard Worker; CHECK: jr $ra 61*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: addiu $sp, $sp, {{[0-9]+}} 62*9880d681SAndroid Build Coastguard Worker 63*9880d681SAndroid Build Coastguard Worker 64*9880d681SAndroid Build Coastguard Worker; For NaCl, check that branch-delay slot doesn't contain dangerous instructions. 65*9880d681SAndroid Build Coastguard Worker 66*9880d681SAndroid Build Coastguard Worker; CHECK-NACL: jal 67*9880d681SAndroid Build Coastguard Worker; CHECK-NACL-NEXT: nop 68*9880d681SAndroid Build Coastguard Worker 69*9880d681SAndroid Build Coastguard Worker; CHECK-NACL: jr $ra 70*9880d681SAndroid Build Coastguard Worker; CHECK-NACL-NEXT: nop 71*9880d681SAndroid Build Coastguard Worker} 72