LLVM 22.0.0git
AddressSanitizer.h
Go to the documentation of this file.
1//===- AddressSanitizer.h - AddressSanitizer instrumentation ----*- 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 AddressSanitizer class which is a port of the legacy
10// AddressSanitizer pass to use the new PassManager infrastructure.
11//
12//===----------------------------------------------------------------------===//
13#ifndef LLVM_TRANSFORMS_INSTRUMENTATION_ADDRESSSANITIZER_H
14#define LLVM_TRANSFORMS_INSTRUMENTATION_ADDRESSSANITIZER_H
15
16#include "llvm/IR/PassManager.h"
19
20namespace llvm {
21class Module;
22class raw_ostream;
23
25 bool CompileKernel = false;
26 bool Recover = false;
27 bool UseAfterScope = false;
32 bool InsertVersionCheck = true;
33};
34
35/// Public interface to the address sanitizer module pass for instrumenting code
36/// to check for various memory errors.
37///
38/// This adds 'asan.module_ctor' to 'llvm.global_ctors'. This pass may also
39/// run intependently of the function address sanitizer.
40class AddressSanitizerPass : public PassInfoMixin<AddressSanitizerPass> {
41public:
44 bool UseGlobalGC = true, bool UseOdrIndicator = true,
45 AsanDtorKind DestructorKind = AsanDtorKind::Global,
46 AsanCtorKind ConstructorKind = AsanCtorKind::Global);
48 LLVM_ABI void
50 function_ref<StringRef(StringRef)> MapClassName2PassName);
51 static bool isRequired() { return true; }
52
53private:
55 bool UseGlobalGC;
56 bool UseOdrIndicator;
57 AsanDtorKind DestructorKind;
58 AsanCtorKind ConstructorKind;
59};
60
62 const int32_t Packed;
64 const bool IsWrite;
65 const bool CompileKernel;
66
67 LLVM_ABI explicit ASanAccessInfo(int32_t Packed);
70};
71
72} // namespace llvm
73
74#endif
#define LLVM_ABI
Definition: Compiler.h:213
This header defines various interfaces for pass management in LLVM.
Machine Check Debug Module
raw_pwrite_stream & OS
Public interface to the address sanitizer module pass for instrumenting code to check for various mem...
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
LLVM_ABI void printPipeline(raw_ostream &OS, function_ref< StringRef(StringRef)> MapClassName2PassName)
A container for analyses that lazily runs them and caches their results.
Definition: PassManager.h:255
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:67
A set of analyses that are preserved following a run of a transformation pass.
Definition: Analysis.h:112
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
An efficient, type-erasing, non-owning reference to a callable.
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
AsanDetectStackUseAfterReturnMode
Mode of ASan detect stack use after return.
@ Runtime
Detect stack use after return if not disabled runtime with (ASAN_OPTIONS=detect_stack_use_after_retur...
AsanDtorKind
Types of ASan module destructors supported.
@ Global
Append to llvm.global_dtors.
AsanCtorKind
Types of ASan module constructors supported.
const uint8_t AccessSizeIndex
AsanDetectStackUseAfterReturnMode UseAfterReturn
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition: PassManager.h:70