[Mlir-commits] [mlir] Only insert the function in the callable map if it resolves. (PR #110348)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sat Sep 28 09:41:44 PDT 2024
https://github.com/mavann updated https://github.com/llvm/llvm-project/pull/110348
>From 422400f2e18a9da1a3a17b6ae3bac9e0abb56c85 Mon Sep 17 00:00:00 2001
From: Maxime van Noppen <mavann at microsoft.com>
Date: Fri, 27 Sep 2024 20:49:24 -0400
Subject: [PATCH 1/2] Only insert the function in the callable map if it
resolves.
---
mlir/lib/Dialect/MLProgram/Transforms/PipelineGlobalOps.cpp | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/mlir/lib/Dialect/MLProgram/Transforms/PipelineGlobalOps.cpp b/mlir/lib/Dialect/MLProgram/Transforms/PipelineGlobalOps.cpp
index 40c83487fd47d5..f84aa6c41ab8c9 100644
--- a/mlir/lib/Dialect/MLProgram/Transforms/PipelineGlobalOps.cpp
+++ b/mlir/lib/Dialect/MLProgram/Transforms/PipelineGlobalOps.cpp
@@ -59,8 +59,9 @@ LogicalResult MLProgramPipelineGlobals::buildGlobalMap(ModuleOp module) {
}
auto symbol = mlir::dyn_cast<SymbolRefAttr>(callable);
- auto *func = getFromSymbol(op, symbol);
- callableMap[symbol] = func;
+ if (auto *func = getFromSymbol(op, symbol)) {
+ callableMap[symbol] = func;
+ }
}
return WalkResult::advance();
});
>From 4d79231418f01d27a575a10239bd411c7c86a7b6 Mon Sep 17 00:00:00 2001
From: Maxime van Noppen <maxime.van.noppen at outlook.com>
Date: Sat, 28 Sep 2024 12:41:32 -0400
Subject: [PATCH 2/2] Add the crash as test case.
---
mlir/test/mlir-opt/PipelineGlobalOpsCrash.mlir | 8 ++++++++
1 file changed, 8 insertions(+)
create mode 100644 mlir/test/mlir-opt/PipelineGlobalOpsCrash.mlir
diff --git a/mlir/test/mlir-opt/PipelineGlobalOpsCrash.mlir b/mlir/test/mlir-opt/PipelineGlobalOpsCrash.mlir
new file mode 100644
index 00000000000000..efbde9c7588f48
--- /dev/null
+++ b/mlir/test/mlir-opt/PipelineGlobalOpsCrash.mlir
@@ -0,0 +1,8 @@
+// RUN: mlir-opt -mlprogram-pipeline-globals %s
+
+func.func @call_and_store_after(%arg1: memref<f32>) {
+ memref.load %arg1[] {name = "caller"} : memref<f32>
+ test.call_and_store @callee(%arg1), %arg1 {name = "call", store_before_call = false} : (memref<f32>, memref<f32>) -> ()
+ memref.load %arg1[] {name = "post"} : memref<f32>
+ return
+}
\ No newline at end of file
More information about the Mlir-commits
mailing list