diff options
Diffstat (limited to 'llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerCommon.h')
-rw-r--r-- | llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerCommon.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerCommon.h b/llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerCommon.h new file mode 100644 index 0000000000000..7da0bf8c441fa --- /dev/null +++ b/llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerCommon.h @@ -0,0 +1,49 @@ +//===--------- Definition of the AddressSanitizer class ---------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file declares common infrastructure for AddressSanitizer and +// HWAddressSanitizer. +// +//===----------------------------------------------------------------------===// +#ifndef LLVM_TRANSFORMS_INSTRUMENTATION_ADDRESSSANITIZERCOMMON_H +#define LLVM_TRANSFORMS_INSTRUMENTATION_ADDRESSSANITIZERCOMMON_H + +#include "llvm/IR/Instruction.h" +#include "llvm/IR/Module.h" + +namespace llvm { + +class InterestingMemoryOperand { +public: + Use *PtrUse; + bool IsWrite; + Type *OpType; + uint64_t TypeSize; + MaybeAlign Alignment; + // The mask Value, if we're looking at a masked load/store. + Value *MaybeMask; + + InterestingMemoryOperand(Instruction *I, unsigned OperandNo, bool IsWrite, + class Type *OpType, MaybeAlign Alignment, + Value *MaybeMask = nullptr) + : IsWrite(IsWrite), OpType(OpType), Alignment(Alignment), + MaybeMask(MaybeMask) { + const DataLayout &DL = I->getModule()->getDataLayout(); + TypeSize = DL.getTypeStoreSizeInBits(OpType); + PtrUse = &I->getOperandUse(OperandNo); + } + + Instruction *getInsn() { return cast<Instruction>(PtrUse->getUser()); } + + Value *getPtr() { return PtrUse->get(); } +}; + +} // namespace llvm + +#endif |