diff --git a/llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerCommon.h b/llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerCommon.h index 7858a1c4b2fdf..8182442b4a6f0 100644 --- a/llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerCommon.h +++ b/llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerCommon.h @@ -27,7 +27,7 @@ class InterestingMemoryOperand { Use *PtrUse; bool IsWrite; Type *OpType; - uint64_t TypeSize; + TypeSize TypeStoreSize = TypeSize::Fixed(0); MaybeAlign Alignment; // The mask Value, if we're looking at a masked load/store. Value *MaybeMask; @@ -38,7 +38,7 @@ class InterestingMemoryOperand { : IsWrite(IsWrite), OpType(OpType), Alignment(Alignment), MaybeMask(MaybeMask) { const DataLayout &DL = I->getModule()->getDataLayout(); - TypeSize = DL.getTypeStoreSizeInBits(OpType); + TypeStoreSize = DL.getTypeStoreSizeInBits(OpType); PtrUse = &I->getOperandUse(OperandNo); } diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp index 5ec45a10e7244..63202770d54b2 100644 --- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -1492,7 +1492,7 @@ void AddressSanitizer::instrumentMop(ObjectSizeOffsetVisitor &ObjSizeVis, // dynamically initialized global is always valid. GlobalVariable *G = dyn_cast(getUnderlyingObject(Addr)); if (G && (!ClInitializers || GlobalIsLinkerInitialized(G)) && - isSafeAccess(ObjSizeVis, Addr, O.TypeSize)) { + isSafeAccess(ObjSizeVis, Addr, O.TypeStoreSize)) { NumOptimizedAccessesToGlobalVar++; return; } @@ -1501,7 +1501,7 @@ void AddressSanitizer::instrumentMop(ObjectSizeOffsetVisitor &ObjSizeVis, if (ClOpt && ClOptStack) { // A direct inbounds access to a stack variable is always valid. if (isa(getUnderlyingObject(Addr)) && - isSafeAccess(ObjSizeVis, Addr, O.TypeSize)) { + isSafeAccess(ObjSizeVis, Addr, O.TypeStoreSize)) { NumOptimizedAccessesToStackVar++; return; } @@ -1519,7 +1519,7 @@ void AddressSanitizer::instrumentMop(ObjectSizeOffsetVisitor &ObjSizeVis, O.IsWrite, nullptr, UseCalls, Exp); } else { doInstrumentAddress(this, O.getInsn(), O.getInsn(), Addr, O.Alignment, - Granularity, O.TypeSize, O.IsWrite, nullptr, UseCalls, + Granularity, O.TypeStoreSize, O.IsWrite, nullptr, UseCalls, Exp); } } diff --git a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp index 6a610e1877f13..2690c30212606 100644 --- a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp @@ -967,11 +967,11 @@ bool HWAddressSanitizer::instrumentMemAccess(InterestingMemoryOperand &O) { return false; // FIXME IRBuilder<> IRB(O.getInsn()); - if (isPowerOf2_64(O.TypeSize) && - (O.TypeSize / 8 <= (1ULL << (kNumberOfAccessSizes - 1))) && + if (isPowerOf2_64(O.TypeStoreSize) && + (O.TypeStoreSize / 8 <= (1ULL << (kNumberOfAccessSizes - 1))) && (!O.Alignment || *O.Alignment >= Mapping.getObjectAlignment() || - *O.Alignment >= O.TypeSize / 8)) { - size_t AccessSizeIndex = TypeSizeToSizeIndex(O.TypeSize); + *O.Alignment >= O.TypeStoreSize / 8)) { + size_t AccessSizeIndex = TypeSizeToSizeIndex(O.TypeStoreSize); if (InstrumentWithCalls) { IRB.CreateCall(HwasanMemoryAccessCallback[O.IsWrite][AccessSizeIndex], IRB.CreatePointerCast(Addr, IntptrTy)); @@ -983,7 +983,7 @@ bool HWAddressSanitizer::instrumentMemAccess(InterestingMemoryOperand &O) { } else { IRB.CreateCall(HwasanMemoryAccessCallbackSized[O.IsWrite], {IRB.CreatePointerCast(Addr, IntptrTy), - ConstantInt::get(IntptrTy, O.TypeSize / 8)}); + ConstantInt::get(IntptrTy, O.TypeStoreSize / 8)}); } untagPointerOperand(O.getInsn(), Addr);