LLVM API Documentation

Instrumentation.h
Go to the documentation of this file.
00001 //===- Transforms/Instrumentation.h - Instrumentation passes ----*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file defines constructor functions for instrumentation passes.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #ifndef LLVM_TRANSFORMS_INSTRUMENTATION_H
00015 #define LLVM_TRANSFORMS_INSTRUMENTATION_H
00016 
00017 #include "llvm/ADT/StringRef.h"
00018 
00019 #if defined(__GNUC__) && defined(__linux__) && !defined(ANDROID)
00020 inline void *getDFSanArgTLSPtrForJIT() {
00021   extern __thread __attribute__((tls_model("initial-exec")))
00022     void *__dfsan_arg_tls;
00023   return (void *)&__dfsan_arg_tls;
00024 }
00025 
00026 inline void *getDFSanRetValTLSPtrForJIT() {
00027   extern __thread __attribute__((tls_model("initial-exec")))
00028     void *__dfsan_retval_tls;
00029   return (void *)&__dfsan_retval_tls;
00030 }
00031 #endif
00032 
00033 namespace llvm {
00034 
00035 class ModulePass;
00036 class FunctionPass;
00037 
00038 // Insert GCOV profiling instrumentation
00039 struct GCOVOptions {
00040   static GCOVOptions getDefault();
00041 
00042   // Specify whether to emit .gcno files.
00043   bool EmitNotes;
00044 
00045   // Specify whether to modify the program to emit .gcda files when run.
00046   bool EmitData;
00047 
00048   // A four-byte version string. The meaning of a version string is described in
00049   // gcc's gcov-io.h
00050   char Version[4];
00051 
00052   // Emit a "cfg checksum" that follows the "line number checksum" of a
00053   // function. This affects both .gcno and .gcda files.
00054   bool UseCfgChecksum;
00055 
00056   // Add the 'noredzone' attribute to added runtime library calls.
00057   bool NoRedZone;
00058 
00059   // Emit the name of the function in the .gcda files. This is redundant, as
00060   // the function identifier can be used to find the name from the .gcno file.
00061   bool FunctionNamesInData;
00062 };
00063 ModulePass *createGCOVProfilerPass(const GCOVOptions &Options =
00064                                    GCOVOptions::getDefault());
00065 
00066 /// Options for the frontend instrumentation based profiling pass.
00067 struct InstrProfOptions {
00068   InstrProfOptions() : NoRedZone(false) {}
00069 
00070   // Add the 'noredzone' attribute to added runtime library calls.
00071   bool NoRedZone;
00072 };
00073 
00074 /// Insert frontend instrumentation based profiling.
00075 ModulePass *createInstrProfilingPass(
00076     const InstrProfOptions &Options = InstrProfOptions());
00077 
00078 // Insert AddressSanitizer (address sanity checking) instrumentation
00079 FunctionPass *createAddressSanitizerFunctionPass();
00080 ModulePass *createAddressSanitizerModulePass();
00081 
00082 // Insert MemorySanitizer instrumentation (detection of uninitialized reads)
00083 FunctionPass *createMemorySanitizerPass(int TrackOrigins = 0);
00084 
00085 // Insert ThreadSanitizer (race detection) instrumentation
00086 FunctionPass *createThreadSanitizerPass();
00087 
00088 // Insert DataFlowSanitizer (dynamic data flow analysis) instrumentation
00089 ModulePass *createDataFlowSanitizerPass(StringRef ABIListFile = StringRef(),
00090                                         void *(*getArgTLS)() = nullptr,
00091                                         void *(*getRetValTLS)() = nullptr);
00092 
00093 // Insert SanitizerCoverage instrumentation.
00094 ModulePass *createSanitizerCoverageModulePass(int CoverageLevel);
00095 
00096 #if defined(__GNUC__) && defined(__linux__) && !defined(ANDROID)
00097 inline ModulePass *createDataFlowSanitizerPassForJIT(StringRef ABIListFile =
00098                                                          StringRef()) {
00099   return createDataFlowSanitizerPass(ABIListFile, getDFSanArgTLSPtrForJIT,
00100                                      getDFSanRetValTLSPtrForJIT);
00101 }
00102 #endif
00103 
00104 // BoundsChecking - This pass instruments the code to perform run-time bounds
00105 // checking on loads, stores, and other memory intrinsics.
00106 FunctionPass *createBoundsCheckingPass();
00107 
00108 } // End llvm namespace
00109 
00110 #endif