[NFC] Improve code reuse.

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D116711
This commit is contained in:
Florian Mayer 2022-01-05 16:27:23 -08:00
parent e6ceec9c1d
commit 754d6af7c3
1 changed files with 7 additions and 10 deletions

View File

@ -1403,16 +1403,16 @@ bool HWAddressSanitizer::instrumentStack(
size_t Size = getAllocaSizeInBytes(*AI);
size_t AlignedSize = alignTo(Size, Mapping.getObjectAlignment());
auto TagEnd = [&](Instruction *Node) {
IRB.SetInsertPoint(Node);
Value *UARTag = getUARTag(IRB, StackTag);
tagAlloca(IRB, AI, UARTag, AlignedSize);
};
bool StandardLifetime =
UnrecognizedLifetimes.empty() && isStandardLifetime(Info, GetDT());
if (DetectUseAfterScope && StandardLifetime) {
IntrinsicInst *Start = Info.LifetimeStart[0];
IRB.SetInsertPoint(Start->getNextNode());
auto TagEnd = [&](Instruction *Node) {
IRB.SetInsertPoint(Node);
Value *UARTag = getUARTag(IRB, StackTag);
tagAlloca(IRB, AI, UARTag, AlignedSize);
};
tagAlloca(IRB, AI, Tag, Size);
if (!forAllReachableExits(GetDT(), GetPDT(), Start, Info.LifetimeEnd,
RetVec, TagEnd)) {
@ -1421,11 +1421,8 @@ bool HWAddressSanitizer::instrumentStack(
}
} else {
tagAlloca(IRB, AI, Tag, Size);
for (auto *RI : RetVec) {
IRB.SetInsertPoint(RI);
Value *UARTag = getUARTag(IRB, StackTag);
tagAlloca(IRB, AI, UARTag, AlignedSize);
}
for (auto *RI : RetVec)
TagEnd(RI);
if (!StandardLifetime) {
for (auto &II : Info.LifetimeStart)
II->eraseFromParent();