Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions mlir/lib/Analysis/DataFlow/LivenessAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,6 @@ RunLivenessAnalysis::RunLivenessAnalysis(Operation *op) {
// The framework doesn't visit operations in dead blocks, so we need to
// explicitly mark them as dead.
op->walk([&](Operation *op) {
if (op->getNumResults() == 0)
return;
for (auto result : llvm::enumerate(op->getResults())) {
if (getLiveness(result.value()))
continue;
Expand Down
3 changes: 2 additions & 1 deletion mlir/lib/Transforms/RemoveDeadValues.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,8 @@ static void processSimpleOp(Operation *op, RunLivenessAnalysis &la,
static void processFuncOp(FunctionOpInterface funcOp, Operation *module,
RunLivenessAnalysis &la, DenseSet<Value> &nonLiveSet,
RDVFinalCleanupList &cl) {
LDBG() << "Processing function op: " << funcOp.getOperation()->getName();
LDBG() << "Processing function op: "
<< OpWithFlags(funcOp, OpPrintingFlags().skipRegions());
if (funcOp.isPublic() || funcOp.isExternal()) {
LDBG() << "Function is public or external, skipping: "
<< funcOp.getOperation()->getName();
Expand Down
34 changes: 34 additions & 0 deletions mlir/test/Transforms/remove-dead-values.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -615,3 +615,37 @@ module @last_block_not_exit {
// CHECK-LABEL: @call_private_but_not_use
// CHECK: call @terminated_with_condbr(%false, %true) : (i1, i1)
}

// -----

// Test the elimination of function arguments.

// CHECK-LABEL: func private @single_parameter
// CHECK-SAME: () {
func.func private @single_parameter(%arg0: index) {
return
}

// CHECK-LABEL: func.func private @mutl_parameter(
// CHECK-SAME: %[[ARG0:.*]]: index)
// CHECK: return %[[ARG0]]
func.func private @mutl_parameter(%arg0: index, %arg1: index, %arg2: index) -> index {
return %arg1 : index
}

// CHECK-LABEL: func private @eliminate_parameter
// CHECK-SAME: () {
func.func private @eliminate_parameter(%arg0: index, %arg1: index) {
call @single_parameter(%arg0) : (index) -> ()
return
}

// CHECK-LABEL: func @callee
// CHECK-SAME: (%[[ARG0:.*]]: index, %[[ARG1:.*]]: index, %[[ARG2:.*]]: index)
func.func @callee(%arg0: index, %arg1: index, %arg2: index) -> index {
// CHECK: call @eliminate_parameter() : () -> ()
call @eliminate_parameter(%arg0, %arg1) : (index, index) -> ()
// CHECK: call @mutl_parameter(%[[ARG1]]) : (index) -> index
%res = call @mutl_parameter(%arg0, %arg1, %arg2) : (index, index, index) -> (index)
return %res : index
}