git: 17e32453b89d - stable/13 - Merge commit eb8f379567e8 from llvm-project (by Florian Hahn):

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Mon, 08 Apr 2024 07:47:10 UTC
The branch stable/13 has been updated by dim:

URL: https://cgit.FreeBSD.org/src/commit/?id=17e32453b89d48db0d2f9e8086952df7d423423c

commit 17e32453b89d48db0d2f9e8086952df7d423423c
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2024-04-05 13:00:12 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2024-04-08 07:42:20 +0000

    Merge commit eb8f379567e8 from llvm-project (by Florian Hahn):
    
      [DSE] Remove malloc from EarliestEscapeInfo before removing. (#84157)
    
      Not removing the malloc from earliest escape info leaves stale entries
      in the cache.
    
      Fixes https://github.com/llvm/llvm-project/issues/84051.
    
      PR: https://github.com/llvm/llvm-project/pull/84157
    
    This fixes a crash in clang (usually a bus error, but can also be
    another memory error) when compiling the science/siconos port.
    
    PR:             278174
    Reported by:    yuri
    MFC after:      3 days
    
    (cherry picked from commit aaabed1dea7c1d16cdc5457bf6dee74164104e26)
---
 .../llvm-project/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp  | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/contrib/llvm-project/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp b/contrib/llvm-project/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
index d3fbe49439a8..62a9b6a41c5b 100644
--- a/contrib/llvm-project/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/contrib/llvm-project/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -1893,6 +1893,7 @@ struct DSEState {
                               Malloc->getArgOperand(0), IRB, TLI);
     if (!Calloc)
       return false;
+
     MemorySSAUpdater Updater(&MSSA);
     auto *LastDef =
       cast<MemoryDef>(Updater.getMemorySSA()->getMemoryAccess(Malloc));
@@ -1901,9 +1902,8 @@ struct DSEState {
                                       LastDef);
     auto *NewAccessMD = cast<MemoryDef>(NewAccess);
     Updater.insertDef(NewAccessMD, /*RenameUses=*/true);
-    Updater.removeMemoryAccess(Malloc);
     Malloc->replaceAllUsesWith(Calloc);
-    Malloc->eraseFromParent();
+    deleteDeadInstruction(Malloc);
     return true;
   }