Skip to content

Commit

Permalink
[mlir][transforms] Skip RemoveDeadValues for function declaration (l…
Browse files Browse the repository at this point in the history
…lvm#108221)

This patch skips `RemoveDeadValues` if funcOp is declaration, which
fixes a crash.
Fixes llvm#107546.
  • Loading branch information
CoTinker authored Sep 14, 2024
1 parent a20a973 commit 1208699
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mlir/lib/Transforms/RemoveDeadValues.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,10 @@ static void cleanSimpleOp(Operation *op, RunLivenessAnalysis &la) {
/// non-live across all callers),
/// (5) Dropping the uses of these return values from its callers, AND
/// (6) Erasing these return values
/// iff it is not public.
/// iff it is not public or declaration.
static void cleanFuncOp(FunctionOpInterface funcOp, Operation *module,
RunLivenessAnalysis &la) {
if (funcOp.isPublic())
if (funcOp.isPublic() || funcOp.isDeclaration())
return;

// Get the list of unnecessary (non-live) arguments in `nonLiveArgs`.
Expand Down
5 changes: 5 additions & 0 deletions mlir/test/Transforms/remove-dead-values.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -357,3 +357,8 @@ func.func @kernel(%arg0: memref<18xf32>) {
// CHECK: gpu.launch blocks
// CHECK: memref.store
// CHECK-NEXT: gpu.terminator

// -----

// CHECK: func.func private @no_block_func_declaration()
func.func private @no_block_func_declaration() -> ()

0 comments on commit 1208699

Please sign in to comment.