[llvm] [InstCombine] fix hwasan mistake in "remove dead loads" (PR #145057)

Jameson Nash via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 20 09:13:34 PDT 2025


https://github.com/vtjnash updated https://github.com/llvm/llvm-project/pull/145057

>From 02415d5c33f4da46035938d296eb7cd6e87a0136 Mon Sep 17 00:00:00 2001
From: Jameson Nash <vtjnash at gmail.com>
Date: Fri, 20 Jun 2025 15:47:39 +0000
Subject: [PATCH 1/2] [InstCombine] fix hwasan mistake in "remove dead loads"

Detected by CI after #143958.
---
 llvm/lib/Transforms/InstCombine/InstructionCombining.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index bcc73090277aa..e4ae119a30499 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -3490,8 +3490,8 @@ Instruction *InstCombinerImpl::visitAllocSite(Instruction &MI) {
           replaceInstUsesWith(*I, Result);
           eraseInstFromFunction(*I);
           Users[i] = nullptr; // Skip examining in the next loop.
-        }
-        if (auto *MTI = dyn_cast<MemTransferInst>(I)) {
+          continue;
+        } else if (auto *MTI = dyn_cast<MemTransferInst>(I)) {
           if (KnowInitZero && isRefSet(*Removable)) {
             IRBuilderBase::InsertPointGuard Guard(Builder);
             Builder.SetInsertPoint(MTI);

>From 8dd0a3d339e9b51458689572438ebaec47759b59 Mon Sep 17 00:00:00 2001
From: Jameson Nash <vtjnash at gmail.com>
Date: Fri, 20 Jun 2025 12:13:26 -0400
Subject: [PATCH 2/2] Update InstructionCombining.cpp

---
 llvm/lib/Transforms/InstCombine/InstructionCombining.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index e4ae119a30499..ce42029261359 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -3491,7 +3491,8 @@ Instruction *InstCombinerImpl::visitAllocSite(Instruction &MI) {
           eraseInstFromFunction(*I);
           Users[i] = nullptr; // Skip examining in the next loop.
           continue;
-        } else if (auto *MTI = dyn_cast<MemTransferInst>(I)) {
+        }
+        if (auto *MTI = dyn_cast<MemTransferInst>(I)) {
           if (KnowInitZero && isRefSet(*Removable)) {
             IRBuilderBase::InsertPointGuard Guard(Builder);
             Builder.SetInsertPoint(MTI);



More information about the llvm-commits mailing list