LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Instrumentation.h
Go to the documentation of this file.
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 
19 #if defined(__GNUC__) && defined(__linux__)
20 inline void *getDFSanArgTLSPtrForJIT() {
21  extern __thread __attribute__((tls_model("initial-exec")))
22  void *__dfsan_arg_tls;
23  return (void *)&__dfsan_arg_tls;
24 }
25 
26 inline void *getDFSanRetValTLSPtrForJIT() {
27  extern __thread __attribute__((tls_model("initial-exec")))
28  void *__dfsan_retval_tls;
29  return (void *)&__dfsan_retval_tls;
30 }
31 #endif
32 
33 namespace llvm {
34 
35 class ModulePass;
36 class FunctionPass;
37 
38 // Insert GCOV profiling instrumentation
39 struct GCOVOptions {
40  static GCOVOptions getDefault();
41 
42  // Specify whether to emit .gcno files.
43  bool EmitNotes;
44 
45  // Specify whether to modify the program to emit .gcda files when run.
46  bool EmitData;
47 
48  // A four-byte version string. The meaning of a version string is described in
49  // gcc's gcov-io.h
50  char Version[4];
51 
52  // Emit a "cfg checksum" that follows the "line number checksum" of a
53  // function. This affects both .gcno and .gcda files.
55 
56  // Add the 'noredzone' attribute to added runtime library calls.
57  bool NoRedZone;
58 
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.
62 };
65 
66 // Insert AddressSanitizer (address sanity checking) instrumentation
68  bool CheckInitOrder = true, bool CheckUseAfterReturn = false,
69  bool CheckLifetime = false, StringRef BlacklistFile = StringRef(),
70  bool ZeroBaseShadow = false);
72  bool CheckInitOrder = true, StringRef BlacklistFile = StringRef(),
73  bool ZeroBaseShadow = false);
74 
75 // Insert MemorySanitizer instrumentation (detection of uninitialized reads)
76 FunctionPass *createMemorySanitizerPass(bool TrackOrigins = false,
77  StringRef BlacklistFile = StringRef());
78 
79 // Insert ThreadSanitizer (race detection) instrumentation
81 
82 // Insert DataFlowSanitizer (dynamic data flow analysis) instrumentation
84  void *(*getArgTLS)() = 0,
85  void *(*getRetValTLS)() = 0);
86 
87 #if defined(__GNUC__) && defined(__linux__)
88 inline ModulePass *createDataFlowSanitizerPassForJIT(StringRef ABIListFile =
89  StringRef()) {
90  return createDataFlowSanitizerPass(ABIListFile, getDFSanArgTLSPtrForJIT,
91  getDFSanRetValTLSPtrForJIT);
92 }
93 #endif
94 
95 // BoundsChecking - This pass instruments the code to perform run-time bounds
96 // checking on loads, stores, and other memory intrinsics.
97 FunctionPass *createBoundsCheckingPass();
98 
99 /// createDebugIRPass - Enable interactive stepping through LLVM IR in LLDB (or
100 /// GDB) and generate a file with the LLVM IR to be
101 /// displayed in the debugger.
102 ///
103 /// Existing debug metadata is preserved (but may be modified) in order to allow
104 /// accessing variables in the original source. The line table and file
105 /// information is modified to correspond to the lines in the LLVM IR. If
106 /// Filename and Directory are empty, a file name is generated based on existing
107 /// debug information. If no debug information is available, a temporary file
108 /// name is generated.
109 ///
110 /// @param HideDebugIntrinsics Omit debug intrinsics in emitted IR source file.
111 /// @param HideDebugMetadata Omit debug metadata in emitted IR source file.
112 /// @param Directory Embed this directory in the debug information.
113 /// @param Filename Embed this file name in the debug information.
114 ModulePass *createDebugIRPass(bool HideDebugIntrinsics,
115  bool HideDebugMetadata,
116  StringRef Directory = StringRef(),
117  StringRef Filename = StringRef());
118 
119 /// createDebugIRPass - Enable interactive stepping through LLVM IR in LLDB
120 /// (or GDB) with an existing IR file on disk. When creating
121 /// a DebugIR pass with this function, no source file is
122 /// output to disk and the existing one is unmodified. Debug
123 /// metadata in the Module is created/updated to point to
124 /// the existing textual IR file on disk.
125 /// NOTE: If the IR file to be debugged is not on disk, use the version of this
126 /// function with parameters in order to generate the file that will be
127 /// seen by the debugger.
128 ModulePass *createDebugIRPass();
129 
130 } // End llvm namespace
131 
132 #endif
FunctionPass * createBoundsCheckingPass()
static GCOVOptions getDefault()
ModulePass * createGCOVProfilerPass(const GCOVOptions &Options=GCOVOptions::getDefault())
ModulePass * createAddressSanitizerModulePass(bool CheckInitOrder=true, StringRef BlacklistFile=StringRef(), bool ZeroBaseShadow=false)
ModulePass * createDebugIRPass(bool HideDebugIntrinsics, bool HideDebugMetadata, StringRef Directory=StringRef(), StringRef Filename=StringRef())
Definition: DebugIR.cpp:611
always inline
ModulePass * createDataFlowSanitizerPass(StringRef ABIListFile=StringRef(), void *(*getArgTLS)()=0, void *(*getRetValTLS)()=0)
FunctionPass * createAddressSanitizerFunctionPass(bool CheckInitOrder=true, bool CheckUseAfterReturn=false, bool CheckLifetime=false, StringRef BlacklistFile=StringRef(), bool ZeroBaseShadow=false)
FunctionPass * createThreadSanitizerPass(StringRef BlacklistFile=StringRef())
void *__dso_handle __attribute__((__visibility__("hidden")))
FunctionPass * createMemorySanitizerPass(bool TrackOrigins=false, StringRef BlacklistFile=StringRef())