https://github.com/mmha created https://github.com/llvm/llvm-project/pull/157471

This patch replaces all uses of `replaceAllUseWith` with `replaceOp`. This 
fixes a number of regressions post #155244.

>From 9cc2c129d4f1cc805901897c6a11be50fe971675 Mon Sep 17 00:00:00 2001
From: Morris Hafner <[email protected]>
Date: Mon, 8 Sep 2025 16:12:45 +0200
Subject: [PATCH] Fix LLVM lowering crashes

---
 clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp 
b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
index ee9f58c829ca9..f8dac2aa02a0c 100644
--- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
+++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
@@ -1355,8 +1355,7 @@ mlir::LogicalResult 
CIRToLLVMConstantOpLowering::matchAndRewrite(
     } else {
       const mlir::Value initVal =
           lowerCirAttrAsValue(op, op.getValue(), rewriter, typeConverter);
-      rewriter.replaceAllUsesWith(op, initVal);
-      rewriter.eraseOp(op);
+      rewriter.replaceOp(op, initVal);
       return mlir::success();
     }
   } else if (const auto recordAttr =
@@ -2653,8 +2652,7 @@ mlir::LogicalResult 
CIRToLLVMVTableGetVPtrOpLowering::matchAndRewrite(
   // pointer to the vptr type. Since the LLVM dialect uses opaque pointers
   // we can just replace uses of this operation with the original pointer.
   mlir::Value srcVal = adaptor.getSrc();
-  rewriter.replaceAllUsesWith(op, srcVal);
-  rewriter.eraseOp(op);
+  rewriter.replaceOp (op, srcVal);
   return mlir::success();
 }
 

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to