LLVM  12.0.0git
AddressSanitizerCommon.h
Go to the documentation of this file.
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 
20 namespace llvm {
21 
23 public:
25  bool IsWrite;
27  uint64_t TypeSize;
29  // The mask Value, if we're looking at a masked load/store.
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
A parsed version of the target data layout string in and methods for querying it. ...
Definition: DataLayout.h:111
This class represents lattice values for constants.
Definition: AllocatorList.h:23
const Use & getOperandUse(unsigned i) const
Definition: User.h:182
TypeSize getTypeStoreSizeInBits(Type *Ty) const
Returns the maximum number of bits that may be overwritten by storing the specified type; always a mu...
Definition: DataLayout.h:470
const DataLayout & getDataLayout() const
Get the data layout for the module&#39;s target platform.
Definition: Module.cpp:397
A Use represents the edge between a Value definition and its users.
Definition: Use.h:44
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
InterestingMemoryOperand(Instruction *I, unsigned OperandNo, bool IsWrite, class Type *OpType, MaybeAlign Alignment, Value *MaybeMask=nullptr)
This struct is a compact representation of a valid (power of two) or undefined (0) alignment...
Definition: Alignment.h:119
Module.h This file contains the declarations for the Module class.
const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
Definition: Instruction.cpp:68
#define I(x, y, z)
Definition: MD5.cpp:59
LLVM Value Representation.
Definition: Value.h:74
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL