Skip to content

Commit cfb5f89

Browse files
thejhramosian-glider
authored andcommitted
[AddressSanitizer] Refactor ClDebug{Min,Max} handling
Summary: A following commit will split the loop over ToInstrument into two. To avoid having to duplicate the condition for suppressing instrumentation sites based on ClDebug{Min,Max}, refactor it out into a new function. While we're at it, we can also avoid the indirection through NumInstrumented for setting FunctionModified. This is patch 1/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 Reviewers: kcc, glider Reviewed By: glider Subscribers: jfb, hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D77616
1 parent 87e07b4 commit cfb5f89

File tree

4 files changed

+294
-227
lines changed

4 files changed

+294
-227
lines changed
Lines changed: 49 additions & 0 deletions
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)