Skip to content

Commit eb739e9

Browse files
authored
[NFC] [MTE] simplify tagp logic (#110337)
We would put a placeholder in the tagp instruction, then replace all uses of the original alloca with this, then replace the placeholder. We use replaceUsesWithIf anyway, so it's easier to understand if we just exclude the tagp call there.
1 parent b3a9c34 commit eb739e9

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

llvm/lib/Target/AArch64/AArch64StackTagging.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -594,16 +594,15 @@ bool AArch64StackTagging::runOnFunction(Function &Fn) {
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

0 commit comments

Comments
 (0)