AddressSanitizerCommon.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. #include "llvm/IR/Instruction.h"
  17. #include "llvm/IR/Module.h"
  18. namespace llvm {
  19. class InterestingMemoryOperand {
  20. public:
  21. Use *PtrUse;
  22. bool IsWrite;
  23. Type *OpType;
  24. uint64_t TypeSize;
  25. MaybeAlign Alignment;
  26. // The mask Value, if we're looking at a masked load/store.
  27. Value *MaybeMask;
  28. InterestingMemoryOperand(Instruction *I, unsigned OperandNo, bool IsWrite,
  29. class Type *OpType, MaybeAlign Alignment,
  30. Value *MaybeMask = nullptr)
  31. : IsWrite(IsWrite), OpType(OpType), Alignment(Alignment),
  32. MaybeMask(MaybeMask) {
  33. const DataLayout &DL = I->getModule()->getDataLayout();
  34. TypeSize = DL.getTypeStoreSizeInBits(OpType);
  35. PtrUse = &I->getOperandUse(OperandNo);
  36. }
  37. Instruction *getInsn() { return cast<Instruction>(PtrUse->getUser()); }
  38. Value *getPtr() { return PtrUse->get(); }
  39. };
  40. } // namespace llvm
  41. #endif