LLVM  15.0.0git
SanitizerCoverage.h
Go to the documentation of this file.
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/PassManager.h"
23 
24 namespace llvm {
25 class Module;
26 class ModulePass;
27 
28 /// This is the ModuleSanitizerCoverage pass used in the new pass manager. The
29 /// pass instruments functions for coverage, adds initialization calls to the
30 /// module for trace PC guards and 8bit counters if they are requested, and
31 /// appends globals to llvm.compiler.used.
33  : public PassInfoMixin<ModuleSanitizerCoveragePass> {
34 public:
37  const std::vector<std::string> &AllowlistFiles =
38  std::vector<std::string>(),
39  const std::vector<std::string> &BlocklistFiles =
40  std::vector<std::string>())
41  : Options(Options) {
42  if (AllowlistFiles.size() > 0)
43  Allowlist = SpecialCaseList::createOrDie(AllowlistFiles,
45  if (BlocklistFiles.size() > 0)
46  Blocklist = SpecialCaseList::createOrDie(BlocklistFiles,
48  }
50  static bool isRequired() { return true; }
51 
52 private:
54 
55  std::unique_ptr<SpecialCaseList> Allowlist;
56  std::unique_ptr<SpecialCaseList> Blocklist;
57 };
58 
59 // Insert SanitizerCoverage instrumentation.
61  const SanitizerCoverageOptions &Options = SanitizerCoverageOptions(),
62  const std::vector<std::string> &AllowlistFiles = std::vector<std::string>(),
63  const std::vector<std::string> &BlocklistFiles =
64  std::vector<std::string>());
65 
66 } // namespace llvm
67 
68 #endif
llvm::PreservedAnalyses
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:152
Instrumentation.h
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::ModuleSanitizerCoveragePass
This is the ModuleSanitizerCoverage pass used in the new pass manager.
Definition: SanitizerCoverage.h:32
llvm::SanitizerCoverageOptions
Definition: Instrumentation.h:141
llvm::PassInfoMixin
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition: PassManager.h:371
llvm::ModuleSanitizerCoveragePass::run
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
Definition: SanitizerCoverage.cpp:330
Options
const char LLVMTargetMachineRef LLVMPassBuilderOptionsRef Options
Definition: PassBuilderBindings.cpp:48
llvm::vfs::getRealFileSystem
IntrusiveRefCntPtr< FileSystem > getRealFileSystem()
Gets an vfs::FileSystem for the 'real' file system, as seen by the operating system.
Definition: VirtualFileSystem.cpp:376
llvm::SpecialCaseList::createOrDie
static std::unique_ptr< SpecialCaseList > createOrDie(const std::vector< std::string > &Paths, llvm::vfs::FileSystem &FS)
Parses the special case list entries from files.
Definition: SpecialCaseList.cpp:90
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
Module
Machine Check Debug Module
Definition: MachineCheckDebugify.cpp:122
VirtualFileSystem.h
llvm::ModuleSanitizerCoveragePass::ModuleSanitizerCoveragePass
ModuleSanitizerCoveragePass(SanitizerCoverageOptions Options=SanitizerCoverageOptions(), const std::vector< std::string > &AllowlistFiles=std::vector< std::string >(), const std::vector< std::string > &BlocklistFiles=std::vector< std::string >())
Definition: SanitizerCoverage.h:35
PassManager.h
SpecialCaseList.h
llvm::ModuleSanitizerCoveragePass::isRequired
static bool isRequired()
Definition: SanitizerCoverage.h:50
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition: InstructionSimplify.h:42
llvm::createModuleSanitizerCoverageLegacyPassPass
ModulePass * createModuleSanitizerCoverageLegacyPassPass(const SanitizerCoverageOptions &Options=SanitizerCoverageOptions(), const std::vector< std::string > &AllowlistFiles=std::vector< std::string >(), const std::vector< std::string > &BlocklistFiles=std::vector< std::string >())
Definition: SanitizerCoverage.cpp:1088