Skip to content

Commit cfe36e4

Browse files
thejhramosian-glider
authored andcommitted
[AddressSanitizer] Refactor: Permit >1 interesting operands per instruction
Summary: Refactor getInterestingMemoryOperands() so that information about the pointer operand is returned through an array of structures instead of passing each piece of information separately by-value. This is in preparation for returning information about multiple pointer operands from a single instruction. A side effect is that, instead of repeatedly generating the same information through isInterestingMemoryAccess(), it is now simply collected once and then passed around; that's probably more efficient. HWAddressSanitizer has a bunch of copypasted code from AddressSanitizer, so these changes have to be duplicated. This is patch 3/4 of a patch series: https://reviews.llvm.org/D77616 [PATCH 1/4] [AddressSanitizer] Refactor ClDebug{Min,Max} handling https://reviews.llvm.org/D77617 [PATCH 2/4] [AddressSanitizer] Split out memory intrinsic handling https://reviews.llvm.org/D77618 [PATCH 3/4] [AddressSanitizer] Refactor: Permit >1 interesting operands per instruction https://reviews.llvm.org/D77619 [PATCH 4/4] [AddressSanitizer] Instrument byval call arguments [glider: renamed llvm::InterestingMemoryOperand::Type to OpType to fix GCC compilation] Reviewers: kcc, glider Reviewed By: glider Subscribers: hiraditya, jfb, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D77618
1 parent 223a95f commit cfe36e4

File tree

3 files changed

+218
-214
lines changed

3 files changed

+218
-214
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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+
22+
class InterestingMemoryOperand {
23+
public:
24+
Use *PtrUse;
25+
bool IsWrite;
26+
Type *OpType;
27+
uint64_t TypeSize;
28+
unsigned Alignment;
29+
// The mask Value, if we're looking at a masked load/store.
30+
Value *MaybeMask;
31+
32+
InterestingMemoryOperand(Instruction *I, unsigned OperandNo, bool IsWrite,
33+
class Type *OpType, unsigned 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

0 commit comments

Comments
 (0)