[llvm] r277069 - [asan] Add const into few methods
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 28 15:50:50 PDT 2016
Author: vitalybuka
Date: Thu Jul 28 17:50:50 2016
New Revision: 277069
URL: http://llvm.org/viewvc/llvm-project?rev=277069&view=rev
Log:
[asan] Add const into few methods
Summary: No functional changes
Reviewers: eugenis
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D22899
Modified:
llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
Modified: llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp?rev=277069&r1=277068&r2=277069&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp Thu Jul 28 17:50:50 2016
@@ -460,20 +460,20 @@ struct AddressSanitizer : public Functio
AU.addRequired<DominatorTreeWrapperPass>();
AU.addRequired<TargetLibraryInfoWrapperPass>();
}
- uint64_t getAllocaSizeInBytes(AllocaInst *AI) const {
+ uint64_t getAllocaSizeInBytes(const AllocaInst &AI) const {
uint64_t ArraySize = 1;
- if (AI->isArrayAllocation()) {
- ConstantInt *CI = dyn_cast<ConstantInt>(AI->getArraySize());
+ if (AI.isArrayAllocation()) {
+ const ConstantInt *CI = dyn_cast<ConstantInt>(AI.getArraySize());
assert(CI && "non-constant array size");
ArraySize = CI->getZExtValue();
}
- Type *Ty = AI->getAllocatedType();
+ Type *Ty = AI.getAllocatedType();
uint64_t SizeInBytes =
- AI->getModule()->getDataLayout().getTypeAllocSize(Ty);
+ AI.getModule()->getDataLayout().getTypeAllocSize(Ty);
return SizeInBytes * ArraySize;
}
/// Check if we want (and can) handle this alloca.
- bool isInterestingAlloca(AllocaInst &AI);
+ bool isInterestingAlloca(const AllocaInst &AI);
/// If it is an interesting memory access, return the PointerOperand
/// and set IsWrite/Alignment. Otherwise return nullptr.
@@ -545,7 +545,7 @@ struct AddressSanitizer : public Functio
Function *AsanMemmove, *AsanMemcpy, *AsanMemset;
InlineAsm *EmptyAsm;
GlobalsMetadata GlobalsMD;
- DenseMap<AllocaInst *, bool> ProcessedAllocas;
+ DenseMap<const AllocaInst *, bool> ProcessedAllocas;
friend struct FunctionStackPoisoner;
};
@@ -917,7 +917,7 @@ void AddressSanitizer::instrumentMemIntr
}
/// Check if we want (and can) handle this alloca.
-bool AddressSanitizer::isInterestingAlloca(AllocaInst &AI) {
+bool AddressSanitizer::isInterestingAlloca(const AllocaInst &AI) {
auto PreviouslySeenAllocaInfo = ProcessedAllocas.find(&AI);
if (PreviouslySeenAllocaInfo != ProcessedAllocas.end())
@@ -926,7 +926,7 @@ bool AddressSanitizer::isInterestingAllo
bool IsInteresting =
(AI.getAllocatedType()->isSized() &&
// alloca() may be called with 0 size, ignore it.
- ((!AI.isStaticAlloca()) || getAllocaSizeInBytes(&AI) > 0) &&
+ ((!AI.isStaticAlloca()) || getAllocaSizeInBytes(AI) > 0) &&
// We are only interested in allocas not promotable to registers.
// Promotable allocas are common under -O0.
(!ClSkipPromotableAllocas || !isAllocaPromotable(&AI)) &&
@@ -2078,7 +2078,7 @@ void FunctionStackPoisoner::poisonStack(
SVD.reserve(AllocaVec.size());
for (AllocaInst *AI : AllocaVec) {
ASanStackVariableDescription D = {AI->getName().data(),
- ASan.getAllocaSizeInBytes(AI),
+ ASan.getAllocaSizeInBytes(*AI),
AI->getAlignment(), AI, 0};
SVD.push_back(D);
}
More information about the llvm-commits
mailing list