1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -mtriple=arm64-apple-ios -relocation-model=pic -disable-fp-elim | FileCheck %s 2*9880d681SAndroid Build Coastguard Worker 3*9880d681SAndroid Build Coastguard Worker@__stack_chk_guard = external global i64* 4*9880d681SAndroid Build Coastguard Worker 5*9880d681SAndroid Build Coastguard Worker; PR20558 6*9880d681SAndroid Build Coastguard Worker 7*9880d681SAndroid Build Coastguard Worker; CHECK: adrp [[R0:x[0-9]+]], ___stack_chk_guard@GOTPAGE 8*9880d681SAndroid Build Coastguard Worker; CHECK: ldr [[R1:x[0-9]+]], {{\[}}[[R0]], ___stack_chk_guard@GOTPAGEOFF{{\]}} 9*9880d681SAndroid Build Coastguard Worker; Load the stack guard for the second time, just in case the previous value gets spilled. 10*9880d681SAndroid Build Coastguard Worker; CHECK: adrp [[GUARD_PAGE:x[0-9]+]], ___stack_chk_guard@GOTPAGE 11*9880d681SAndroid Build Coastguard Worker; CHECK: ldr [[R2:x[0-9]+]], {{\[}}[[R1]]{{\]}} 12*9880d681SAndroid Build Coastguard Worker; CHECK: stur [[R2]], {{\[}}x29, [[SLOT0:[0-9#\-]+]]{{\]}} 13*9880d681SAndroid Build Coastguard Worker; CHECK: ldur [[R3:x[0-9]+]], {{\[}}x29, [[SLOT0]]{{\]}} 14*9880d681SAndroid Build Coastguard Worker; CHECK: ldr [[GUARD_ADDR:x[0-9]+]], {{\[}}[[GUARD_PAGE]], ___stack_chk_guard@GOTPAGEOFF{{\]}} 15*9880d681SAndroid Build Coastguard Worker; CHECK: ldr [[GUARD:x[0-9]+]], {{\[}}[[GUARD_ADDR]]{{\]}} 16*9880d681SAndroid Build Coastguard Worker; CHECK: sub [[R4:x[0-9]+]], [[GUARD]], [[R3]] 17*9880d681SAndroid Build Coastguard Worker; CHECK: cbnz [[R4]], LBB 18*9880d681SAndroid Build Coastguard Worker 19*9880d681SAndroid Build Coastguard Workerdefine i32 @test_stack_guard_remat2() { 20*9880d681SAndroid Build Coastguard Workerentry: 21*9880d681SAndroid Build Coastguard Worker %StackGuardSlot = alloca i8* 22*9880d681SAndroid Build Coastguard Worker %StackGuard = load i8*, i8** bitcast (i64** @__stack_chk_guard to i8**) 23*9880d681SAndroid Build Coastguard Worker call void @llvm.stackprotector(i8* %StackGuard, i8** %StackGuardSlot) 24*9880d681SAndroid Build Coastguard Worker %container = alloca [32 x i8], align 1 25*9880d681SAndroid Build Coastguard Worker call void @llvm.stackprotectorcheck(i8** bitcast (i64** @__stack_chk_guard to i8**)) 26*9880d681SAndroid Build Coastguard Worker ret i32 -1 27*9880d681SAndroid Build Coastguard Worker} 28*9880d681SAndroid Build Coastguard Worker 29*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.stackprotector(i8*, i8**) 30*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.stackprotectorcheck(i8**) 31