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 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 29 void __esan_exit(void *Ptr) { 30 processCompilationUnitExit(Ptr); 31 } 32 33 void __esan_aligned_load1(void *Addr) { 34 processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 1, false); 35 } 36 37 void __esan_aligned_load2(void *Addr) { 38 processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 2, false); 39 } 40 41 void __esan_aligned_load4(void *Addr) { 42 processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 4, false); 43 } 44 45 void __esan_aligned_load8(void *Addr) { 46 processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 8, false); 47 } 48 49 void __esan_aligned_load16(void *Addr) { 50 processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 16, false); 51 } 52 53 void __esan_aligned_store1(void *Addr) { 54 processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 1, true); 55 } 56 57 void __esan_aligned_store2(void *Addr) { 58 processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 2, true); 59 } 60 61 void __esan_aligned_store4(void *Addr) { 62 processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 4, true); 63 } 64 65 void __esan_aligned_store8(void *Addr) { 66 processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 8, true); 67 } 68 69 void __esan_aligned_store16(void *Addr) { 70 processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 16, true); 71 } 72 73 void __esan_unaligned_load2(void *Addr) { 74 processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 2, false); 75 } 76 77 void __esan_unaligned_load4(void *Addr) { 78 processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 4, false); 79 } 80 81 void __esan_unaligned_load8(void *Addr) { 82 processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 8, false); 83 } 84 85 void __esan_unaligned_load16(void *Addr) { 86 processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 16, false); 87 } 88 89 void __esan_unaligned_store2(void *Addr) { 90 processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 2, true); 91 } 92 93 void __esan_unaligned_store4(void *Addr) { 94 processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 4, true); 95 } 96 97 void __esan_unaligned_store8(void *Addr) { 98 processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 8, true); 99 } 100 101 void __esan_unaligned_store16(void *Addr) { 102 processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 16, true); 103 } 104 105 void __esan_unaligned_loadN(void *Addr, uptr Size) { 106 processRangeAccess(GET_CALLER_PC(), (uptr)Addr, Size, false); 107 } 108 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" { 115 SANITIZER_INTERFACE_ATTRIBUTE void __esan_report() { 116 reportResults(); 117 } 118 } // extern "C" 119