1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
2 ; RUN: llc -mtriple=aarch64-apple-darwin < %s -o - | FileCheck %s
4 @.str = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1
6 ; Check we use the GOT to reference ___stack_chk_guard on Darwin
8 define void @test(ptr %a) #0 {
10 ; CHECK: ; %bb.0: ; %entry
11 ; CHECK-NEXT: sub sp, sp, #80
12 ; CHECK-NEXT: stp x20, x19, [sp, #48] ; 16-byte Folded Spill
13 ; CHECK-NEXT: stp x29, x30, [sp, #64] ; 16-byte Folded Spill
14 ; CHECK-NEXT: .cfi_def_cfa_offset 80
15 ; CHECK-NEXT: .cfi_offset w30, -8
16 ; CHECK-NEXT: .cfi_offset w29, -16
17 ; CHECK-NEXT: .cfi_offset w19, -24
18 ; CHECK-NEXT: .cfi_offset w20, -32
20 ; CHECK-NEXT: adrp x8, ___stack_chk_guard@GOTPAGE
21 ; CHECK-NEXT: mov x1, x0
22 ; CHECK-NEXT: add x19, sp, #16
24 ; CHECK-NEXT: ldr x8, [x8, ___stack_chk_guard@GOTPAGEOFF]
26 ; CHECK-NEXT: ldr x8, [x8]
27 ; CHECK-NEXT: str x8, [sp, #40]
28 ; CHECK-NEXT: str x0, [sp, #8]
29 ; CHECK-NEXT: add x0, sp, #16
30 ; CHECK-NEXT: bl _strcpy
32 ; CHECK-NEXT: adrp x0, l_.str@PAGE
34 ; CHECK-NEXT: add x0, x0, l_.str@PAGEOFF
35 ; CHECK-NEXT: str x19, [sp]
36 ; CHECK-NEXT: bl _printf
38 ; CHECK-NEXT: adrp x8, ___stack_chk_guard@GOTPAGE
40 ; CHECK-NEXT: ldr x8, [x8, ___stack_chk_guard@GOTPAGEOFF]
41 ; CHECK-NEXT: ldr x9, [sp, #40]
43 ; CHECK-NEXT: ldr x8, [x8]
44 ; CHECK-NEXT: cmp x8, x9
45 ; CHECK-NEXT: b.ne LBB0_2
46 ; CHECK-NEXT: ; %bb.1: ; %entry
47 ; CHECK-NEXT: ldp x29, x30, [sp, #64] ; 16-byte Folded Reload
48 ; CHECK-NEXT: ldp x20, x19, [sp, #48] ; 16-byte Folded Reload
49 ; CHECK-NEXT: add sp, sp, #80
51 ; CHECK-NEXT: LBB0_2: ; %entry
52 ; CHECK-NEXT: bl ___stack_chk_fail
53 ; CHECK-NEXT: .loh AdrpLdrGotLdr Lloh5, Lloh6, Lloh7
54 ; CHECK-NEXT: .loh AdrpAdd Lloh3, Lloh4
55 ; CHECK-NEXT: .loh AdrpLdrGotLdr Lloh0, Lloh1, Lloh2
57 %a.addr = alloca ptr, align 8
58 %buf = alloca [16 x i8], align 16
59 store ptr %a, ptr %a.addr, align 8
60 %0 = load ptr, ptr %a.addr, align 8
61 %call = call ptr @strcpy(ptr %buf, ptr %0)
62 %call2 = call i32 (ptr, ...) @printf(ptr @.str, ptr %buf)
66 declare ptr @strcpy(ptr, ptr)
67 declare i32 @printf(ptr, ...)
69 attributes #0 = { ssp }