Home | History | Annotate | Download | only in asan_tests
      1 ; Test for insertion of redzones around local variables
      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 
      8 ; Function with local variables to be instrumented
      9 define internal void @func() {
     10   %local1 = alloca i8, i32 4, align 4
     11   %local2 = alloca i8, i32 32, align 1
     12   %local3 = alloca i8, i32 13, align 2
     13   %local4 = alloca i8, i32 75, align 4
     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)
     25   ret void
     26 }
     27 
     28 declare external void @foo(i32)
     29 
     30 ; DUMP-LABEL: ================ Instrumented CFG ================
     31 ; DUMP-NEXT: define internal void @func() {
     32 ; DUMP-NEXT: __0:
     33 ; DUMP-NEXT:   %__$rz0 = alloca i8, i32 32, align 8
     34 ; DUMP-NEXT:   %local1 = alloca i8, i32 64, align 8
     35 ; DUMP-NEXT:   %local2 = alloca i8, i32 64, align 8
     36 ; DUMP-NEXT:   %local3 = alloca i8, i32 64, align 8
     37 ; DUMP-NEXT:   %local4 = alloca i8, i32 128, align 8
     38 ; DUMP-NEXT:   %local5 = alloca i8, i32 96, align 8
     39 ; DUMP-NEXT:   %shadowIndex = lshr i32 %__$rz0, 3
     40 ; DUMP-NEXT:   %firstShadowLoc = add i32 %shadowIndex, 536870912
     41 ; DUMP-NEXT:   %__8 = add i32 %firstShadowLoc, 0
     42 ; DUMP-NEXT:   store i32 -1, i32* %__8, align 1
     43 ; DUMP-NEXT:   %__9 = add i32 %firstShadowLoc, 4
     44 ; DUMP-NEXT:   store i32 -252, i32* %__9, align 1
     45 ; DUMP-NEXT:   %__10 = add i32 %firstShadowLoc, 8
     46 ; DUMP-NEXT:   store i32 -1, i32* %__10, align 1
     47 ; DUMP-NEXT:   %__11 = add i32 %firstShadowLoc, 16
     48 ; DUMP-NEXT:   store i32 -1, i32* %__11, align 1
     49 ; DUMP-NEXT:   %__12 = add i32 %firstShadowLoc, 20
     50 ; DUMP-NEXT:   store i32 -64256, i32* %__12, align 1
     51 ; DUMP-NEXT:   %__13 = add i32 %firstShadowLoc, 24
     52 ; DUMP-NEXT:   store i32 -1, i32* %__13, align 1
     53 ; DUMP-NEXT:   %__14 = add i32 %firstShadowLoc, 36
     54 ; DUMP-NEXT:   store i32 -64768, i32* %__14, align 1
     55 ; DUMP-NEXT:   %__15 = add i32 %firstShadowLoc, 40
     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
     74 ; DUMP-NEXT: }
     75