Skip to content

Commit

Permalink
[NFC] Improve code reuse.
Browse files Browse the repository at this point in the history
Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D116711
  • Loading branch information
fmayer committed Jan 21, 2022
1 parent e6ceec9 commit 754d6af
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
Expand Up @@ -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)) {
Expand All @@ -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();
Expand Down

0 comments on commit 754d6af

Please sign in to comment.