LLVM  14.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 
16 #include "llvm/IR/Function.h"
17 #include "llvm/IR/PassManager.h"
18 
19 namespace llvm {
20 
28  bool CompileKernel;
29  bool Recover;
31 };
32 
33 /// This is a public interface to the hardware address sanitizer pass for
34 /// instrumenting code to check for various memory errors at runtime, similar to
35 /// AddressSanitizer but based on partial hardware assistance.
36 class HWAddressSanitizerPass : public PassInfoMixin<HWAddressSanitizerPass> {
37 public:
39  : Options(Options){};
41  static bool isRequired() { return true; }
42  void printPipeline(raw_ostream &OS,
43  function_ref<StringRef(StringRef)> MapClassName2PassName);
44 
45 private:
47 };
48 
49 FunctionPass *
50 createHWAddressSanitizerLegacyPassPass(bool CompileKernel = false,
51  bool Recover = false,
52  bool DisableOptimization = false);
53 
54 namespace HWASanAccessInfo {
55 
56 // Bit field positions for the accessinfo parameter to
57 // llvm.hwasan.check.memaccess. Shared between the pass and the backend. Bits
58 // 0-15 are also used by the runtime.
59 enum {
60  AccessSizeShift = 0, // 4 bits
63  MatchAllShift = 16, // 8 bits
66 };
67 
68 enum { RuntimeMask = 0xffff };
69 
70 } // namespace HWASanAccessInfo
71 
72 } // namespace llvm
73 
74 #endif
llvm::HWAddressSanitizerPass::HWAddressSanitizerPass
HWAddressSanitizerPass(HWAddressSanitizerOptions Options)
Definition: HWAddressSanitizer.h:38
llvm::PreservedAnalyses
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:155
llvm
This file implements support for optimizing divisions by a constant.
Definition: AllocatorList.h:23
llvm::HWAddressSanitizerPass::isRequired
static bool isRequired()
Definition: HWAddressSanitizer.h:41
llvm::PassInfoMixin
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition: PassManager.h:374
llvm::HWAddressSanitizerOptions::DisableOptimization
bool DisableOptimization
Definition: HWAddressSanitizer.h:30
llvm::HWAddressSanitizerPass
This is a public interface to the hardware address sanitizer pass for instrumenting code to check for...
Definition: HWAddressSanitizer.h:36
llvm::HWASanAccessInfo::IsWriteShift
@ IsWriteShift
Definition: HWAddressSanitizer.h:61
llvm::createHWAddressSanitizerLegacyPassPass
FunctionPass * createHWAddressSanitizerLegacyPassPass(bool CompileKernel=false, bool Recover=false, bool DisableOptimization=false)
Definition: HWAddressSanitizer.cpp:482
llvm::HWASanAccessInfo::RecoverShift
@ RecoverShift
Definition: HWAddressSanitizer.h:62
llvm::HWASanAccessInfo::HasMatchAllShift
@ HasMatchAllShift
Definition: HWAddressSanitizer.h:64
llvm::HWAddressSanitizerOptions::HWAddressSanitizerOptions
HWAddressSanitizerOptions()
Definition: HWAddressSanitizer.h:22
llvm::HWASanAccessInfo::MatchAllShift
@ MatchAllShift
Definition: HWAddressSanitizer.h:63
llvm::HWAddressSanitizerOptions::CompileKernel
bool CompileKernel
Definition: HWAddressSanitizer.h:27
MAM
ModuleAnalysisManager MAM
Definition: PassBuilderBindings.cpp:61
false
Definition: StackSlotColoring.cpp:142
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:53
llvm::function_ref
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLExtras.h:168
llvm::HWASanAccessInfo::AccessSizeShift
@ AccessSizeShift
Definition: HWAddressSanitizer.h:60
llvm::HWAddressSanitizerPass::run
PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM)
Definition: HWAddressSanitizer.cpp:489
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:67
llvm::HWAddressSanitizerOptions::Recover
bool Recover
Definition: HWAddressSanitizer.h:29
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::HWAddressSanitizerOptions
Definition: HWAddressSanitizer.h:21
Function.h
PassManager.h
llvm::HWASanAccessInfo::RuntimeMask
@ RuntimeMask
Definition: HWAddressSanitizer.h:68
llvm::HWAddressSanitizerPass::printPipeline
void printPipeline(raw_ostream &OS, function_ref< StringRef(StringRef)> MapClassName2PassName)
Definition: HWAddressSanitizer.cpp:513
llvm::HWAddressSanitizerOptions::HWAddressSanitizerOptions
HWAddressSanitizerOptions(bool CompileKernel, bool Recover, bool DisableOptimization)
Definition: HWAddressSanitizer.h:24
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition: InstructionSimplify.h:44
llvm::HWASanAccessInfo::CompileKernelShift
@ CompileKernelShift
Definition: HWAddressSanitizer.h:65