[Mlir-commits] [mlir] [mlir][memref] Fix rollback in test case during `convert-to-llvm` (PR #135958)

Matthias Springer llvmlistbot at llvm.org
Wed Apr 16 06:07:56 PDT 2025


https://github.com/matthias-springer created https://github.com/llvm/llvm-project/pull/135958

This commit is in preparation of the One-Shot Dialect Conversion refactoring, which removes the rollback from the dialect conversion framework.

`GenericAtomicRMWOpLowering` triggered a rollback in two test cases. The lowering pattern adds additional basic blocks to enclosing operation, which used to be a `func.func`. Adding a basic block triggers legalization of the op that owns the basic block. This fails when running `--convert-to-llvm="filter-dialects=memref"` because there are no lowering patterns for the `func` dialect and only `llvm` ops are considered "legal" by the `convert-to-llvm` pass, causing a rollback of the entire `GenericAtomicRMWOpLowering` pattern.


>From f1e755516f6efb0aeeb545f8f58625a154540d51 Mon Sep 17 00:00:00 2001
From: Matthias Springer <mspringer at nvidia.com>
Date: Wed, 16 Apr 2025 15:03:24 +0200
Subject: [PATCH] [mlir][memref] Remove rollback in conversion test case

---
 mlir/test/Conversion/MemRefToLLVM/memref-to-llvm.mlir | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/mlir/test/Conversion/MemRefToLLVM/memref-to-llvm.mlir b/mlir/test/Conversion/MemRefToLLVM/memref-to-llvm.mlir
index 12e93c96f743d..70da5a94d1615 100644
--- a/mlir/test/Conversion/MemRefToLLVM/memref-to-llvm.mlir
+++ b/mlir/test/Conversion/MemRefToLLVM/memref-to-llvm.mlir
@@ -413,7 +413,9 @@ func.func @atomic_rmw_with_offset(%I : memref<10xi32, strided<[1], offset: 5>>,
 // -----
 
 // CHECK-LABEL: func @generic_atomic_rmw
-func.func @generic_atomic_rmw(%I : memref<10xi32>, %i : index) {
+llvm.func @generic_atomic_rmw() {
+  %I = "test.foo"() : () -> (memref<10xi32>)
+  %i = "test.foo"() : () -> (index)
   %x = memref.generic_atomic_rmw %I[%i] : memref<10xi32> {
     ^bb0(%old_value : i32):
       memref.atomic_yield %old_value : i32
@@ -432,7 +434,7 @@ func.func @generic_atomic_rmw(%I : memref<10xi32>, %i : index) {
 // -----
 
 // CHECK-LABEL: func @generic_atomic_rmw_in_alloca_scope
-func.func @generic_atomic_rmw_in_alloca_scope(){
+llvm.func @generic_atomic_rmw_in_alloca_scope() {
   %c1 = arith.constant 1 : index
   %alloc = memref.alloc() : memref<2x3xi32>
   memref.alloca_scope  {
@@ -441,7 +443,7 @@ func.func @generic_atomic_rmw_in_alloca_scope(){
       memref.atomic_yield %arg0 : i32
     }
   }
-  return
+  llvm.return
 }
 // CHECK:        %[[STACK_SAVE:.*]] = llvm.intr.stacksave : !llvm.ptr
 // CHECK-NEXT:   llvm.br ^bb1



More information about the Mlir-commits mailing list