Francis Visoiu Mistrih | 39fc284 | 2019-07-17 20:46:16 +0000 | [diff] [blame] | 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. |
Sander de Smalen | f28e112 | 2019-08-16 15:42:28 +0000 | [diff] [blame] | 12 | ; CHECK: stur [[GUARD]], [x29, #-8] |
Francis Visoiu Mistrih | 39fc284 | 2019-07-17 20:46:16 +0000 | [diff] [blame] | 13 | define void @test(i8* %i, ...) #0 { |
| 14 | entry: |
| 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 | |
| 33 | declare void @llvm.lifetime.start(i64, i8* nocapture) |
| 34 | declare void @llvm.va_start(i8*) |
| 35 | declare void @baz(i8*, %struct.__va_list*) |
| 36 | declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture readonly, i64, i32, i1) |
| 37 | declare void @bar(i8*) |
| 38 | declare void @llvm.va_end(i8*) |
| 39 | declare void @llvm.lifetime.end(i64, i8* nocapture) |
| 40 | |
| 41 | attributes #0 = { noinline nounwind optnone ssp } |