summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Mayer <fmayer@google.com>2024-10-08 15:51:47 -0700
committerGitHub <noreply@github.com>2024-10-08 15:51:47 -0700
commiteb739e9377d74f562048c15716b8ebe6255e3e5a (patch)
treea205a83f7ca00e3880e0c0dca8aae79a9c0c6c0a
parentb3a9c340190982af5f274a964cf4a845f7eb49dc (diff)
[NFC] [MTE] simplify tagp logic (#110337)users/fmayer/spr/main.nfc-mte-simplify-tagp-logic
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.
-rw-r--r--llvm/lib/Target/AArch64/AArch64StackTagging.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/llvm/lib/Target/AArch64/AArch64StackTagging.cpp b/llvm/lib/Target/AArch64/AArch64StackTagging.cpp
index 6ea58e26d072..09910cc7bd47 100644
--- a/llvm/lib/Target/AArch64/AArch64StackTagging.cpp
+++ b/llvm/lib/Target/AArch64/AArch64StackTagging.cpp
@@ -594,16 +594,15 @@ bool AArch64StackTagging::runOnFunction(Function &Fn) {
IRBuilder<> IRB(Info.AI->getNextNode());
Function *TagP = Intrinsic::getDeclaration(
F->getParent(), Intrinsic::aarch64_tagp, {Info.AI->getType()});
- Instruction *TagPCall =
- IRB.CreateCall(TagP, {Constant::getNullValue(Info.AI->getType()), Base,
- ConstantInt::get(IRB.getInt64Ty(), Tag)});
+ Instruction *TagPCall = IRB.CreateCall(
+ TagP, {Info.AI, Base, ConstantInt::get(IRB.getInt64Ty(), Tag)});
if (Info.AI->hasName())
TagPCall->setName(Info.AI->getName() + ".tag");
// Does not replace metadata, so we don't have to handle DbgVariableRecords.
Info.AI->replaceUsesWithIf(TagPCall, [&](const Use &U) {
- return !memtag::isLifetimeIntrinsic(U.getUser());
+ return !memtag::isLifetimeIntrinsic(U.getUser()) &&
+ U.getUser() != TagPCall;
});
- TagPCall->setOperand(0, Info.AI);
// Calls to functions that may return twice (e.g. setjmp) confuse the
// postdominator analysis, and will leave us to keep memory tagged after