[Mlir-commits] [mlir] [mlir][acc] Add LegalizeDataValues support for DeclareEnterOp (PR #138008)
Razvan Lupusoru
llvmlistbot at llvm.org
Wed Apr 30 13:51:29 PDT 2025
================
@@ -71,7 +72,56 @@ static void replaceAllUsesInAccComputeRegionsWith(Value orig, Value replacement,
}
template <typename Op>
-static void collectAndReplaceInRegion(Op &op, bool hostToDevice) {
+static void replaceAllUsesInUnstructuredComputeRegionWith(
+ Op &op, llvm::SmallVector<std::pair<Value, Value>> &values,
+ DominanceInfo &domInfo, PostDominanceInfo &postDomInfo) {
+
+ SmallVector<Operation *> exitOps;
+ if constexpr (std::is_same_v<Op, acc::DeclareEnterOp>) {
+ // For declare enter/exit pairs, collect all exit ops
+ for (auto *user : op.getToken().getUsers()) {
+ if (auto declareExit = dyn_cast<acc::DeclareExitOp>(user))
+ exitOps.push_back(declareExit);
+ }
+ if (exitOps.empty())
+ op.emitError(
----------------
razvanlupusoru wrote:
This is not an error. For example in the acc.global_ctor, an acc.declare_enter is used without an exit operation. That said, I think it seems OK to avoid doing any replacement of values in such a case - just don't make it an error.
https://github.com/llvm/llvm-project/pull/138008
More information about the Mlir-commits
mailing list