1 //===--------- Definition of the SanitizerCoverage class --------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
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
9 //===----------------------------------------------------------------------===//
11 // This file declares the SanitizerCoverage class which is a port of the legacy
12 // SanitizerCoverage pass to use the new PassManager infrastructure.
14 //===----------------------------------------------------------------------===//
16 #ifndef LLVM_TRANSFORMS_INSTRUMENTATION_SANITIZERCOVERAGE_H
17 #define LLVM_TRANSFORMS_INSTRUMENTATION_SANITIZERCOVERAGE_H
19 #include "llvm/IR/Function.h"
20 #include "llvm/IR/Module.h"
21 #include "llvm/IR/PassManager.h"
22 #include "llvm/Transforms/Instrumentation.h"
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> {
30 explicit SanitizerCoveragePass(
31 SanitizerCoverageOptions Options = SanitizerCoverageOptions())
33 PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
36 SanitizerCoverageOptions Options;
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> {
45 explicit ModuleSanitizerCoveragePass(
46 SanitizerCoverageOptions Options = SanitizerCoverageOptions())
48 PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
51 SanitizerCoverageOptions Options;
54 // Insert SanitizerCoverage instrumentation.
55 FunctionPass *createSanitizerCoverageLegacyPassPass(
56 const SanitizerCoverageOptions &Options = SanitizerCoverageOptions());
57 ModulePass *createModuleSanitizerCoverageLegacyPassPass(
58 const SanitizerCoverageOptions &Options = SanitizerCoverageOptions());