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