[llvm] c195add - [NFC] [MTE] [HWASan] Remove unnecessary member of AllocaInfo
Florian Mayer via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 16 15:19:38 PST 2022
Author: Florian Mayer
Date: 2022-02-16T15:19:30-08:00
New Revision: c195addb606be4bc1d8f2716215657148382dbf8
URL: https://github.com/llvm/llvm-project/commit/c195addb606be4bc1d8f2716215657148382dbf8
DIFF: https://github.com/llvm/llvm-project/commit/c195addb606be4bc1d8f2716215657148382dbf8.diff
LOG: [NFC] [MTE] [HWASan] Remove unnecessary member of AllocaInfo
Reviewed By: eugenis
Differential Revision: https://reviews.llvm.org/D119981
Added:
Modified:
llvm/include/llvm/Transforms/Utils/MemoryTaggingSupport.h
llvm/lib/Target/AArch64/AArch64StackTagging.cpp
llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
llvm/lib/Transforms/Utils/MemoryTaggingSupport.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Transforms/Utils/MemoryTaggingSupport.h b/llvm/include/llvm/Transforms/Utils/MemoryTaggingSupport.h
index c00d2c6445a9c..7de9beb8887eb 100644
--- a/llvm/include/llvm/Transforms/Utils/MemoryTaggingSupport.h
+++ b/llvm/include/llvm/Transforms/Utils/MemoryTaggingSupport.h
@@ -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 @@ class StackInfoBuilder {
};
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
diff --git a/llvm/lib/Target/AArch64/AArch64StackTagging.cpp b/llvm/lib/Target/AArch64/AArch64StackTagging.cpp
index 22383432d1a8a..589074e16d9b0 100644
--- a/llvm/lib/Target/AArch64/AArch64StackTagging.cpp
+++ b/llvm/lib/Target/AArch64/AArch64StackTagging.cpp
@@ -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
diff --git a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
index 0d599733980f4..350f9701d48d4 100644
--- a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
@@ -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();
diff --git a/llvm/lib/Transforms/Utils/MemoryTaggingSupport.cpp b/llvm/lib/Transforms/Utils/MemoryTaggingSupport.cpp
index 602a2fe4ed3cd..641dd58456f6f 100644
--- a/llvm/lib/Transforms/Utils/MemoryTaggingSupport.cpp
+++ b/llvm/lib/Transforms/Utils/MemoryTaggingSupport.cpp
@@ -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
More information about the llvm-commits
mailing list