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(); }); 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