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 common infrastructure for AddressSanitizer and |
10 | // HWAddressSanitizer. |
11 | // |
12 | //===----------------------------------------------------------------------===// |
13 | #ifndef LLVM_TRANSFORMS_INSTRUMENTATION_ADDRESSSANITIZERCOMMON_H |
14 | #define LLVM_TRANSFORMS_INSTRUMENTATION_ADDRESSSANITIZERCOMMON_H |
15 | |
16 | #include "llvm/Analysis/CFG.h" |
17 | #include "llvm/Analysis/PostDominators.h" |
18 | #include "llvm/IR/Dominators.h" |
19 | #include "llvm/IR/Instruction.h" |
20 | #include "llvm/IR/IntrinsicInst.h" |
21 | #include "llvm/IR/Module.h" |
22 | |
23 | namespace llvm { |
24 | |
25 | class InterestingMemoryOperand { |
26 | public: |
27 | Use *PtrUse; |
28 | bool IsWrite; |
29 | Type *OpType; |
30 | TypeSize TypeStoreSize = TypeSize::getFixed(ExactSize: 0); |
31 | MaybeAlign Alignment; |
32 | // The mask Value, if we're looking at a masked load/store. |
33 | Value *MaybeMask; |
34 | // The EVL Value, if we're looking at a vp intrinsic. |
35 | Value *MaybeEVL; |
36 | // The Stride Value, if we're looking at a strided load/store. |
37 | Value *MaybeStride; |
38 | |
39 | InterestingMemoryOperand(Instruction *I, unsigned OperandNo, bool IsWrite, |
40 | class Type *OpType, MaybeAlign Alignment, |
41 | Value *MaybeMask = nullptr, |
42 | Value *MaybeEVL = nullptr, |
43 | Value *MaybeStride = nullptr) |
44 | : IsWrite(IsWrite), OpType(OpType), Alignment(Alignment), |
45 | MaybeMask(MaybeMask), MaybeEVL(MaybeEVL), MaybeStride(MaybeStride) { |
46 | const DataLayout &DL = I->getDataLayout(); |
47 | TypeStoreSize = DL.getTypeStoreSizeInBits(Ty: OpType); |
48 | PtrUse = &I->getOperandUse(i: OperandNo); |
49 | } |
50 | |
51 | Instruction *getInsn() { return cast<Instruction>(Val: PtrUse->getUser()); } |
52 | |
53 | Value *getPtr() { return PtrUse->get(); } |
54 | }; |
55 | |
56 | // Get AddressSanitizer parameters. |
57 | void getAddressSanitizerParams(const Triple &TargetTriple, int LongSize, |
58 | bool IsKasan, uint64_t *ShadowBase, |
59 | int *MappingScale, bool *OrShadowOffset); |
60 | |
61 | } // namespace llvm |
62 | |
63 | #endif |
64 | |