Skip to content

[mlir][bufferization] Module bufferization: Delete obsolete code #127455

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -289,35 +289,6 @@ static func::FuncOp getCalledFunction(func::CallOp callOp) {
SymbolTable::lookupNearestSymbolFrom(callOp, sym));
}

/// Gather equivalence info of CallOps.
/// Note: This only adds new equivalence info if the called function was already
/// analyzed.
// TODO: This does not handle cyclic function call graphs etc.
static void equivalenceAnalysis(func::FuncOp funcOp,
OneShotAnalysisState &state,
FuncAnalysisState &funcState) {
funcOp->walk([&](func::CallOp callOp) {
func::FuncOp calledFunction = getCalledFunction(callOp);
assert(calledFunction && "could not retrieved called func::FuncOp");

// No equivalence info available for the called function.
if (!funcState.equivalentFuncArgs.count(calledFunction))
return WalkResult::skip();

for (auto it : funcState.equivalentFuncArgs[calledFunction]) {
int64_t returnIdx = it.first;
int64_t bbargIdx = it.second;
if (!state.isInPlace(callOp->getOpOperand(bbargIdx)))
continue;
Value returnVal = callOp.getResult(returnIdx);
Value argVal = callOp->getOperand(bbargIdx);
state.unionEquivalenceClasses(returnVal, argVal);
}

return WalkResult::advance();
});
}

/// Return "true" if the given function signature has tensor semantics.
static bool hasTensorSignature(func::FuncOp funcOp) {
return llvm::any_of(funcOp.getFunctionType().getInputs(),
Expand Down Expand Up @@ -493,9 +464,6 @@ mlir::bufferization::analyzeModuleOp(ModuleOp moduleOp,
// Now analyzing function.
funcState.startFunctionAnalysis(funcOp);

// Gather equivalence info for CallOps.
equivalenceAnalysis(funcOp, state, funcState);

// Analyze funcOp.
if (failed(analyzeOp(funcOp, state, statistics)))
return failure();
Expand All @@ -514,9 +482,6 @@ mlir::bufferization::analyzeModuleOp(ModuleOp moduleOp,
if (!state.getOptions().isOpAllowed(funcOp))
continue;

// Gather equivalence info for CallOps.
equivalenceAnalysis(funcOp, state, funcState);

// Analyze funcOp.
if (failed(analyzeOp(funcOp, state, statistics)))
return failure();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// RUN: mlir-opt %s -one-shot-bufferize="bufferize-function-boundaries test-analysis-only" -split-input-file | FileCheck %s
// RUN: mlir-opt %s -one-shot-bufferize="bufferize-function-boundaries test-analysis-only dump-alias-sets" -split-input-file | FileCheck %s --check-prefix=CHECK-ALIAS

// Run fuzzer with different seeds.
// RUN: mlir-opt %s -one-shot-bufferize="bufferize-function-boundaries test-analysis-only analysis-heuristic=fuzzer analysis-fuzzer-seed=23" -split-input-file -o /dev/null
Expand Down Expand Up @@ -1406,3 +1407,21 @@ func.func @caller(%c: i1, %t0: tensor<5xf32>, %t1: tensor<5xf32>, %t2: tensor<5x
return %r : tensor<5xf32>
}

// -----

// CHECK-ALIAS-LABEL: func @foo
func.func @foo(%arg0: tensor<?xf32>) -> tensor<?xf32> {
// CHECK-ALIAS: return
// CHECK-ALIAS-SAME: __equivalent_func_args__ = [0]
return %arg0 : tensor<?xf32>
}

// CHECK-ALIAS: func @bar(%[[arg0:.*]]: tensor<?xf32>
func.func @bar(%arg0: tensor<?xf32>) -> tensor<?xf32> {
// CHECK-ALIAS: %[[call:.*]] = call @foo(%[[arg0]])
// CHECK-ALIAS-SAME: {__inplace_operands_attr__ = ["true"], __opresult_alias_set_attr__ = [{{\[}}"%[[call]]", "%[[arg0]]"]]}
%x = call @foo(%arg0) : (tensor<?xf32>) -> tensor<?xf32>
// CHECK-ALIAS: return
// CHECK-ALIAS-SAME: __equivalent_func_args__ = [0]
return %x : tensor<?xf32>
}