[llvm] [Darwin][MTE] bugfix: Only instrument stack history buffer if there are instrumented allocas in the function (PR #178770)

Usama Hameed via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 29 14:55:13 PST 2026


https://github.com/usama54321 created https://github.com/llvm/llvm-project/pull/178770

None

>From 03b7b22e95c91c750af5028716e6b6fcb183e1c7 Mon Sep 17 00:00:00 2001
From: usama <u_hameed at apple.com>
Date: Thu, 29 Jan 2026 14:38:24 -0800
Subject: [PATCH] [Darwin][MTE] bugfix: Only instrument stack history buffer if
 there are instrumented allocas in the function

---
 llvm/lib/Target/AArch64/AArch64StackTagging.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/Target/AArch64/AArch64StackTagging.cpp b/llvm/lib/Target/AArch64/AArch64StackTagging.cpp
index 215f33672b79e..4ae73d73b2a86 100644
--- a/llvm/lib/Target/AArch64/AArch64StackTagging.cpp
+++ b/llvm/lib/Target/AArch64/AArch64StackTagging.cpp
@@ -456,7 +456,7 @@ static Value *getSlotPtr(IRBuilder<> &IRB, const Triple &TargetTriple,
         !TargetTriple.isAndroidVersionLT(35) && HasInstrumentedAllocas)
       return memtag::getAndroidSlotPtr(IRB, -3);
     if (TargetTriple.isOSDarwin() && TargetTriple.isAArch64() &&
-        !TargetTriple.isSimulatorEnvironment())
+        !TargetTriple.isSimulatorEnvironment() && HasInstrumentedAllocas)
       return memtag::getDarwinSlotPtr(IRB, 231);
   }
   return nullptr;



More information about the llvm-commits mailing list