forked from OSchip/llvm-project
[NFC] [MTE] [HWASan] Remove unnecessary member of AllocaInfo
Reviewed By: eugenis Differential Revision: https://reviews.llvm.org/D119981
This commit is contained in:
parent
7470244475
commit
c195addb60
|
@ -19,7 +19,6 @@
|
|||
#include "llvm/IR/Instruction.h"
|
||||
#include "llvm/IR/IntrinsicInst.h"
|
||||
#include "llvm/IR/Module.h"
|
||||
#include "llvm/IR/ValueHandle.h"
|
||||
|
||||
namespace llvm {
|
||||
namespace memtag {
|
||||
|
@ -75,7 +74,6 @@ Instruction *getUntagLocationIfFunctionExit(Instruction &Inst);
|
|||
|
||||
struct AllocaInfo {
|
||||
AllocaInst *AI;
|
||||
TrackingVH<Instruction> OldAI; // Track through RAUW to replace debug uses.
|
||||
SmallVector<IntrinsicInst *, 2> LifetimeStart;
|
||||
SmallVector<IntrinsicInst *, 2> LifetimeEnd;
|
||||
SmallVector<DbgVariableIntrinsic *, 2> DbgVariableIntrinsics;
|
||||
|
@ -102,7 +100,7 @@ private:
|
|||
};
|
||||
|
||||
uint64_t getAllocaSizeInBytes(const AllocaInst &AI);
|
||||
bool alignAndPadAlloca(memtag::AllocaInfo &Info, llvm::Align Align);
|
||||
void alignAndPadAlloca(memtag::AllocaInfo &Info, llvm::Align Align);
|
||||
|
||||
} // namespace memtag
|
||||
} // namespace llvm
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include "llvm/IR/IntrinsicInst.h"
|
||||
#include "llvm/IR/IntrinsicsAArch64.h"
|
||||
#include "llvm/IR/Metadata.h"
|
||||
#include "llvm/IR/ValueHandle.h"
|
||||
#include "llvm/InitializePasses.h"
|
||||
#include "llvm/Pass.h"
|
||||
#include "llvm/Support/Casting.h"
|
||||
|
@ -532,9 +533,8 @@ bool AArch64StackTagging::runOnFunction(Function &Fn) {
|
|||
for (auto &I : SInfo.AllocasToInstrument) {
|
||||
memtag::AllocaInfo &Info = I.second;
|
||||
assert(Info.AI && isInterestingAlloca(*Info.AI));
|
||||
auto *PrevAI = Info.AI;
|
||||
if (memtag::alignAndPadAlloca(Info, kTagGranuleSize))
|
||||
PrevAI->eraseFromParent();
|
||||
TrackingVH<Instruction> OldAI = Info.AI;
|
||||
memtag::alignAndPadAlloca(Info, kTagGranuleSize);
|
||||
AllocaInst *AI = Info.AI;
|
||||
int Tag = NextTag;
|
||||
NextTag = (NextTag + 1) % 16;
|
||||
|
@ -590,7 +590,7 @@ bool AArch64StackTagging::runOnFunction(Function &Fn) {
|
|||
|
||||
// Fixup debug intrinsics to point to the new alloca.
|
||||
for (auto DVI : Info.DbgVariableIntrinsics)
|
||||
DVI->replaceVariableLocationOp(Info.OldAI, Info.AI);
|
||||
DVI->replaceVariableLocationOp(OldAI, Info.AI);
|
||||
}
|
||||
|
||||
// If we have instrumented at least one alloca, all unrecognized lifetime
|
||||
|
|
|
@ -1378,8 +1378,7 @@ bool HWAddressSanitizer::instrumentStack(
|
|||
II->eraseFromParent();
|
||||
}
|
||||
}
|
||||
if (memtag::alignAndPadAlloca(Info, Align(Mapping.getObjectAlignment())))
|
||||
AI->eraseFromParent();
|
||||
memtag::alignAndPadAlloca(Info, Align(Mapping.getObjectAlignment()));
|
||||
}
|
||||
for (auto &I : SInfo.UnrecognizedLifetimes)
|
||||
I->eraseFromParent();
|
||||
|
|
|
@ -67,7 +67,6 @@ void StackInfoBuilder::visit(Instruction &Inst) {
|
|||
if (AllocaInst *AI = dyn_cast<AllocaInst>(&Inst)) {
|
||||
if (IsInterestingAlloca(*AI)) {
|
||||
Info.AllocasToInstrument[AI].AI = AI;
|
||||
Info.AllocasToInstrument[AI].OldAI = AI;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -109,7 +108,7 @@ uint64_t getAllocaSizeInBytes(const AllocaInst &AI) {
|
|||
return AI.getAllocationSizeInBits(DL).getValue() / 8;
|
||||
}
|
||||
|
||||
bool alignAndPadAlloca(memtag::AllocaInfo &Info, llvm::Align Alignment) {
|
||||
void alignAndPadAlloca(memtag::AllocaInfo &Info, llvm::Align Alignment) {
|
||||
const Align NewAlignment = max(MaybeAlign(Info.AI->getAlign()), Alignment);
|
||||
Info.AI->setAlignment(NewAlignment);
|
||||
auto &Ctx = Info.AI->getFunction()->getContext();
|
||||
|
@ -117,7 +116,7 @@ bool alignAndPadAlloca(memtag::AllocaInfo &Info, llvm::Align Alignment) {
|
|||
uint64_t Size = getAllocaSizeInBytes(*Info.AI);
|
||||
uint64_t AlignedSize = alignTo(Size, Alignment);
|
||||
if (Size == AlignedSize)
|
||||
return false;
|
||||
return;
|
||||
|
||||
// Add padding to the alloca.
|
||||
Type *AllocatedType =
|
||||
|
@ -139,8 +138,8 @@ bool alignAndPadAlloca(memtag::AllocaInfo &Info, llvm::Align Alignment) {
|
|||
|
||||
auto *NewPtr = new BitCastInst(NewAI, Info.AI->getType(), "", Info.AI);
|
||||
Info.AI->replaceAllUsesWith(NewPtr);
|
||||
Info.AI->eraseFromParent();
|
||||
Info.AI = NewAI;
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace memtag
|
||||
|
|
Loading…
Reference in New Issue