OSDN Git Service

bdc79b1a452443d8dd5b68ec6c5b07607e49fc99
[android-x86/external-llvm.git] / include / llvm / Transforms / Instrumentation / SanitizerCoverage.h
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/Function.h"
20 #include "llvm/IR/Module.h"
21 #include "llvm/IR/PassManager.h"
22 #include "llvm/Transforms/Instrumentation.h"
23
24 namespace llvm {
25
26 /// This is the SanitizerCoverage pass used in the new pass manager. The
27 /// pass instruments functions for coverage.
28 class SanitizerCoveragePass : public PassInfoMixin<SanitizerCoveragePass> {
29 public:
30   explicit SanitizerCoveragePass(
31       SanitizerCoverageOptions Options = SanitizerCoverageOptions())
32       : Options(Options) {}
33   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
34
35 private:
36   SanitizerCoverageOptions Options;
37 };
38
39 /// This is the ModuleSanitizerCoverage pass used in the new pass manager. This
40 /// adds initialization calls to the module for trace PC guards and 8bit
41 /// counters if they are requested.
42 class ModuleSanitizerCoveragePass
43     : public PassInfoMixin<ModuleSanitizerCoveragePass> {
44 public:
45   explicit ModuleSanitizerCoveragePass(
46       SanitizerCoverageOptions Options = SanitizerCoverageOptions())
47       : Options(Options) {}
48   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
49
50 private:
51   SanitizerCoverageOptions Options;
52 };
53
54 // Insert SanitizerCoverage instrumentation.
55 FunctionPass *createSanitizerCoverageLegacyPassPass(
56     const SanitizerCoverageOptions &Options = SanitizerCoverageOptions());
57 ModulePass *createModuleSanitizerCoverageLegacyPassPass(
58     const SanitizerCoverageOptions &Options = SanitizerCoverageOptions());
59
60 } // namespace llvm
61
62 #endif