Home | History | Annotate | Download | only in Transforms
      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 namespace llvm {
     20 
     21 class ModulePass;
     22 class FunctionPass;
     23 
     24 // Insert edge profiling instrumentation
     25 ModulePass *createEdgeProfilerPass();
     26 
     27 // Insert optimal edge profiling instrumentation
     28 ModulePass *createOptimalEdgeProfilerPass();
     29 
     30 // Insert path profiling instrumentation
     31 ModulePass *createPathProfilerPass();
     32 
     33 // Insert GCOV profiling instrumentation
     34 struct GCOVOptions {
     35   static GCOVOptions getDefault();
     36 
     37   // Specify whether to emit .gcno files.
     38   bool EmitNotes;
     39 
     40   // Specify whether to modify the program to emit .gcda files when run.
     41   bool EmitData;
     42 
     43   // A four-byte version string. The meaning of a version string is described in
     44   // gcc's gcov-io.h
     45   char Version[4];
     46 
     47   // Emit a "cfg checksum" that follows the "line number checksum" of a
     48   // function. This affects both .gcno and .gcda files.
     49   bool UseCfgChecksum;
     50 
     51   // Add the 'noredzone' attribute to added runtime library calls.
     52   bool NoRedZone;
     53 
     54   // Emit the name of the function in the .gcda files. This is redundant, as
     55   // the function identifier can be used to find the name from the .gcno file.
     56   bool FunctionNamesInData;
     57 };
     58 ModulePass *createGCOVProfilerPass(const GCOVOptions &Options =
     59                                    GCOVOptions::getDefault());
     60 
     61 // Insert AddressSanitizer (address sanity checking) instrumentation
     62 FunctionPass *createAddressSanitizerFunctionPass(
     63     bool CheckInitOrder = true, bool CheckUseAfterReturn = false,
     64     bool CheckLifetime = false, StringRef BlacklistFile = StringRef(),
     65     bool ZeroBaseShadow = false);
     66 ModulePass *createAddressSanitizerModulePass(
     67     bool CheckInitOrder = true, StringRef BlacklistFile = StringRef(),
     68     bool ZeroBaseShadow = false);
     69 
     70 // Insert MemorySanitizer instrumentation (detection of uninitialized reads)
     71 FunctionPass *createMemorySanitizerPass(bool TrackOrigins = false,
     72                                         StringRef BlacklistFile = StringRef());
     73 
     74 // Insert ThreadSanitizer (race detection) instrumentation
     75 FunctionPass *createThreadSanitizerPass(StringRef BlacklistFile = StringRef());
     76 
     77 // BoundsChecking - This pass instruments the code to perform run-time bounds
     78 // checking on loads, stores, and other memory intrinsics.
     79 FunctionPass *createBoundsCheckingPass();
     80 
     81 /// createDebugIRPass - Enable interactive stepping through LLVM IR in LLDB (or
     82 ///                     GDB) and generate a file with the LLVM IR to be
     83 ///                     displayed in the debugger.
     84 ///
     85 /// Existing debug metadata is preserved (but may be modified) in order to allow
     86 /// accessing variables in the original source. The line table and file
     87 /// information is modified to correspond to the lines in the LLVM IR. If
     88 /// Filename and Directory are empty, a file name is generated based on existing
     89 /// debug information. If no debug information is available, a temporary file
     90 /// name is generated.
     91 ///
     92 /// @param HideDebugIntrinsics  Omit debug intrinsics in emitted IR source file.
     93 /// @param HideDebugMetadata    Omit debug metadata in emitted IR source file.
     94 /// @param Directory            Embed this directory in the debug information.
     95 /// @param Filename             Embed this file name in the debug information.
     96 ModulePass *createDebugIRPass(bool HideDebugIntrinsics,
     97                               bool HideDebugMetadata,
     98                               StringRef Directory = StringRef(),
     99                               StringRef Filename = StringRef());
    100 
    101 /// createDebugIRPass - Enable interactive stepping through LLVM IR in LLDB
    102 ///                     (or GDB) with an existing IR file on disk. When creating
    103 ///                     a DebugIR pass with this function, no source file is
    104 ///                     output to disk and the existing one is unmodified. Debug
    105 ///                     metadata in the Module is created/updated to point to
    106 ///                     the existing textual IR file on disk.
    107 /// NOTE: If the IR file to be debugged is not on disk, use the version of this
    108 ///       function with parameters in order to generate the file that will be
    109 ///       seen by the debugger.
    110 ModulePass *createDebugIRPass();
    111 
    112 } // End llvm namespace
    113 
    114 #endif
    115