1 //===- Transforms/Instrumentation.h - Instrumentation passes ----*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines constructor functions for instrumentation passes.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_TRANSFORMS_INSTRUMENTATION_H
15 #define LLVM_TRANSFORMS_INSTRUMENTATION_H
17 #include "llvm/ADT/StringRef.h"
19 #if defined(__GNUC__) && defined(__linux__) && !defined(ANDROID)
20 inline void *getDFSanArgTLSPtrForJIT() {
21 extern __thread __attribute__((tls_model("initial-exec")))
22 void *__dfsan_arg_tls;
23 return (void *)&__dfsan_arg_tls;
26 inline void *getDFSanRetValTLSPtrForJIT() {
27 extern __thread __attribute__((tls_model("initial-exec")))
28 void *__dfsan_retval_tls;
29 return (void *)&__dfsan_retval_tls;
38 // Insert GCOV profiling instrumentation
40 static GCOVOptions getDefault();
42 // Specify whether to emit .gcno files.
45 // Specify whether to modify the program to emit .gcda files when run.
48 // A four-byte version string. The meaning of a version string is described in
52 // Emit a "cfg checksum" that follows the "line number checksum" of a
53 // function. This affects both .gcno and .gcda files.
56 // Add the 'noredzone' attribute to added runtime library calls.
59 // Emit the name of the function in the .gcda files. This is redundant, as
60 // the function identifier can be used to find the name from the .gcno file.
61 bool FunctionNamesInData;
63 ModulePass *createGCOVProfilerPass(const GCOVOptions &Options =
64 GCOVOptions::getDefault());
66 /// Options for the frontend instrumentation based profiling pass.
67 struct InstrProfOptions {
68 InstrProfOptions() : NoRedZone(false) {}
70 // Add the 'noredzone' attribute to added runtime library calls.
74 /// Insert frontend instrumentation based profiling.
75 ModulePass *createInstrProfilingPass(
76 const InstrProfOptions &Options = InstrProfOptions());
78 // Insert AddressSanitizer (address sanity checking) instrumentation
79 FunctionPass *createAddressSanitizerFunctionPass();
80 ModulePass *createAddressSanitizerModulePass();
82 // Insert MemorySanitizer instrumentation (detection of uninitialized reads)
83 FunctionPass *createMemorySanitizerPass(int TrackOrigins = 0);
85 // Insert ThreadSanitizer (race detection) instrumentation
86 FunctionPass *createThreadSanitizerPass();
88 // Insert DataFlowSanitizer (dynamic data flow analysis) instrumentation
89 ModulePass *createDataFlowSanitizerPass(StringRef ABIListFile = StringRef(),
90 void *(*getArgTLS)() = nullptr,
91 void *(*getRetValTLS)() = nullptr);
93 // Insert SanitizerCoverage instrumentation.
94 ModulePass *createSanitizerCoverageModulePass(int CoverageLevel);
96 #if defined(__GNUC__) && defined(__linux__) && !defined(ANDROID)
97 inline ModulePass *createDataFlowSanitizerPassForJIT(StringRef ABIListFile =
99 return createDataFlowSanitizerPass(ABIListFile, getDFSanArgTLSPtrForJIT,
100 getDFSanRetValTLSPtrForJIT);
104 // BoundsChecking - This pass instruments the code to perform run-time bounds
105 // checking on loads, stores, and other memory intrinsics.
106 FunctionPass *createBoundsCheckingPass();
108 } // End llvm namespace