Skip to content

Commit 0eb475a

Browse files
committed
[𝘀𝗽𝗿] initial version
Created using spr 1.3.4
2 parents c650067 + b3a9c34 commit 0eb475a

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

llvm/lib/Target/AArch64/AArch64StackTagging.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -581,29 +581,28 @@ bool AArch64StackTagging::runOnFunction(Function &Fn) {
581581
Instruction *Base =
582582
insertBaseTaggedPointer(*Fn.getParent(), SInfo.AllocasToInstrument, DT);
583583

584-
int NextTag = 0;
584+
unsigned int NextTag = 0;
585585
for (auto &I : SInfo.AllocasToInstrument) {
586586
memtag::AllocaInfo &Info = I.second;
587587
assert(Info.AI && SIB.getAllocaInterestingness(*Info.AI) ==
588588
llvm::memtag::AllocaInterestingness::kInteresting);
589589
memtag::alignAndPadAlloca(Info, kTagGranuleSize);
590590
AllocaInst *AI = Info.AI;
591-
int Tag = NextTag;
591+
unsigned int Tag = NextTag;
592592
NextTag = (NextTag + 1) % 16;
593593
// Replace alloca with tagp(alloca).
594594
IRBuilder<> IRB(Info.AI->getNextNode());
595595
Function *TagP = Intrinsic::getDeclaration(
596596
F->getParent(), Intrinsic::aarch64_tagp, {Info.AI->getType()});
597-
Instruction *TagPCall =
598-
IRB.CreateCall(TagP, {Constant::getNullValue(Info.AI->getType()), Base,
599-
ConstantInt::get(IRB.getInt64Ty(), Tag)});
597+
Instruction *TagPCall = IRB.CreateCall(
598+
TagP, {Info.AI, Base, ConstantInt::get(IRB.getInt64Ty(), Tag)});
600599
if (Info.AI->hasName())
601600
TagPCall->setName(Info.AI->getName() + ".tag");
602601
// Does not replace metadata, so we don't have to handle DbgVariableRecords.
603602
Info.AI->replaceUsesWithIf(TagPCall, [&](const Use &U) {
604-
return !memtag::isLifetimeIntrinsic(U.getUser());
603+
return !memtag::isLifetimeIntrinsic(U.getUser()) &&
604+
U.getUser() != TagPCall;
605605
});
606-
TagPCall->setOperand(0, Info.AI);
607606

608607
// Calls to functions that may return twice (e.g. setjmp) confuse the
609608
// postdominator analysis, and will leave us to keep memory tagged after
@@ -643,7 +642,7 @@ bool AArch64StackTagging::runOnFunction(Function &Fn) {
643642
II->eraseFromParent();
644643
}
645644

646-
memtag::annotateDebugRecords(Info, static_cast<unsigned long>(Tag));
645+
memtag::annotateDebugRecords(Info, Tag);
647646
}
648647

649648
// If we have instrumented at least one alloca, all unrecognized lifetime

0 commit comments

Comments
 (0)