Kostya Serebryany | 4fb7801 | 2013-12-06 09:00:17 +0000 | [diff] [blame] | 1 | ; Test the ASan's stack layout. |
| 2 | ; More tests in tests/Transforms/Utils/ASanStackFrameLayoutTest.cpp |
Alexey Samsonov | 4b7f413 | 2014-12-11 21:53:03 +0000 | [diff] [blame^] | 3 | ; RUN: opt < %s -asan -asan-module -asan-stack-dynamic-alloca=0 -S \ |
| 4 | ; RUN: | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-STATIC |
| 5 | ; RUN: opt < %s -asan -asan-module -asan-stack-dynamic-alloca=1 -S \ |
| 6 | ; RUN: | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-DYNAMIC |
Kostya Serebryany | 4fb7801 | 2013-12-06 09:00:17 +0000 | [diff] [blame] | 7 | |
| 8 | target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" |
| 9 | target triple = "x86_64-unknown-linux-gnu" |
| 10 | |
| 11 | declare void @Use(i8*) |
| 12 | |
Alexander Potapenko | cb66fe3 | 2013-12-25 17:06:04 +0000 | [diff] [blame] | 13 | ; CHECK: private unnamed_addr constant{{.*}}3 32 10 3 XXX 64 20 3 YYY 128 30 3 ZZZ |
| 14 | ; CHECK: private unnamed_addr constant{{.*}}3 32 5 3 AAA 64 55 3 BBB 160 555 3 CCC |
| 15 | ; CHECK: private unnamed_addr constant{{.*}}3 256 128 3 CCC 448 128 3 BBB 608 128 3 AAA |
Kostya Serebryany | 4fb7801 | 2013-12-06 09:00:17 +0000 | [diff] [blame] | 16 | |
| 17 | define void @Func1() sanitize_address { |
| 18 | entry: |
| 19 | ; CHECK-LABEL: Func1 |
Alexey Samsonov | 4b7f413 | 2014-12-11 21:53:03 +0000 | [diff] [blame^] | 20 | |
| 21 | ; CHECK-STATIC: alloca [192 x i8] |
| 22 | ; CHECK-DYNAMIC: alloca i8, i64 192 |
| 23 | |
Kostya Serebryany | 4fb7801 | 2013-12-06 09:00:17 +0000 | [diff] [blame] | 24 | ; CHECK-NOT: alloca |
| 25 | ; CHECK: ret void |
| 26 | %XXX = alloca [10 x i8], align 1 |
| 27 | %YYY = alloca [20 x i8], align 1 |
| 28 | %ZZZ = alloca [30 x i8], align 1 |
| 29 | ret void |
| 30 | } |
| 31 | |
| 32 | define void @Func2() sanitize_address { |
| 33 | entry: |
| 34 | ; CHECK-LABEL: Func2 |
Alexey Samsonov | 4b7f413 | 2014-12-11 21:53:03 +0000 | [diff] [blame^] | 35 | |
| 36 | ; CHECK-STATIC: alloca [864 x i8] |
| 37 | ; CHECK-DYNAMIC: alloca i8, i64 864 |
| 38 | |
Kostya Serebryany | 4fb7801 | 2013-12-06 09:00:17 +0000 | [diff] [blame] | 39 | ; CHECK-NOT: alloca |
| 40 | ; CHECK: ret void |
| 41 | %AAA = alloca [5 x i8], align 1 |
| 42 | %BBB = alloca [55 x i8], align 1 |
| 43 | %CCC = alloca [555 x i8], align 1 |
| 44 | ret void |
| 45 | } |
| 46 | |
| 47 | ; Check that we reorder vars according to alignment and handle large alignments. |
| 48 | define void @Func3() sanitize_address { |
| 49 | entry: |
| 50 | ; CHECK-LABEL: Func3 |
Alexey Samsonov | 4b7f413 | 2014-12-11 21:53:03 +0000 | [diff] [blame^] | 51 | |
| 52 | ; CHECK-STATIC: alloca [768 x i8] |
| 53 | ; CHECK-DYNAMIC: alloca i8, i64 768 |
| 54 | |
Kostya Serebryany | 4fb7801 | 2013-12-06 09:00:17 +0000 | [diff] [blame] | 55 | ; CHECK-NOT: alloca |
| 56 | ; CHECK: ret void |
| 57 | %AAA = alloca [128 x i8], align 16 |
| 58 | %BBB = alloca [128 x i8], align 64 |
| 59 | %CCC = alloca [128 x i8], align 256 |
| 60 | ret void |
| 61 | } |