| 1 |
; Regression test for safestack layout. Used to fail with asan. |
| 2 |
; RUN: opt -safe-stack -S -mtriple=x86_64-pc-linux-gnu < %s -o - | FileCheck %s |
| 3 |
; RUN: opt -passes=safe-stack -S -mtriple=x86_64-pc-linux-gnu < %s -o - | FileCheck %s |
| 4 |
|
| 5 |
define void @f() safestack { |
| 6 |
; CHECK-LABEL: define void @f |
| 7 |
entry: |
| 8 |
; CHECK: %[[USP:.*]] = load ptr, ptr @__safestack_unsafe_stack_ptr |
| 9 |
; CHECK: getelementptr i8, ptr %[[USP]], i32 -224 |
| 10 |
|
| 11 |
%x0 = alloca i8, align 16 |
| 12 |
%x1 = alloca i8, align 16 |
| 13 |
%x2 = alloca i8, align 16 |
| 14 |
%x3 = alloca i8, align 16 |
| 15 |
%x4 = alloca i8, align 16 |
| 16 |
%x5 = alloca i8, align 16 |
| 17 |
%x6 = alloca i8, align 16 |
| 18 |
%x7 = alloca i8, align 16 |
| 19 |
%x8 = alloca i8, align 16 |
| 20 |
%x9 = alloca i8, align 16 |
| 21 |
%x10 = alloca i8, align 16 |
| 22 |
%x11 = alloca i8, align 16 |
| 23 |
%x12 = alloca i8, align 16 |
| 24 |
%x13 = alloca i8, align 16 |
| 25 |
%y0 = alloca i8, align 2 |
| 26 |
%y1 = alloca i8, align 2 |
| 27 |
%y2 = alloca i8, align 2 |
| 28 |
%y3 = alloca i8, align 2 |
| 29 |
%y4 = alloca i8, align 2 |
| 30 |
%y5 = alloca i8, align 2 |
| 31 |
%y6 = alloca i8, align 2 |
| 32 |
%y7 = alloca i8, align 2 |
| 33 |
%y8 = alloca i8, align 2 |
| 34 |
|
| 35 |
; CHECK: getelementptr i8, ptr %[[USP]], i32 -16 |
| 36 |
call void @capture8(ptr %x0) |
| 37 |
; CHECK: getelementptr i8, ptr %[[USP]], i32 -32 |
| 38 |
call void @capture8(ptr %x1) |
| 39 |
; CHECK: getelementptr i8, ptr %[[USP]], i32 -48 |
| 40 |
call void @capture8(ptr %x2) |
| 41 |
; CHECK: getelementptr i8, ptr %[[USP]], i32 -64 |
| 42 |
call void @capture8(ptr %x3) |
| 43 |
; CHECK: getelementptr i8, ptr %[[USP]], i32 -80 |
| 44 |
call void @capture8(ptr %x4) |
| 45 |
; CHECK: getelementptr i8, ptr %[[USP]], i32 -96 |
| 46 |
call void @capture8(ptr %x5) |
| 47 |
; CHECK: getelementptr i8, ptr %[[USP]], i32 -112 |
| 48 |
call void @capture8(ptr %x6) |
| 49 |
; CHECK: getelementptr i8, ptr %[[USP]], i32 -128 |
| 50 |
call void @capture8(ptr %x7) |
| 51 |
; CHECK: getelementptr i8, ptr %[[USP]], i32 -144 |
| 52 |
call void @capture8(ptr %x8) |
| 53 |
; CHECK: getelementptr i8, ptr %[[USP]], i32 -160 |
| 54 |
call void @capture8(ptr %x9) |
| 55 |
; CHECK: getelementptr i8, ptr %[[USP]], i32 -176 |
| 56 |
call void @capture8(ptr %x10) |
| 57 |
; CHECK: getelementptr i8, ptr %[[USP]], i32 -192 |
| 58 |
call void @capture8(ptr %x11) |
| 59 |
; CHECK: getelementptr i8, ptr %[[USP]], i32 -208 |
| 60 |
call void @capture8(ptr %x12) |
| 61 |
; CHECK: getelementptr i8, ptr %[[USP]], i32 -224 |
| 62 |
call void @capture8(ptr %x13) |
| 63 |
; CHECK: getelementptr i8, ptr %[[USP]], i32 -2 |
| 64 |
call void @capture8(ptr %y0) |
| 65 |
; CHECK: getelementptr i8, ptr %[[USP]], i32 -4 |
| 66 |
call void @capture8(ptr %y1) |
| 67 |
; CHECK: getelementptr i8, ptr %[[USP]], i32 -6 |
| 68 |
call void @capture8(ptr %y2) |
| 69 |
; CHECK: getelementptr i8, ptr %[[USP]], i32 -8 |
| 70 |
call void @capture8(ptr %y3) |
| 71 |
; CHECK: getelementptr i8, ptr %[[USP]], i32 -10 |
| 72 |
call void @capture8(ptr %y4) |
| 73 |
; CHECK: getelementptr i8, ptr %[[USP]], i32 -12 |
| 74 |
call void @capture8(ptr %y5) |
| 75 |
; CHECK: getelementptr i8, ptr %[[USP]], i32 -14 |
| 76 |
call void @capture8(ptr %y6) |
| 77 |
; CHECK: getelementptr i8, ptr %[[USP]], i32 -18 |
| 78 |
call void @capture8(ptr %y7) |
| 79 |
; CHECK: getelementptr i8, ptr %[[USP]], i32 -20 |
| 80 |
call void @capture8(ptr %y8) |
| 81 |
|
| 82 |
ret void |
| 83 |
} |
| 84 |
|
| 85 |
declare void @capture8(ptr) |