[Mlir-commits] [flang] [mlir] [llvm][mlir][OpenMP] Support translation for linear clause in omp.wsloop and omp.simd (PR #139386)
Sergio Afonso
llvmlistbot at llvm.org
Tue Jan 13 07:13:17 PST 2026
================
----------------
skatrak wrote:
Thank you Nimish for this work and sorry for the delayed comment! I think this function can be slightly refactored to make it simpler / more maintainable (keeping state preserved across calls make it quite easy to break things later on). I'd suggest something like this:
```c++
bool ClauseProcessor::processLinear(...) const {
...
llvm::SmallVector<mlir::Attribute> typeAttrs;
bool clauseFound = findRepeatableClause<...>([&](...) {
auto &objects = std::get<omp::ObjectList>(clause.t);
for (const omp::Object &object : objects) {
...
typeAttrs.push_back(mlir::TypeAttr::get(converter.genType(*sym)));
}
...
});
if (clauseFound)
result.linearVarTypes = mlir::ArrayAttr::get(&converter.getMLIRContext(), typeAttrs);
return clauseFound;
}
```
That makes it so we don't need to clear a global array when we indirectly detect we're processing a new directive, by looking at `result.linearVars`, and we also we avoid creating a new array attribute for each instance of the clause on a directive.
https://github.com/llvm/llvm-project/pull/139386
More information about the Mlir-commits
mailing list