OSDN Git Service

Merge "Update aosp/master LLVM for rebase to r230699."
[android-x86/external-llvm.git] / include / llvm / Transforms / Instrumentation.h
1 //===- Transforms/Instrumentation.h - Instrumentation passes ----*- 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 defines constructor functions for instrumentation passes.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_TRANSFORMS_INSTRUMENTATION_H
15 #define LLVM_TRANSFORMS_INSTRUMENTATION_H
16
17 #include "llvm/ADT/StringRef.h"
18 #include <vector>
19
20 #if defined(__GNUC__) && defined(__linux__) && !defined(ANDROID)
21 inline void *getDFSanArgTLSPtrForJIT() {
22   extern __thread __attribute__((tls_model("initial-exec")))
23     void *__dfsan_arg_tls;
24   return (void *)&__dfsan_arg_tls;
25 }
26
27 inline void *getDFSanRetValTLSPtrForJIT() {
28   extern __thread __attribute__((tls_model("initial-exec")))
29     void *__dfsan_retval_tls;
30   return (void *)&__dfsan_retval_tls;
31 }
32 #endif
33
34 namespace llvm {
35
36 class ModulePass;
37 class FunctionPass;
38
39 // Insert GCOV profiling instrumentation
40 struct GCOVOptions {
41   static GCOVOptions getDefault();
42
43   // Specify whether to emit .gcno files.
44   bool EmitNotes;
45
46   // Specify whether to modify the program to emit .gcda files when run.
47   bool EmitData;
48
49   // A four-byte version string. The meaning of a version string is described in
50   // gcc's gcov-io.h
51   char Version[4];
52
53   // Emit a "cfg checksum" that follows the "line number checksum" of a
54   // function. This affects both .gcno and .gcda files.
55   bool UseCfgChecksum;
56
57   // Add the 'noredzone' attribute to added runtime library calls.
58   bool NoRedZone;
59
60   // Emit the name of the function in the .gcda files. This is redundant, as
61   // the function identifier can be used to find the name from the .gcno file.
62   bool FunctionNamesInData;
63 };
64 ModulePass *createGCOVProfilerPass(const GCOVOptions &Options =
65                                    GCOVOptions::getDefault());
66
67 /// Options for the frontend instrumentation based profiling pass.
68 struct InstrProfOptions {
69   InstrProfOptions() : NoRedZone(false) {}
70
71   // Add the 'noredzone' attribute to added runtime library calls.
72   bool NoRedZone;
73 };
74
75 /// Insert frontend instrumentation based profiling.
76 ModulePass *createInstrProfilingPass(
77     const InstrProfOptions &Options = InstrProfOptions());
78
79 // Insert AddressSanitizer (address sanity checking) instrumentation
80 FunctionPass *createAddressSanitizerFunctionPass();
81 ModulePass *createAddressSanitizerModulePass();
82
83 // Insert MemorySanitizer instrumentation (detection of uninitialized reads)
84 FunctionPass *createMemorySanitizerPass(int TrackOrigins = 0);
85
86 // Insert ThreadSanitizer (race detection) instrumentation
87 FunctionPass *createThreadSanitizerPass();
88
89 // Insert DataFlowSanitizer (dynamic data flow analysis) instrumentation
90 ModulePass *createDataFlowSanitizerPass(
91     const std::vector<std::string> &ABIListFiles = std::vector<std::string>(),
92     void *(*getArgTLS)() = nullptr, void *(*getRetValTLS)() = nullptr);
93
94 // Insert SanitizerCoverage instrumentation.
95 ModulePass *createSanitizerCoverageModulePass(int CoverageLevel);
96
97 #if defined(__GNUC__) && defined(__linux__) && !defined(ANDROID)
98 inline ModulePass *createDataFlowSanitizerPassForJIT(
99     const std::vector<std::string> &ABIListFiles = std::vector<std::string>()) {
100   return createDataFlowSanitizerPass(ABIListFiles, getDFSanArgTLSPtrForJIT,
101                                      getDFSanRetValTLSPtrForJIT);
102 }
103 #endif
104
105 // BoundsChecking - This pass instruments the code to perform run-time bounds
106 // checking on loads, stores, and other memory intrinsics.
107 FunctionPass *createBoundsCheckingPass();
108
109 } // End llvm namespace
110
111 #endif