Skip to content

Instantly share code, notes, and snippets.

@navyxliu
Created October 6, 2025 03:21
Show Gist options
  • Select an option

  • Save navyxliu/cd7b0d28235129a72ec2e827d5b3957e to your computer and use it in GitHub Desktop.

Select an option

Save navyxliu/cd7b0d28235129a72ec2e827d5b3957e to your computer and use it in GitHub Desktop.
RDV: private main2.
there's another bug in remove-dead-values.
the problem is liveness analysis depends on mlir::dataflow::DeadCodeAnalysis.
without any reference of @main2, it doesn't participate progation of liveness. As a result, it has no idea arg0 and %arg1 of @immutable_fn_return_void_with_unused_argument.
RDV needs to delete @main2 entirely.
➜ build git:(backward_remove_dead_values) cat in3.mlir
// /bin/mlir-opt --remove-dead-values --debug-only=remove-dead-values --debug-only=liveness-analysis --debug-only=dataflow ./in3.mlir
func.func public @immutable_fn_return_void_with_unused_argument(%arg0: i32, %arg1: memref<4xf32>) -> () {
return
}
func.func private @main2(%arg: i32) -> () {
%one = arith.constant 1 : i32
%scalar = arith.addi %arg, %one: i32
%mem = memref.alloc() : memref<4xf32>
call @immutable_fn_return_void_with_unused_argument(%scalar, %mem) : (i32, memref<4xf32>) -> ()
return
}
//func.func @main(%arg: i32) -> () {
// call @main2(%arg): (i32) -> ()
// return
//}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment