Skip to content

Commit 1208699

Browse files
authored
[mlir][transforms] Skip RemoveDeadValues for function declaration (#108221)
This patch skips `RemoveDeadValues` if funcOp is declaration, which fixes a crash. Fixes #107546.
1 parent a20a973 commit 1208699

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

mlir/lib/Transforms/RemoveDeadValues.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,10 @@ static void cleanSimpleOp(Operation *op, RunLivenessAnalysis &la) {
191191
/// non-live across all callers),
192192
/// (5) Dropping the uses of these return values from its callers, AND
193193
/// (6) Erasing these return values
194-
/// iff it is not public.
194+
/// iff it is not public or declaration.
195195
static void cleanFuncOp(FunctionOpInterface funcOp, Operation *module,
196196
RunLivenessAnalysis &la) {
197-
if (funcOp.isPublic())
197+
if (funcOp.isPublic() || funcOp.isDeclaration())
198198
return;
199199

200200
// Get the list of unnecessary (non-live) arguments in `nonLiveArgs`.

mlir/test/Transforms/remove-dead-values.mlir

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,3 +357,8 @@ func.func @kernel(%arg0: memref<18xf32>) {
357357
// CHECK: gpu.launch blocks
358358
// CHECK: memref.store
359359
// CHECK-NEXT: gpu.terminator
360+
361+
// -----
362+
363+
// CHECK: func.func private @no_block_func_declaration()
364+
func.func private @no_block_func_declaration() -> ()

0 commit comments

Comments
 (0)