LLVM  15.0.0git
AddressSanitizerCommon.h
Go to the documentation of this file.
1 //===--------- Definition of the AddressSanitizer class ---------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file declares common infrastructure for AddressSanitizer and
10 // HWAddressSanitizer.
11 //
12 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_TRANSFORMS_INSTRUMENTATION_ADDRESSSANITIZERCOMMON_H
14 #define LLVM_TRANSFORMS_INSTRUMENTATION_ADDRESSSANITIZERCOMMON_H
15 
16 #include "llvm/Analysis/CFG.h"
18 #include "llvm/IR/Dominators.h"
19 #include "llvm/IR/Instruction.h"
20 #include "llvm/IR/IntrinsicInst.h"
21 #include "llvm/IR/Module.h"
22 
23 namespace llvm {
24 
26 public:
28  bool IsWrite;
32  // The mask Value, if we're looking at a masked load/store.
34 
35  InterestingMemoryOperand(Instruction *I, unsigned OperandNo, bool IsWrite,
37  Value *MaybeMask = nullptr)
40  const DataLayout &DL = I->getModule()->getDataLayout();
41  TypeSize = DL.getTypeStoreSizeInBits(OpType);
42  PtrUse = &I->getOperandUse(OperandNo);
43  }
44 
45  Instruction *getInsn() { return cast<Instruction>(PtrUse->getUser()); }
46 
47  Value *getPtr() { return PtrUse->get(); }
48 };
49 
50 // Get AddressSanitizer parameters.
51 void getAddressSanitizerParams(const Triple &TargetTriple, int LongSize,
52  bool IsKasan, uint64_t *ShadowBase,
53  int *MappingScale, bool *OrShadowOffset);
54 
55 } // namespace llvm
56 
57 #endif
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::DataLayout
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:113
IntrinsicInst.h
llvm::InterestingMemoryOperand
Definition: AddressSanitizerCommon.h:25
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
Module.h
llvm::InterestingMemoryOperand::InterestingMemoryOperand
InterestingMemoryOperand(Instruction *I, unsigned OperandNo, bool IsWrite, class Type *OpType, MaybeAlign Alignment, Value *MaybeMask=nullptr)
Definition: AddressSanitizerCommon.h:35
llvm::InterestingMemoryOperand::TypeSize
uint64_t TypeSize
Definition: AddressSanitizerCommon.h:30
Instruction.h
PostDominators.h
llvm::InterestingMemoryOperand::getInsn
Instruction * getInsn()
Definition: AddressSanitizerCommon.h:45
llvm::InterestingMemoryOperand::OpType
Type * OpType
Definition: AddressSanitizerCommon.h:29
llvm::MaybeAlign
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Definition: Alignment.h:109
llvm::Instruction
Definition: Instruction.h:42
uint64_t
I
#define I(x, y, z)
Definition: MD5.cpp:58
CFG.h
llvm::InterestingMemoryOperand::MaybeMask
Value * MaybeMask
Definition: AddressSanitizerCommon.h:33
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition: AArch64SLSHardening.cpp:76
llvm::InterestingMemoryOperand::Alignment
MaybeAlign Alignment
Definition: AddressSanitizerCommon.h:31
llvm::TypeSize
Definition: TypeSize.h:421
llvm::InterestingMemoryOperand::getPtr
Value * getPtr()
Definition: AddressSanitizerCommon.h:47
llvm::getAddressSanitizerParams
void getAddressSanitizerParams(const Triple &TargetTriple, int LongSize, bool IsKasan, uint64_t *ShadowBase, int *MappingScale, bool *OrShadowOffset)
Definition: AddressSanitizer.cpp:583
Dominators.h
llvm::InterestingMemoryOperand::IsWrite
bool IsWrite
Definition: AddressSanitizerCommon.h:28
llvm::InterestingMemoryOperand::PtrUse
Use * PtrUse
Definition: AddressSanitizerCommon.h:27
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::Use
A Use represents the edge between a Value definition and its users.
Definition: Use.h:43