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 Module;
21 class StringRef;
22 class raw_ostream;
23 
31  bool CompileKernel;
32  bool Recover;
34 };
35 
36 /// This is a public interface to the hardware address sanitizer pass for
37 /// instrumenting code to check for various memory errors at runtime, similar to
38 /// AddressSanitizer but based on partial hardware assistance.
39 class HWAddressSanitizerPass : public PassInfoMixin<HWAddressSanitizerPass> {
40 public:
42  : Options(Options){};
44  static bool isRequired() { return true; }
45  void printPipeline(raw_ostream &OS,
46  function_ref<StringRef(StringRef)> MapClassName2PassName);
47 
48 private:
50 };
51 
52 namespace HWASanAccessInfo {
53 
54 // Bit field positions for the accessinfo parameter to
55 // llvm.hwasan.check.memaccess. Shared between the pass and the backend. Bits
56 // 0-15 are also used by the runtime.
57 enum {
58  AccessSizeShift = 0, // 4 bits
61  MatchAllShift = 16, // 8 bits
64 };
65 
66 enum { RuntimeMask = 0xffff };
67 
68 } // namespace HWASanAccessInfo
69 
70 } // namespace llvm
71 
72 #endif
llvm::HWAddressSanitizerPass::HWAddressSanitizerPass
HWAddressSanitizerPass(HWAddressSanitizerOptions Options)
Definition: HWAddressSanitizer.h:41
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:44
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:33
llvm::HWAddressSanitizerPass
This is a public interface to the hardware address sanitizer pass for instrumenting code to check for...
Definition: HWAddressSanitizer.h:39
llvm::HWAddressSanitizerOptions::HWAddressSanitizerOptions
HWAddressSanitizerOptions()
Definition: HWAddressSanitizer.h:25
llvm::HWASanAccessInfo::RecoverShift
@ RecoverShift
Definition: HWAddressSanitizer.h:60
llvm::HWASanAccessInfo::IsWriteShift
@ IsWriteShift
Definition: HWAddressSanitizer.h:59
llvm::HWAddressSanitizerOptions::CompileKernel
bool CompileKernel
Definition: HWAddressSanitizer.h:30
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:61
llvm::HWASanAccessInfo::RuntimeMask
@ RuntimeMask
Definition: HWAddressSanitizer.h:66
llvm::HWAddressSanitizerPass::run
PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM)
Definition: HWAddressSanitizer.cpp:414
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:32
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:24
llvm::HWASanAccessInfo::AccessSizeShift
@ AccessSizeShift
Definition: HWAddressSanitizer.h:58
PassManager.h
llvm::HWASanAccessInfo::HasMatchAllShift
@ HasMatchAllShift
Definition: HWAddressSanitizer.h:62
llvm::HWAddressSanitizerPass::printPipeline
void printPipeline(raw_ostream &OS, function_ref< StringRef(StringRef)> MapClassName2PassName)
Definition: HWAddressSanitizer.cpp:430
llvm::HWASanAccessInfo::CompileKernelShift
@ CompileKernelShift
Definition: HWAddressSanitizer.h:63
llvm::HWAddressSanitizerOptions::HWAddressSanitizerOptions
HWAddressSanitizerOptions(bool CompileKernel, bool Recover, bool DisableOptimization)
Definition: HWAddressSanitizer.h:27
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition: InstructionSimplify.h:42