OLD | NEW |
1 ; Test for insertion of redzones around local variables | 1 ; Test for insertion of redzones around local variables |
2 | 2 |
3 ; REQUIRES: allow_dump | 3 ; REQUIRES: allow_dump |
4 | 4 |
5 ; RUN: %p2i -i %s --args -verbose=inst -threads=0 -fsanitize-address \ | 5 ; RUN: %p2i -i %s --args -verbose=inst -threads=0 -fsanitize-address \ |
6 ; RUN: | FileCheck --check-prefix=DUMP %s | 6 ; RUN: -allow-externally-defined-symbols | FileCheck --check-prefix=DUMP %s |
7 | 7 |
8 ; Function with local variables to be instrumented | 8 ; Function with local variables to be instrumented |
9 define internal void @func() { | 9 define internal void @func() { |
10 %local1 = alloca i8, i32 4, align 4 | 10 %local1 = alloca i8, i32 4, align 4 |
11 %local2 = alloca i8, i32 32, align 1 | 11 %local2 = alloca i8, i32 32, align 1 |
12 %local3 = alloca i8, i32 13, align 2 | 12 %local3 = alloca i8, i32 13, align 2 |
13 %local4 = alloca i8, i32 75, align 4 | 13 %local4 = alloca i8, i32 75, align 4 |
14 %local5 = alloca i8, i32 64, align 8 | 14 %local5 = alloca i8, i32 64, align 8 |
| 15 %i1 = ptrtoint i8* %local1 to i32 |
| 16 %i2 = ptrtoint i8* %local2 to i32 |
| 17 %i3 = ptrtoint i8* %local3 to i32 |
| 18 %i4 = ptrtoint i8* %local4 to i32 |
| 19 %i5 = ptrtoint i8* %local5 to i32 |
| 20 call void @foo(i32 %i1) |
| 21 call void @foo(i32 %i2) |
| 22 call void @foo(i32 %i3) |
| 23 call void @foo(i32 %i4) |
| 24 call void @foo(i32 %i5) |
15 ret void | 25 ret void |
16 } | 26 } |
17 | 27 |
| 28 declare external void @foo(i32) |
| 29 |
18 ; DUMP-LABEL: ================ Instrumented CFG ================ | 30 ; DUMP-LABEL: ================ Instrumented CFG ================ |
19 ; DUMP-NEXT: define internal void @func() { | 31 ; DUMP-NEXT: define internal void @func() { |
20 ; DUMP-NEXT: __0: | 32 ; DUMP-NEXT: __0: |
21 ; DUMP-NEXT: %local1 = alloca i8, i32 64, align 8 | 33 ; DUMP-NEXT: %__$rz0 = alloca i8, i32 32, align 8 |
22 ; DUMP-NEXT: %local2 = alloca i8, i32 64, align 8 | 34 ; DUMP-NEXT: %local1 = alloca i8, i32 64, align 8 |
23 ; DUMP-NEXT: %local3 = alloca i8, i32 64, align 8 | 35 ; DUMP-NEXT: %local2 = alloca i8, i32 64, align 8 |
24 ; DUMP-NEXT: %local4 = alloca i8, i32 128, align 8 | 36 ; DUMP-NEXT: %local3 = alloca i8, i32 64, align 8 |
25 ; DUMP-NEXT: %local5 = alloca i8, i32 96, align 8 | 37 ; DUMP-NEXT: %local4 = alloca i8, i32 128, align 8 |
26 ; DUMP-NEXT: %__$rz[[RZ0:[0-9]+]] = alloca i8, i32 32, align 8 | 38 ; DUMP-NEXT: %local5 = alloca i8, i32 96, align 8 |
27 ; DUMP-NEXT: call void @__asan_poison(i32 %__$rz[[RZ0]], i32 32, i32 -1) | 39 ; DUMP-NEXT: %shadowIndex = lshr i32 %__$rz0, 3 |
28 ; DUMP-NEXT: %__$rz[[RZ1:[0-9]+]] = add i32 %local1, 4 | 40 ; DUMP-NEXT: %firstShadowLoc = add i32 %shadowIndex, 536870912 |
29 ; DUMP-NEXT: call void @__asan_poison(i32 %__$rz[[RZ1]], i32 60, i32 -1) | 41 ; DUMP-NEXT: %__8 = add i32 %firstShadowLoc, 0 |
30 ; DUMP-NEXT: %__$rz[[RZ2:[0-9]+]] = add i32 %local2, 32 | 42 ; DUMP-NEXT: store i32 -1, i32* %__8, align 1 |
31 ; DUMP-NEXT: call void @__asan_poison(i32 %__$rz[[RZ2]], i32 32, i32 -1) | 43 ; DUMP-NEXT: %__9 = add i32 %firstShadowLoc, 4 |
32 ; DUMP-NEXT: %__$rz[[RZ3:[0-9]+]] = add i32 %local3, 13 | 44 ; DUMP-NEXT: store i32 -252, i32* %__9, align 1 |
33 ; DUMP-NEXT: call void @__asan_poison(i32 %__$rz[[RZ3]], i32 51, i32 -1) | 45 ; DUMP-NEXT: %__10 = add i32 %firstShadowLoc, 8 |
34 ; DUMP-NEXT: %__$rz[[RZ4:[0-9]+]] = add i32 %local4, 75 | 46 ; DUMP-NEXT: store i32 -1, i32* %__10, align 1 |
35 ; DUMP-NEXT: call void @__asan_poison(i32 %__$rz[[RZ4]], i32 53, i32 -1) | 47 ; DUMP-NEXT: %__11 = add i32 %firstShadowLoc, 16 |
36 ; DUMP-NEXT: %__$rz[[RZ5:[0-9]+]] = add i32 %local5, 64 | 48 ; DUMP-NEXT: store i32 -1, i32* %__11, align 1 |
37 ; DUMP-NEXT: call void @__asan_poison(i32 %__$rz[[RZ5]], i32 32, i32 -1) | 49 ; DUMP-NEXT: %__12 = add i32 %firstShadowLoc, 20 |
38 ; DUMP-NEXT: call void @__asan_unpoison(i32 %__$rz[[RZ1]], i32 60) | 50 ; DUMP-NEXT: store i32 -64256, i32* %__12, align 1 |
39 ; DUMP-NEXT: call void @__asan_unpoison(i32 %__$rz[[RZ2]], i32 32) | 51 ; DUMP-NEXT: %__13 = add i32 %firstShadowLoc, 24 |
40 ; DUMP-NEXT: call void @__asan_unpoison(i32 %__$rz[[RZ3]], i32 51) | 52 ; DUMP-NEXT: store i32 -1, i32* %__13, align 1 |
41 ; DUMP-NEXT: call void @__asan_unpoison(i32 %__$rz[[RZ4]], i32 53) | 53 ; DUMP-NEXT: %__14 = add i32 %firstShadowLoc, 36 |
42 ; DUMP-NEXT: call void @__asan_unpoison(i32 %__$rz[[RZ5]], i32 32) | 54 ; DUMP-NEXT: store i32 -64768, i32* %__14, align 1 |
43 ; DUMP-NEXT: call void @__asan_unpoison(i32 %__$rz[[RZ0]], i32 32) | 55 ; DUMP-NEXT: %__15 = add i32 %firstShadowLoc, 40 |
44 ; DUMP-NEXT: ret void | 56 ; DUMP-NEXT: store i32 -1, i32* %__15, align 1 |
| 57 ; DUMP-NEXT: %__16 = add i32 %firstShadowLoc, 52 |
| 58 ; DUMP-NEXT: store i32 -1, i32* %__16, align 1 |
| 59 ; DUMP-NEXT: call void @foo(i32 %local1) |
| 60 ; DUMP-NEXT: call void @foo(i32 %local2) |
| 61 ; DUMP-NEXT: call void @foo(i32 %local3) |
| 62 ; DUMP-NEXT: call void @foo(i32 %local4) |
| 63 ; DUMP-NEXT: call void @foo(i32 %local5) |
| 64 ; DUMP-NEXT: store i32 0, i32* %__8, align 1 |
| 65 ; DUMP-NEXT: store i32 0, i32* %__9, align 1 |
| 66 ; DUMP-NEXT: store i32 0, i32* %__10, align 1 |
| 67 ; DUMP-NEXT: store i32 0, i32* %__11, align 1 |
| 68 ; DUMP-NEXT: store i32 0, i32* %__12, align 1 |
| 69 ; DUMP-NEXT: store i32 0, i32* %__13, align 1 |
| 70 ; DUMP-NEXT: store i32 0, i32* %__14, align 1 |
| 71 ; DUMP-NEXT: store i32 0, i32* %__15, align 1 |
| 72 ; DUMP-NEXT: store i32 0, i32* %__16, align 1 |
| 73 ; DUMP-NEXT: ret void |
45 ; DUMP-NEXT: } | 74 ; DUMP-NEXT: } |
OLD | NEW |