]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/compiler-rt/lib/esan/esan_interface_internal.h
Merge llvm, clang, lld, lldb, compiler-rt and libc++ r301441, and update
[FreeBSD/FreeBSD.git] / contrib / compiler-rt / lib / esan / esan_interface_internal.h
1 //===-- esan_interface_internal.h -------------------------------*- C++ -*-===//
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 // Calls to the functions declared in this header will be inserted by
13 // the instrumentation module.
14 //===----------------------------------------------------------------------===//
15
16 #ifndef ESAN_INTERFACE_INTERNAL_H
17 #define ESAN_INTERFACE_INTERNAL_H
18
19 #include <sanitizer_common/sanitizer_internal_defs.h>
20
21 // This header should NOT include any other headers.
22 // All functions in this header are extern "C" and start with __esan_.
23
24 using __sanitizer::uptr;
25 using __sanitizer::u32;
26
27 extern "C" {
28
29 // This should be kept consistent with LLVM's EfficiencySanitizerOptions.
30 // The value is passed as a 32-bit integer by the compiler.
31 typedef enum Type : u32 {
32   ESAN_None = 0,
33   ESAN_CacheFrag,
34   ESAN_WorkingSet,
35   ESAN_Max,
36 } ToolType;
37
38 // To handle interceptors that invoke instrumented code prior to
39 // __esan_init() being called, the instrumentation module creates this
40 // global variable specifying the tool.
41 extern ToolType __esan_which_tool;
42
43 // This function should be called at the very beginning of the process,
44 // before any instrumented code is executed and before any call to malloc.
45 SANITIZER_INTERFACE_ATTRIBUTE void __esan_init(ToolType Tool, void *Ptr);
46 SANITIZER_INTERFACE_ATTRIBUTE void __esan_exit(void *Ptr);
47
48 // The instrumentation module will insert a call to one of these routines prior
49 // to each load and store instruction for which we do not have "fastpath"
50 // inlined instrumentation.  These calls constitute the "slowpath" for our
51 // tools.  We have separate routines for each type of memory access to enable
52 // targeted optimization.
53 SANITIZER_INTERFACE_ATTRIBUTE void __esan_aligned_load1(void *Addr);
54 SANITIZER_INTERFACE_ATTRIBUTE void __esan_aligned_load2(void *Addr);
55 SANITIZER_INTERFACE_ATTRIBUTE void __esan_aligned_load4(void *Addr);
56 SANITIZER_INTERFACE_ATTRIBUTE void __esan_aligned_load8(void *Addr);
57 SANITIZER_INTERFACE_ATTRIBUTE void __esan_aligned_load16(void *Addr);
58
59 SANITIZER_INTERFACE_ATTRIBUTE void __esan_aligned_store1(void *Addr);
60 SANITIZER_INTERFACE_ATTRIBUTE void __esan_aligned_store2(void *Addr);
61 SANITIZER_INTERFACE_ATTRIBUTE void __esan_aligned_store4(void *Addr);
62 SANITIZER_INTERFACE_ATTRIBUTE void __esan_aligned_store8(void *Addr);
63 SANITIZER_INTERFACE_ATTRIBUTE void __esan_aligned_store16(void *Addr);
64
65 SANITIZER_INTERFACE_ATTRIBUTE void __esan_unaligned_load2(void *Addr);
66 SANITIZER_INTERFACE_ATTRIBUTE void __esan_unaligned_load4(void *Addr);
67 SANITIZER_INTERFACE_ATTRIBUTE void __esan_unaligned_load8(void *Addr);
68 SANITIZER_INTERFACE_ATTRIBUTE void __esan_unaligned_load16(void *Addr);
69
70 SANITIZER_INTERFACE_ATTRIBUTE void __esan_unaligned_store2(void *Addr);
71 SANITIZER_INTERFACE_ATTRIBUTE void __esan_unaligned_store4(void *Addr);
72 SANITIZER_INTERFACE_ATTRIBUTE void __esan_unaligned_store8(void *Addr);
73 SANITIZER_INTERFACE_ATTRIBUTE void __esan_unaligned_store16(void *Addr);
74
75 // These cover unusually-sized accesses.
76 SANITIZER_INTERFACE_ATTRIBUTE
77 void __esan_unaligned_loadN(void *Addr, uptr Size);
78 SANITIZER_INTERFACE_ATTRIBUTE
79 void __esan_unaligned_storeN(void *Addr, uptr Size);
80
81 } // extern "C"
82
83 #endif // ESAN_INTERFACE_INTERNAL_H