LLVM 17.0.0git
MemoryTaggingSupport.h
Go to the documentation of this file.
1//===- MemoryTaggingSupport.h - helpers for memory tagging implementations ===//
2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
3// See https://llvm.org/LICENSE.txt for license information.
4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5//
6//===----------------------------------------------------------------------===//
7//
8// This file declares common infrastructure for HWAddressSanitizer and
9// Aarch64StackTagging.
10//
11//===----------------------------------------------------------------------===//
12#ifndef LLVM_TRANSFORMS_UTILS_MEMORYTAGGINGSUPPORT_H
13#define LLVM_TRANSFORMS_UTILS_MEMORYTAGGINGSUPPORT_H
14
15#include "llvm/ADT/MapVector.h"
21
22namespace llvm {
23class DominatorTree;
24class DbgVariableIntrinsic;
25class IntrinsicInst;
26class PostDominatorTree;
27class AllocaInst;
28class Instruction;
29namespace memtag {
30// For an alloca valid between lifetime markers Start and Ends, call the
31// Callback for all possible exits out of the lifetime in the containing
32// function, which can return from the instructions in RetVec.
33//
34// Returns whether Ends covered all possible exits. If they did not,
35// the caller should remove Ends to ensure that work done at the other
36// exits does not happen outside of the lifetime.
38 const LoopInfo &LI, const Instruction *Start,
41 llvm::function_ref<void(Instruction *)> Callback);
42
44 const SmallVectorImpl<IntrinsicInst *> &LifetimeEnd,
45 const DominatorTree *DT, const LoopInfo *LI,
46 size_t MaxLifetimes);
47
49
50struct AllocaInfo {
55};
56
57struct StackInfo {
61 bool CallsReturnTwice = false;
62};
63
65public:
66 StackInfoBuilder(const StackSafetyGlobalInfo *SSI) : SSI(SSI) {}
67
68 void visit(Instruction &Inst);
69 bool isInterestingAlloca(const AllocaInst &AI);
70 StackInfo &get() { return Info; };
71
72private:
73 StackInfo Info;
74 const StackSafetyGlobalInfo *SSI;
75};
76
79
80} // namespace memtag
81} // namespace llvm
82
83#endif
Analysis containing CSE Info
Definition: CSEInfo.cpp:27
This file implements a map that provides insertion order iteration.
This file defines the SmallVector class.
an instruction to allocate memory on the stack
Definition: Instructions.h:58
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Definition: Dominators.h:166
This class implements a map that also provides access to all stored values in a deterministic order.
Definition: MapVector.h:37
PostDominatorTree Class - Concrete subclass of DominatorTree that is used to compute the post-dominat...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:577
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1200
An efficient, type-erasing, non-owning reference to a callable.
bool isInterestingAlloca(const AllocaInst &AI)
StackInfoBuilder(const StackSafetyGlobalInfo *SSI)
bool isStandardLifetime(const SmallVectorImpl< IntrinsicInst * > &LifetimeStart, const SmallVectorImpl< IntrinsicInst * > &LifetimeEnd, const DominatorTree *DT, const LoopInfo *LI, size_t MaxLifetimes)
bool forAllReachableExits(const DominatorTree &DT, const PostDominatorTree &PDT, const LoopInfo &LI, const Instruction *Start, const SmallVectorImpl< IntrinsicInst * > &Ends, const SmallVectorImpl< Instruction * > &RetVec, llvm::function_ref< void(Instruction *)> Callback)
uint64_t getAllocaSizeInBytes(const AllocaInst &AI)
Instruction * getUntagLocationIfFunctionExit(Instruction &Inst)
void alignAndPadAlloca(memtag::AllocaInfo &Info, llvm::Align Align)
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
SmallVector< DbgVariableIntrinsic *, 2 > DbgVariableIntrinsics
SmallVector< IntrinsicInst *, 2 > LifetimeEnd
SmallVector< IntrinsicInst *, 2 > LifetimeStart
MapVector< AllocaInst *, AllocaInfo > AllocasToInstrument
SmallVector< Instruction *, 4 > UnrecognizedLifetimes
SmallVector< Instruction *, 8 > RetVec