Skip to content

Commit a739589

Browse files
authored
[MemProf][NFC] remove unneeded TypeSize in InterestingMemoryAccess (#79244)
Unlike ASan, MemProf uses the same memory access callback(inline sequence) for different size memory access, remove unneeded TypeSize stored in InterestingMemoryAccess.
1 parent 28db401 commit a739589

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

llvm/lib/Transforms/Instrumentation/MemProfiler.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ struct InterestingMemoryAccess {
171171
Value *Addr = nullptr;
172172
bool IsWrite;
173173
Type *AccessTy;
174-
uint64_t TypeSize;
175174
Value *MaybeMask = nullptr;
176175
};
177176

@@ -194,7 +193,7 @@ class MemProfiler {
194193
void instrumentMop(Instruction *I, const DataLayout &DL,
195194
InterestingMemoryAccess &Access);
196195
void instrumentAddress(Instruction *OrigIns, Instruction *InsertBefore,
197-
Value *Addr, uint32_t TypeSize, bool IsWrite);
196+
Value *Addr, bool IsWrite);
198197
void instrumentMaskedLoadOrStore(const DataLayout &DL, Value *Mask,
199198
Instruction *I, Value *Addr, Type *AccessTy,
200199
bool IsWrite);
@@ -375,15 +374,13 @@ MemProfiler::isInterestingMemoryAccess(Instruction *I) const {
375374
}
376375

377376
const DataLayout &DL = I->getModule()->getDataLayout();
378-
Access.TypeSize = DL.getTypeStoreSizeInBits(Access.AccessTy);
379377
return Access;
380378
}
381379

382380
void MemProfiler::instrumentMaskedLoadOrStore(const DataLayout &DL, Value *Mask,
383381
Instruction *I, Value *Addr,
384382
Type *AccessTy, bool IsWrite) {
385383
auto *VTy = cast<FixedVectorType>(AccessTy);
386-
uint64_t ElemTypeSize = DL.getTypeStoreSizeInBits(VTy->getScalarType());
387384
unsigned Num = VTy->getNumElements();
388385
auto *Zero = ConstantInt::get(IntptrTy, 0);
389386
for (unsigned Idx = 0; Idx < Num; ++Idx) {
@@ -408,8 +405,7 @@ void MemProfiler::instrumentMaskedLoadOrStore(const DataLayout &DL, Value *Mask,
408405
IRBuilder<> IRB(InsertBefore);
409406
InstrumentedAddress =
410407
IRB.CreateGEP(VTy, Addr, {Zero, ConstantInt::get(IntptrTy, Idx)});
411-
instrumentAddress(I, InsertBefore, InstrumentedAddress, ElemTypeSize,
412-
IsWrite);
408+
instrumentAddress(I, InsertBefore, InstrumentedAddress, IsWrite);
413409
}
414410
}
415411

@@ -436,13 +432,13 @@ void MemProfiler::instrumentMop(Instruction *I, const DataLayout &DL,
436432
// Since the access counts will be accumulated across the entire allocation,
437433
// we only update the shadow access count for the first location and thus
438434
// don't need to worry about alignment and type size.
439-
instrumentAddress(I, I, Access.Addr, Access.TypeSize, Access.IsWrite);
435+
instrumentAddress(I, I, Access.Addr, Access.IsWrite);
440436
}
441437
}
442438

443439
void MemProfiler::instrumentAddress(Instruction *OrigIns,
444440
Instruction *InsertBefore, Value *Addr,
445-
uint32_t TypeSize, bool IsWrite) {
441+
bool IsWrite) {
446442
IRBuilder<> IRB(InsertBefore);
447443
Value *AddrLong = IRB.CreatePointerCast(Addr, IntptrTy);
448444

0 commit comments

Comments
 (0)