1; RUN: llc --frame-pointer=all -mtriple=aarch64-- < %s | FileCheck %s
2
3; PR25610: -fstack-protector places the canary in the wrong place on arm64 with
4;          va_args
5
6%struct.__va_list = type { i8*, i8*, i8*, i32, i32 }
7
8; CHECK-LABEL: test
9; CHECK: ldr [[GUARD:x[0-9]+]]{{.*}}:lo12:__stack_chk_guard]
10; Make sure the canary is placed relative to the frame pointer, not
11; the stack pointer.
12; CHECK: stur [[GUARD]], [x29, #-8]
13define void @test(i8* %i, ...) #0 {
14entry:
15  %buf = alloca [10 x i8], align 1
16  %ap = alloca %struct.__va_list, align 8
17  %tmp = alloca %struct.__va_list, align 8
18  %0 = getelementptr inbounds [10 x i8], [10 x i8]* %buf, i64 0, i64 0
19  call void @llvm.lifetime.start(i64 10, i8* %0)
20  %1 = bitcast %struct.__va_list* %ap to i8*
21  call void @llvm.lifetime.start(i64 32, i8* %1)
22  call void @llvm.va_start(i8* %1)
23  %2 = bitcast %struct.__va_list* %tmp to i8*
24  call void @llvm.memcpy.p0i8.p0i8.i64(i8* %2, i8* %1, i64 32, i32 8, i1 false)
25  call void @baz(i8* %i, %struct.__va_list* nonnull %tmp)
26  call void @bar(i8* %0)
27  call void @llvm.va_end(i8* %1)
28  call void @llvm.lifetime.end(i64 32, i8* %1)
29  call void @llvm.lifetime.end(i64 10, i8* %0)
30  ret void
31}
32
33declare void @llvm.lifetime.start(i64, i8* nocapture)
34declare void @llvm.va_start(i8*)
35declare void @baz(i8*, %struct.__va_list*)
36declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture readonly, i64, i32, i1)
37declare void @bar(i8*)
38declare void @llvm.va_end(i8*)
39declare void @llvm.lifetime.end(i64, i8* nocapture)
40
41attributes #0 = { noinline nounwind optnone ssp }
42