LLVM  15.0.0git
HWAddressSanitizer.h
Go to the documentation of this file.
1 //===--------- Definition of the HWAddressSanitizer class -------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file declares the Hardware AddressSanitizer class which is a port of the
10 // legacy HWAddressSanitizer pass to use the new PassManager infrastructure.
11 //
12 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_TRANSFORMS_INSTRUMENTATION_HWADDRESSSANITIZER_H
14 #define LLVM_TRANSFORMS_INSTRUMENTATION_HWADDRESSSANITIZER_H
15 
17 #include "llvm/IR/PassManager.h"
18 
19 namespace llvm {
20 class FunctionPass;
21 class Module;
22 class StringRef;
23 class raw_ostream;
24 
32  bool CompileKernel;
33  bool Recover;
35 };
36 
37 /// This is a public interface to the hardware address sanitizer pass for
38 /// instrumenting code to check for various memory errors at runtime, similar to
39 /// AddressSanitizer but based on partial hardware assistance.
40 class HWAddressSanitizerPass : public PassInfoMixin<HWAddressSanitizerPass> {
41 public:
43  : Options(Options){};
45  static bool isRequired() { return true; }
46  void printPipeline(raw_ostream &OS,
47  function_ref<StringRef(StringRef)> MapClassName2PassName);
48 
49 private:
51 };
52 
53 namespace HWASanAccessInfo {
54 
55 // Bit field positions for the accessinfo parameter to
56 // llvm.hwasan.check.memaccess. Shared between the pass and the backend. Bits
57 // 0-15 are also used by the runtime.
58 enum {
59  AccessSizeShift = 0, // 4 bits
62  MatchAllShift = 16, // 8 bits
65 };
66 
67 enum { RuntimeMask = 0xffff };
68 
69 } // namespace HWASanAccessInfo
70 
71 } // namespace llvm
72 
73 #endif
llvm::HWAddressSanitizerPass::HWAddressSanitizerPass
HWAddressSanitizerPass(HWAddressSanitizerOptions Options)
Definition: HWAddressSanitizer.h:42
llvm::PreservedAnalyses
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:152
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::HWAddressSanitizerPass::isRequired
static bool isRequired()
Definition: HWAddressSanitizer.h:45
llvm::PassInfoMixin
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition: PassManager.h:371
llvm::HWAddressSanitizerOptions::DisableOptimization
bool DisableOptimization
Definition: HWAddressSanitizer.h:34
llvm::HWAddressSanitizerPass
This is a public interface to the hardware address sanitizer pass for instrumenting code to check for...
Definition: HWAddressSanitizer.h:40
llvm::HWAddressSanitizerOptions::HWAddressSanitizerOptions
HWAddressSanitizerOptions()
Definition: HWAddressSanitizer.h:26
llvm::HWASanAccessInfo::RecoverShift
@ RecoverShift
Definition: HWAddressSanitizer.h:61
llvm::HWASanAccessInfo::IsWriteShift
@ IsWriteShift
Definition: HWAddressSanitizer.h:60
llvm::HWAddressSanitizerOptions::CompileKernel
bool CompileKernel
Definition: HWAddressSanitizer.h:31
MAM
ModuleAnalysisManager MAM
Definition: PassBuilderBindings.cpp:61
false
Definition: StackSlotColoring.cpp:141
Options
const char LLVMTargetMachineRef LLVMPassBuilderOptionsRef Options
Definition: PassBuilderBindings.cpp:48
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:54
STLFunctionalExtras.h
llvm::function_ref
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLFunctionalExtras.h:36
llvm::HWASanAccessInfo::MatchAllShift
@ MatchAllShift
Definition: HWAddressSanitizer.h:62
llvm::HWASanAccessInfo::RuntimeMask
@ RuntimeMask
Definition: HWAddressSanitizer.h:67
llvm::HWAddressSanitizerPass::run
PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM)
Definition: HWAddressSanitizer.cpp:388
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
llvm::HWAddressSanitizerOptions::Recover
bool Recover
Definition: HWAddressSanitizer.h:33
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
Module
Machine Check Debug Module
Definition: MachineCheckDebugify.cpp:122
llvm::HWAddressSanitizerOptions
Definition: HWAddressSanitizer.h:25
llvm::HWASanAccessInfo::AccessSizeShift
@ AccessSizeShift
Definition: HWAddressSanitizer.h:59
PassManager.h
llvm::HWASanAccessInfo::HasMatchAllShift
@ HasMatchAllShift
Definition: HWAddressSanitizer.h:63
llvm::HWAddressSanitizerPass::printPipeline
void printPipeline(raw_ostream &OS, function_ref< StringRef(StringRef)> MapClassName2PassName)
Definition: HWAddressSanitizer.cpp:404
llvm::HWASanAccessInfo::CompileKernelShift
@ CompileKernelShift
Definition: HWAddressSanitizer.h:64
llvm::HWAddressSanitizerOptions::HWAddressSanitizerOptions
HWAddressSanitizerOptions(bool CompileKernel, bool Recover, bool DisableOptimization)
Definition: HWAddressSanitizer.h:28
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition: InstructionSimplify.h:42