1//===--------- Definition of the AddressSanitizer 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 common infrastructure for AddressSanitizer and
11// HWAddressSanitizer.
12//
13//===----------------------------------------------------------------------===//
14#ifndef LLVM_TRANSFORMS_INSTRUMENTATION_ADDRESSSANITIZERCOMMON_H
15#define LLVM_TRANSFORMS_INSTRUMENTATION_ADDRESSSANITIZERCOMMON_H
16
17#include "llvm/IR/Instruction.h"
18#include "llvm/IR/Module.h"
19
20namespace llvm {
21
22class InterestingMemoryOperand {
23public:
24 Use *PtrUse;
25 bool IsWrite;
26 Type *OpType;
27 uint64_t TypeSize;
28 MaybeAlign Alignment;
29 // The mask Value, if we're looking at a masked load/store.
30 Value *MaybeMask;
31
32 InterestingMemoryOperand(Instruction *I, unsigned OperandNo, bool IsWrite,
33 class Type *OpType, MaybeAlign Alignment,
34 Value *MaybeMask = nullptr)
35 : IsWrite(IsWrite), OpType(OpType), Alignment(Alignment),
36 MaybeMask(MaybeMask) {
37 const DataLayout &DL = I->getModule()->getDataLayout();
38 TypeSize = DL.getTypeStoreSizeInBits(OpType);
39 PtrUse = &I->getOperandUse(OperandNo);
40 }
41
42 Instruction *getInsn() { return cast<Instruction>(PtrUse->getUser()); }
43
44 Value *getPtr() { return PtrUse->get(); }
45};
46
47} // namespace llvm
48
49#endif
50