From b3a93e27c9d04b3a8dbe7bf99e541a9975a6f97a Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Mon, 8 Sep 2025 16:12:45 +0200 Subject: [PATCH] [CIR] Fix LLVM lowering crashes after #155244 This patch replaces all uses of replaceAllUseWith with replaceOp. This fixes a number of regressions post #155244. --- 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..cb05d6f9c3f79 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(); }