AddressSanitizerCommon.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===--------- Definition of the AddressSanitizer class ---------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // This file declares common infrastructure for AddressSanitizer and
  15. // HWAddressSanitizer.
  16. //
  17. //===----------------------------------------------------------------------===//
  18. #ifndef LLVM_TRANSFORMS_INSTRUMENTATION_ADDRESSSANITIZERCOMMON_H
  19. #define LLVM_TRANSFORMS_INSTRUMENTATION_ADDRESSSANITIZERCOMMON_H
  20. #include "llvm/Analysis/CFG.h"
  21. #include "llvm/Analysis/PostDominators.h"
  22. #include "llvm/IR/Dominators.h"
  23. #include "llvm/IR/Instruction.h"
  24. #include "llvm/IR/IntrinsicInst.h"
  25. #include "llvm/IR/Module.h"
  26. namespace llvm {
  27. class InterestingMemoryOperand {
  28. public:
  29. Use *PtrUse;
  30. bool IsWrite;
  31. Type *OpType;
  32. uint64_t TypeSize;
  33. MaybeAlign Alignment;
  34. // The mask Value, if we're looking at a masked load/store.
  35. Value *MaybeMask;
  36. InterestingMemoryOperand(Instruction *I, unsigned OperandNo, bool IsWrite,
  37. class Type *OpType, MaybeAlign Alignment,
  38. Value *MaybeMask = nullptr)
  39. : IsWrite(IsWrite), OpType(OpType), Alignment(Alignment),
  40. MaybeMask(MaybeMask) {
  41. const DataLayout &DL = I->getModule()->getDataLayout();
  42. TypeSize = DL.getTypeStoreSizeInBits(OpType);
  43. PtrUse = &I->getOperandUse(OperandNo);
  44. }
  45. Instruction *getInsn() { return cast<Instruction>(PtrUse->getUser()); }
  46. Value *getPtr() { return PtrUse->get(); }
  47. };
  48. // Get AddressSanitizer parameters.
  49. void getAddressSanitizerParams(const Triple &TargetTriple, int LongSize,
  50. bool IsKasan, uint64_t *ShadowBase,
  51. int *MappingScale, bool *OrShadowOffset);
  52. } // namespace llvm
  53. #endif
  54. #ifdef __GNUC__
  55. #pragma GCC diagnostic pop
  56. #endif