1 //===--------- Definition of the SanitizerCoverage class --------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
6 // See https://llvm.org/LICENSE.txt for license information.
7 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //
9 //===----------------------------------------------------------------------===//
10 //
11 // This file declares the SanitizerCoverage class which is a port of the legacy
12 // SanitizerCoverage pass to use the new PassManager infrastructure.
13 //
14 //===----------------------------------------------------------------------===//
15 
16 #ifndef LLVM_TRANSFORMS_INSTRUMENTATION_SANITIZERCOVERAGE_H
17 #define LLVM_TRANSFORMS_INSTRUMENTATION_SANITIZERCOVERAGE_H
18 
19 #include "llvm/IR/Module.h"
20 #include "llvm/IR/PassManager.h"
21 #include "llvm/Transforms/Instrumentation.h"
22 
23 namespace llvm {
24 
25 /// This is the ModuleSanitizerCoverage pass used in the new pass manager. The
26 /// pass instruments functions for coverage, adds initialization calls to the
27 /// module for trace PC guards and 8bit counters if they are requested, and
28 /// appends globals to llvm.compiler.used.
29 class ModuleSanitizerCoveragePass
30     : public PassInfoMixin<ModuleSanitizerCoveragePass> {
31 public:
32   explicit ModuleSanitizerCoveragePass(
33       SanitizerCoverageOptions Options = SanitizerCoverageOptions())
34       : Options(Options) {}
35   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
36 
37 private:
38   SanitizerCoverageOptions Options;
39 };
40 
41 // Insert SanitizerCoverage instrumentation.
42 ModulePass *createModuleSanitizerCoverageLegacyPassPass(
43     const SanitizerCoverageOptions &Options = SanitizerCoverageOptions());
44 
45 } // namespace llvm
46 
47 #endif
48