1//===--------- Definition of the HWAddressSanitizer class -------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file declares the Hardware AddressSanitizer class which is a port of the
11// legacy HWAddressSanitizer pass to use the new PassManager infrastructure.
12//
13//===----------------------------------------------------------------------===//
14#ifndef LLVM_TRANSFORMS_INSTRUMENTATION_HWADDRESSSANITIZER_H
15#define LLVM_TRANSFORMS_INSTRUMENTATION_HWADDRESSSANITIZER_H
16
17#include "llvm/IR/Function.h"
18#include "llvm/IR/PassManager.h"
19
20namespace llvm {
21
22/// This is a public interface to the hardware address sanitizer pass for
23/// instrumenting code to check for various memory errors at runtime, similar to
24/// AddressSanitizer but based on partial hardware assistance.
25class HWAddressSanitizerPass : public PassInfoMixin<HWAddressSanitizerPass> {
26public:
27 explicit HWAddressSanitizerPass(bool CompileKernel = false,
28 bool Recover = false);
29 PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
30 static bool isRequired() { return true; }
31
32private:
33 bool CompileKernel;
34 bool Recover;
35};
36
37FunctionPass *createHWAddressSanitizerLegacyPassPass(bool CompileKernel = false,
38 bool Recover = false);
39
40namespace HWASanAccessInfo {
41
42// Bit field positions for the accessinfo parameter to
43// llvm.hwasan.check.memaccess. Shared between the pass and the backend. Bits
44// 0-15 are also used by the runtime.
45enum {
46 AccessSizeShift = 0, // 4 bits
47 IsWriteShift = 4,
48 RecoverShift = 5,
49 MatchAllShift = 16, // 8 bits
50 HasMatchAllShift = 24,
51 CompileKernelShift = 25,
52};
53
54enum { RuntimeMask = 0xffff };
55
56} // namespace HWASanAccessInfo
57
58} // namespace llvm
59
60#endif
61