• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; Test that static allocas throughout the entry block are instrumented correctly
2
3; REQUIRES: allow_dump
4
5; RUN: %p2i -i %s --args -verbose=inst -threads=0 -fsanitize-address \
6; RUN:     -allow-externally-defined-symbols | FileCheck --check-prefix=DUMP %s
7
8declare external i32 @malloc(i32)
9declare external void @free(i32)
10
11define void @func() {
12  %a = alloca i8, i32 4, align 4
13  %m1 = call i32 @malloc(i32 42)
14  %b = alloca i8, i32 16, align 4
15  store i8 50, i8* %a, align 1
16  %c = alloca i8, i32 8, align 8
17  call void @free(i32 %m1)
18  %d = alloca i8, i32 12, align 4
19  ret void
20}
21
22; DUMP-LABEL: ================ Instrumented CFG ================
23; DUMP-NEXT: define void @func() {
24; DUMP-NEXT: __0:
25; DUMP-NEXT:   %__$rz0 = alloca i8, i32 32, align 8
26; DUMP-NEXT:   %a = alloca i8, i32 64, align 8
27; DUMP-NEXT:   %b = alloca i8, i32 64, align 8
28; DUMP-NEXT:   %c = alloca i8, i32 64, align 8
29; DUMP-NEXT:   %d = alloca i8, i32 64, align 8
30; DUMP-NEXT:   %shadowIndex = lshr i32 %__$rz0, 3
31; DUMP-NEXT:   %firstShadowLoc = add i32 %shadowIndex, 536870912
32; DUMP-NEXT:   %__8 = add i32 %firstShadowLoc, 0
33; DUMP-NEXT:   store i32 -1, i32* %__8, align 1
34; DUMP-NEXT:   %__9 = add i32 %firstShadowLoc, 4
35; DUMP-NEXT:   store i32 -252, i32* %__9, align 1
36; DUMP-NEXT:   %__10 = add i32 %firstShadowLoc, 8
37; DUMP-NEXT:   store i32 -1, i32* %__10, align 1
38; DUMP-NEXT:   %__11 = add i32 %firstShadowLoc, 12
39; DUMP-NEXT:   store i32 -65536, i32* %__11, align 1
40; DUMP-NEXT:   %__12 = add i32 %firstShadowLoc, 16
41; DUMP-NEXT:   store i32 -1, i32* %__12, align 1
42; DUMP-NEXT:   %__13 = add i32 %firstShadowLoc, 20
43; DUMP-NEXT:   store i32 -256, i32* %__13, align 1
44; DUMP-NEXT:   %__14 = add i32 %firstShadowLoc, 24
45; DUMP-NEXT:   store i32 -1, i32* %__14, align 1
46; DUMP-NEXT:   %__15 = add i32 %firstShadowLoc, 28
47; DUMP-NEXT:   store i32 -64512, i32* %__15, align 1
48; DUMP-NEXT:   %__16 = add i32 %firstShadowLoc, 32
49; DUMP-NEXT:   store i32 -1, i32* %__16, align 1
50; DUMP-NEXT:   %m1 = call i32 @__asan_malloc(i32 42)
51; DUMP-NEXT:   store i8 50, i8* %a, align 1
52; DUMP-NEXT:   call void @__asan_free(i32 %m1)
53; DUMP-NEXT:   store i32 0, i32* %__8, align 1
54; DUMP-NEXT:   store i32 0, i32* %__9, align 1
55; DUMP-NEXT:   store i32 0, i32* %__10, align 1
56; DUMP-NEXT:   store i32 0, i32* %__11, align 1
57; DUMP-NEXT:   store i32 0, i32* %__12, align 1
58; DUMP-NEXT:   store i32 0, i32* %__13, align 1
59; DUMP-NEXT:   store i32 0, i32* %__14, align 1
60; DUMP-NEXT:   store i32 0, i32* %__15, align 1
61; DUMP-NEXT:   store i32 0, i32* %__16, align 1
62; DUMP-NEXT:   ret void
63; DUMP-NEXT: }