From 422400f2e18a9da1a3a17b6ae3bac9e0abb56c85 Mon Sep 17 00:00:00 2001 From: Maxime van Noppen 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 40c83487fd47d..f84aa6c41ab8c 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(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 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 0000000000000..efbde9c7588f4 --- /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) { + memref.load %arg1[] {name = "caller"} : memref + test.call_and_store @callee(%arg1), %arg1 {name = "call", store_before_call = false} : (memref, memref) -> () + memref.load %arg1[] {name = "post"} : memref + return +} \ No newline at end of file