Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Side by Side Diff: tests_lit/asan_tests/localreplacement.ll

Issue 2256903003: Subzero: Replace pointers to allocation functions in stores (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Refactored common logic Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/IceASanInstrumentation.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 ; Test that loads of local pointers to allocation functions are instrumented 1 ; Test that loads of local pointers to allocation functions and stores
2 ; of pointers to allocation functions are instrumented.
2 3
3 ; REQUIRES: allow_dump 4 ; REQUIRES: allow_dump
4 5
5 ; RUN: %p2i -i %s --args -verbose=inst -threads=0 -fsanitize-address \ 6 ; RUN: %p2i -i %s --args -verbose=inst -threads=0 -fsanitize-address \
6 ; RUN: -allow-externally-defined-symbols | FileCheck --check-prefix=DUMP %s 7 ; RUN: -allow-externally-defined-symbols | FileCheck --check-prefix=DUMP %s
7 8
8 declare external i32 @malloc(i32) 9 declare external i32 @malloc(i32)
9 declare external i32 @realloc(i32, i32) 10 declare external i32 @realloc(i32, i32)
10 declare external i32 @calloc(i32, i32) 11 declare external i32 @calloc(i32, i32)
11 declare external void @free(i32) 12 declare external void @free(i32)
12 13
13 define internal void @func() { 14 define internal void @func(i32 %store_loc) {
14 %malloc_addr = bitcast i32 (i32)* @malloc to i32* 15 %store_dest = inttoptr i32 %store_loc to i32*
15 %realloc_addr = bitcast i32 (i32, i32)* @realloc to i32*
16 %calloc_addr = bitcast i32 (i32, i32)* @calloc to i32*
17 %free_addr = bitcast void (i32)* @free to i32*
18 16
19 %local_malloc = load i32, i32* %malloc_addr, align 1 17 %malloc_ptr = bitcast i32 (i32)* @malloc to i32*
20 %local_realloc = load i32, i32* %realloc_addr, align 1 18 %realloc_ptr = bitcast i32 (i32, i32)* @realloc to i32*
21 %local_calloc = load i32, i32* %calloc_addr, align 1 19 %calloc_ptr = bitcast i32 (i32, i32)* @calloc to i32*
22 %local_free = load i32, i32* %free_addr, align 1 20 %free_ptr = bitcast void (i32)* @free to i32*
21
22 %malloc_addr = ptrtoint i32 (i32)* @malloc to i32
23 %realloc_addr = ptrtoint i32 (i32, i32)* @realloc to i32
24 %calloc_addr = ptrtoint i32 (i32, i32)* @calloc to i32
25 %free_addr = ptrtoint void (i32)* @free to i32
26
27 store i32 %malloc_addr, i32* %store_dest, align 1
28 store i32 %realloc_addr, i32* %store_dest, align 1
29 store i32 %calloc_addr, i32* %store_dest, align 1
30 store i32 %free_addr, i32* %store_dest, align 1
31
32 %local_malloc = load i32, i32* %malloc_ptr, align 1
33 %local_realloc = load i32, i32* %realloc_ptr, align 1
34 %local_calloc = load i32, i32* %calloc_ptr, align 1
35 %local_free = load i32, i32* %free_ptr, align 1
23 36
24 %local_mallocfunc = inttoptr i32 %local_malloc to i32 (i32)* 37 %local_mallocfunc = inttoptr i32 %local_malloc to i32 (i32)*
25 %local_reallocfunc = inttoptr i32 %local_realloc to i32 (i32, i32)* 38 %local_reallocfunc = inttoptr i32 %local_realloc to i32 (i32, i32)*
26 %local_callocfunc = inttoptr i32 %local_calloc to i32 (i32, i32)* 39 %local_callocfunc = inttoptr i32 %local_calloc to i32 (i32, i32)*
27 %local_freefunc = inttoptr i32 %local_free to void (i32)* 40 %local_freefunc = inttoptr i32 %local_free to void (i32)*
28 41
29 %buf = call i32 %local_mallocfunc(i32 42) 42 %buf = call i32 %local_mallocfunc(i32 42)
30 call void %local_freefunc(i32 %buf) 43 call void %local_freefunc(i32 %buf)
31 ret void 44 ret void
32 } 45 }
33 46
34 ; DUMP-LABEL: ================ Instrumented CFG ================ 47 ; DUMP-LABEL: ================ Instrumented CFG ================
35 ; DUMP-NEXT: @func() { 48 ; DUMP-NEXT: @func(i32 %store_loc) {
36 ; DUMP-NEXT: __0: 49 ; DUMP-NEXT: __0:
50 ; DUMP-NEXT: call void @__asan_check_store(i32 %store_loc, i32 4)
51 ; DUMP-NEXT: store i32 @__asan_malloc, i32* %store_loc, align 1
52 ; DUMP-NEXT: store i32 @__asan_realloc, i32* %store_loc, align 1
53 ; DUMP-NEXT: store i32 @__asan_calloc, i32* %store_loc, align 1
54 ; DUMP-NEXT: store i32 @__asan_free, i32* %store_loc, align 1
37 ; DUMP-NEXT: call void @__asan_check_load(i32 @__asan_malloc, i32 4) 55 ; DUMP-NEXT: call void @__asan_check_load(i32 @__asan_malloc, i32 4)
38 ; DUMP-NEXT: %local_malloc = load i32, i32* @__asan_malloc, align 1 56 ; DUMP-NEXT: %local_malloc = load i32, i32* @__asan_malloc, align 1
39 ; DUMP-NEXT: call void @__asan_check_load(i32 @__asan_realloc, i32 4) 57 ; DUMP-NEXT: call void @__asan_check_load(i32 @__asan_realloc, i32 4)
40 ; DUMP-NEXT: %local_realloc = load i32, i32* @__asan_realloc, align 1 58 ; DUMP-NEXT: %local_realloc = load i32, i32* @__asan_realloc, align 1
41 ; DUMP-NEXT: call void @__asan_check_load(i32 @__asan_calloc, i32 4) 59 ; DUMP-NEXT: call void @__asan_check_load(i32 @__asan_calloc, i32 4)
42 ; DUMP-NEXT: %local_calloc = load i32, i32* @__asan_calloc, align 1 60 ; DUMP-NEXT: %local_calloc = load i32, i32* @__asan_calloc, align 1
43 ; DUMP-NEXT: call void @__asan_check_load(i32 @__asan_free, i32 4) 61 ; DUMP-NEXT: call void @__asan_check_load(i32 @__asan_free, i32 4)
44 ; DUMP-NEXT: %local_free = load i32, i32* @__asan_free, align 1 62 ; DUMP-NEXT: %local_free = load i32, i32* @__asan_free, align 1
45 ; DUMP-NEXT: %buf = call i32 %local_malloc(i32 42) 63 ; DUMP-NEXT: %buf = call i32 %local_malloc(i32 42)
46 ; DUMP-NEXT: call void %local_free(i32 %buf) 64 ; DUMP-NEXT: call void %local_free(i32 %buf)
47 ; DUMP-NEXT: ret void 65 ; DUMP-NEXT: ret void
48 ; DUMP-NEXT: } 66 ; DUMP-NEXT: }
OLDNEW
« no previous file with comments | « src/IceASanInstrumentation.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698