LLVM  15.0.0git
AddressSanitizer.h
Go to the documentation of this file.
1 //===--------- Definition of the AddressSanitizer 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 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"
18 
19 namespace llvm {
20 class Module;
21 class raw_ostream;
22 
24  bool CompileKernel = false;
25  bool Recover = false;
26  bool UseAfterScope = false;
29 };
30 
31 /// Public interface to the address sanitizer module pass for instrumenting code
32 /// to check for various memory errors.
33 ///
34 /// This adds 'asan.module_ctor' to 'llvm.global_ctors'. This pass may also
35 /// run intependently of the function address sanitizer.
37  : public PassInfoMixin<ModuleAddressSanitizerPass> {
38 public:
40  const AddressSanitizerOptions &Options, bool UseGlobalGC = true,
41  bool UseOdrIndicator = false,
42  AsanDtorKind DestructorKind = AsanDtorKind::Global);
44  void printPipeline(raw_ostream &OS,
45  function_ref<StringRef(StringRef)> MapClassName2PassName);
46  static bool isRequired() { return true; }
47 
48 private:
50  bool UseGlobalGC;
51  bool UseOdrIndicator;
52  AsanDtorKind DestructorKind;
53 };
54 
56  const int32_t Packed;
57  const uint8_t AccessSizeIndex;
58  const bool IsWrite;
59  const bool CompileKernel;
60 
61  explicit ASanAccessInfo(int32_t Packed);
63 };
64 
65 } // namespace llvm
66 
67 #endif
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
M
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Definition: README.txt:252
llvm::PassInfoMixin
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition: PassManager.h:371
llvm::AsanDetectStackUseAfterReturnMode::Runtime
@ Runtime
Detect stack use after return if not disabled runtime with (ASAN_OPTIONS=detect_stack_use_after_retur...
llvm::ASanAccessInfo::AccessSizeIndex
const uint8_t AccessSizeIndex
Definition: AddressSanitizer.h:57
llvm::ModuleAddressSanitizerPass
Public interface to the address sanitizer module pass for instrumenting code to check for various mem...
Definition: AddressSanitizer.h:36
llvm::ModuleAddressSanitizerPass::printPipeline
void printPipeline(raw_ostream &OS, function_ref< StringRef(StringRef)> MapClassName2PassName)
Definition: AddressSanitizer.cpp:1113
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
llvm::function_ref
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLFunctionalExtras.h:36
llvm::AsanDetectStackUseAfterReturnMode
AsanDetectStackUseAfterReturnMode
Mode of ASan detect stack use after return.
Definition: AddressSanitizerOptions.h:23
llvm::ASanAccessInfo::Packed
const int32_t Packed
Definition: AddressSanitizer.h:56
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
llvm::AddressSanitizerOptions::Recover
bool Recover
Definition: AddressSanitizer.h:25
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::ASanAccessInfo::ASanAccessInfo
ASanAccessInfo(int32_t Packed)
Definition: AddressSanitizer.cpp:600
llvm::ASanAccessInfo::IsWrite
const bool IsWrite
Definition: AddressSanitizer.h:58
llvm::ASanAccessInfo
Definition: AddressSanitizer.h:55
llvm::AsanDtorKind
AsanDtorKind
Types of ASan module destructors supported.
Definition: AddressSanitizerOptions.h:16
llvm::ASanAccessInfo::CompileKernel
const bool CompileKernel
Definition: AddressSanitizer.h:59
llvm::AsanDtorKind::Global
@ Global
Append to llvm.global_dtors.
PassManager.h
AddressSanitizerOptions.h
llvm::ModuleAddressSanitizerPass::run
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
Definition: AddressSanitizer.cpp:1129
llvm::AddressSanitizerOptions::UseAfterScope
bool UseAfterScope
Definition: AddressSanitizer.h:26
llvm::ModuleAddressSanitizerPass::isRequired
static bool isRequired()
Definition: AddressSanitizer.h:46
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition: InstructionSimplify.h:42
llvm::AddressSanitizerOptions::UseAfterReturn
AsanDetectStackUseAfterReturnMode UseAfterReturn
Definition: AddressSanitizer.h:27
llvm::ModuleAddressSanitizerPass::ModuleAddressSanitizerPass
ModuleAddressSanitizerPass(const AddressSanitizerOptions &Options, bool UseGlobalGC=true, bool UseOdrIndicator=false, AsanDtorKind DestructorKind=AsanDtorKind::Global)
Definition: AddressSanitizer.cpp:1123
llvm::AddressSanitizerOptions::CompileKernel
bool CompileKernel
Definition: AddressSanitizer.h:24
llvm::AddressSanitizerOptions
Definition: AddressSanitizer.h:23