[llvm] 2f02c7e - [SanitizerCoverage] Avoid pointer element type access
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 25 08:22:31 PST 2022
Author: Nikita Popov
Date: 2022-01-25T17:22:20+01:00
New Revision: 2f02c7e1f2580c7faf9032922c5a8d3e957d0bd5
URL: https://github.com/llvm/llvm-project/commit/2f02c7e1f2580c7faf9032922c5a8d3e957d0bd5
DIFF: https://github.com/llvm/llvm-project/commit/2f02c7e1f2580c7faf9032922c5a8d3e957d0bd5.diff
LOG: [SanitizerCoverage] Avoid pointer element type access
Use the load/store type instead.
Added:
Modified:
llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp b/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
index 387ea5243265d..d3b60c7add34c 100644
--- a/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
+++ b/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
@@ -917,8 +917,7 @@ void ModuleSanitizerCoverage::InjectTraceForGep(
void ModuleSanitizerCoverage::InjectTraceForLoadsAndStores(
Function &, ArrayRef<LoadInst *> Loads, ArrayRef<StoreInst *> Stores) {
- auto CallbackIdx = [&](const Value *Ptr) -> int {
- auto *ElementTy = Ptr->getType()->getPointerElementType();
+ auto CallbackIdx = [&](Type *ElementTy) -> int {
uint64_t TypeSize = DL->getTypeStoreSizeInBits(ElementTy);
return TypeSize == 8 ? 0
: TypeSize == 16 ? 1
@@ -932,7 +931,7 @@ void ModuleSanitizerCoverage::InjectTraceForLoadsAndStores(
for (auto LI : Loads) {
IRBuilder<> IRB(LI);
auto Ptr = LI->getPointerOperand();
- int Idx = CallbackIdx(Ptr);
+ int Idx = CallbackIdx(LI->getType());
if (Idx < 0)
continue;
IRB.CreateCall(SanCovLoadFunction[Idx],
@@ -941,7 +940,7 @@ void ModuleSanitizerCoverage::InjectTraceForLoadsAndStores(
for (auto SI : Stores) {
IRBuilder<> IRB(SI);
auto Ptr = SI->getPointerOperand();
- int Idx = CallbackIdx(Ptr);
+ int Idx = CallbackIdx(SI->getValueOperand()->getType());
if (Idx < 0)
continue;
IRB.CreateCall(SanCovStoreFunction[Idx],
More information about the llvm-commits
mailing list