1 //===-- esan_interface.cpp ------------------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file is a part of EfficiencySanitizer, a family of performance tuners.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "esan_interface_internal.h"
15 #include "esan.h"
16 #include "sanitizer_common/sanitizer_internal_defs.h"
17
18 using namespace __esan; // NOLINT
19
__esan_init(ToolType Tool,void * Ptr)20 void __esan_init(ToolType Tool, void *Ptr) {
21 if (Tool != __esan_which_tool) {
22 Printf("ERROR: tool mismatch: %d vs %d\n", Tool, __esan_which_tool);
23 Die();
24 }
25 initializeLibrary(Tool);
26 processCompilationUnitInit(Ptr);
27 }
28
__esan_exit(void * Ptr)29 void __esan_exit(void *Ptr) {
30 processCompilationUnitExit(Ptr);
31 }
32
__esan_aligned_load1(void * Addr)33 void __esan_aligned_load1(void *Addr) {
34 processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 1, false);
35 }
36
__esan_aligned_load2(void * Addr)37 void __esan_aligned_load2(void *Addr) {
38 processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 2, false);
39 }
40
__esan_aligned_load4(void * Addr)41 void __esan_aligned_load4(void *Addr) {
42 processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 4, false);
43 }
44
__esan_aligned_load8(void * Addr)45 void __esan_aligned_load8(void *Addr) {
46 processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 8, false);
47 }
48
__esan_aligned_load16(void * Addr)49 void __esan_aligned_load16(void *Addr) {
50 processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 16, false);
51 }
52
__esan_aligned_store1(void * Addr)53 void __esan_aligned_store1(void *Addr) {
54 processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 1, true);
55 }
56
__esan_aligned_store2(void * Addr)57 void __esan_aligned_store2(void *Addr) {
58 processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 2, true);
59 }
60
__esan_aligned_store4(void * Addr)61 void __esan_aligned_store4(void *Addr) {
62 processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 4, true);
63 }
64
__esan_aligned_store8(void * Addr)65 void __esan_aligned_store8(void *Addr) {
66 processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 8, true);
67 }
68
__esan_aligned_store16(void * Addr)69 void __esan_aligned_store16(void *Addr) {
70 processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 16, true);
71 }
72
__esan_unaligned_load2(void * Addr)73 void __esan_unaligned_load2(void *Addr) {
74 processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 2, false);
75 }
76
__esan_unaligned_load4(void * Addr)77 void __esan_unaligned_load4(void *Addr) {
78 processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 4, false);
79 }
80
__esan_unaligned_load8(void * Addr)81 void __esan_unaligned_load8(void *Addr) {
82 processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 8, false);
83 }
84
__esan_unaligned_load16(void * Addr)85 void __esan_unaligned_load16(void *Addr) {
86 processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 16, false);
87 }
88
__esan_unaligned_store2(void * Addr)89 void __esan_unaligned_store2(void *Addr) {
90 processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 2, true);
91 }
92
__esan_unaligned_store4(void * Addr)93 void __esan_unaligned_store4(void *Addr) {
94 processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 4, true);
95 }
96
__esan_unaligned_store8(void * Addr)97 void __esan_unaligned_store8(void *Addr) {
98 processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 8, true);
99 }
100
__esan_unaligned_store16(void * Addr)101 void __esan_unaligned_store16(void *Addr) {
102 processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 16, true);
103 }
104
__esan_unaligned_loadN(void * Addr,uptr Size)105 void __esan_unaligned_loadN(void *Addr, uptr Size) {
106 processRangeAccess(GET_CALLER_PC(), (uptr)Addr, Size, false);
107 }
108
__esan_unaligned_storeN(void * Addr,uptr Size)109 void __esan_unaligned_storeN(void *Addr, uptr Size) {
110 processRangeAccess(GET_CALLER_PC(), (uptr)Addr, Size, true);
111 }
112
113 // Public interface:
114 extern "C" {
__esan_report()115 SANITIZER_INTERFACE_ATTRIBUTE void __esan_report() {
116 reportResults();
117 }
118 } // extern "C"
119