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"
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;
27 inline void *getDFSanRetValTLSPtrForJIT() {
28 extern __thread __attribute__((tls_model("initial-exec")))
29 void *__dfsan_retval_tls;
30 return (void *)&__dfsan_retval_tls;
39 // Insert GCOV profiling instrumentation
41 static GCOVOptions getDefault();
43 // Specify whether to emit .gcno files.
46 // Specify whether to modify the program to emit .gcda files when run.
49 // A four-byte version string. The meaning of a version string is described in
53 // Emit a "cfg checksum" that follows the "line number checksum" of a
54 // function. This affects both .gcno and .gcda files.
57 // Add the 'noredzone' attribute to added runtime library calls.
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;
64 // Emit the exit block immediately after the start block, rather than after
65 // all of the function body's blocks.
66 bool ExitBlockBeforeBody;
68 ModulePass *createGCOVProfilerPass(const GCOVOptions &Options =
69 GCOVOptions::getDefault());
71 /// Options for the frontend instrumentation based profiling pass.
72 struct InstrProfOptions {
73 InstrProfOptions() : NoRedZone(false) {}
75 // Add the 'noredzone' attribute to added runtime library calls.
79 /// Insert frontend instrumentation based profiling.
80 ModulePass *createInstrProfilingPass(
81 const InstrProfOptions &Options = InstrProfOptions());
83 // Insert AddressSanitizer (address sanity checking) instrumentation
84 FunctionPass *createAddressSanitizerFunctionPass();
85 ModulePass *createAddressSanitizerModulePass();
87 // Insert MemorySanitizer instrumentation (detection of uninitialized reads)
88 FunctionPass *createMemorySanitizerPass(int TrackOrigins = 0);
90 // Insert ThreadSanitizer (race detection) instrumentation
91 FunctionPass *createThreadSanitizerPass();
93 // Insert DataFlowSanitizer (dynamic data flow analysis) instrumentation
94 ModulePass *createDataFlowSanitizerPass(
95 const std::vector<std::string> &ABIListFiles = std::vector<std::string>(),
96 void *(*getArgTLS)() = nullptr, void *(*getRetValTLS)() = nullptr);
98 // Insert SanitizerCoverage instrumentation.
99 ModulePass *createSanitizerCoverageModulePass(int CoverageLevel);
101 #if defined(__GNUC__) && defined(__linux__) && !defined(ANDROID)
102 inline ModulePass *createDataFlowSanitizerPassForJIT(
103 const std::vector<std::string> &ABIListFiles = std::vector<std::string>()) {
104 return createDataFlowSanitizerPass(ABIListFiles, getDFSanArgTLSPtrForJIT,
105 getDFSanRetValTLSPtrForJIT);
109 // BoundsChecking - This pass instruments the code to perform run-time bounds
110 // checking on loads, stores, and other memory intrinsics.
111 FunctionPass *createBoundsCheckingPass();
113 } // End llvm namespace