[llvm-branch-commits] [NFC] [MTE] simplify tagp logic (PR #110337)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Sep 27 16:10:20 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-aarch64

Author: Florian Mayer (fmayer)

<details>
<summary>Changes</summary>

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.


---
Full diff: https://github.com/llvm/llvm-project/pull/110337.diff


1 Files Affected:

- (modified) llvm/lib/Target/AArch64/AArch64StackTagging.cpp (+4-5) 


``````````diff
diff --git a/llvm/lib/Target/AArch64/AArch64StackTagging.cpp b/llvm/lib/Target/AArch64/AArch64StackTagging.cpp
index 6ea58e26d07229..09910cc7bd47bd 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

``````````

</details>


https://github.com/llvm/llvm-project/pull/110337


More information about the llvm-branch-commits mailing list