[Mlir-commits] [mlir] [mlir][bufferization] Skip parallel analysis without parallel regions (PR #227202)

Matthias Springer llvmlistbot at llvm.org
Tue Sep 29 18:01:23 PDT 2026


================
@@ -153,6 +153,19 @@ OneShotAnalysisState::OneShotAnalysisState(
   op->walk([&](BufferizableOpInterface bufferizableOp) {
     if (!options.isOpAllowed(bufferizableOp))
       return WalkResult::skip();
+
+    // Reuse this existing walk to determine whether parallel-region analysis
+    // can ever find a conflict. Avoid querying the interface once a parallel
+    // region was found.
+    if (options.checkParallelRegions && !containsParallelRegion) {
----------------
matthias-springer wrote:

This is a bit confusing. There are two variables `checkParallelRegions` and `containsParallelRegion` that seem to do the same thing.

Let's follow the same design as with `mayHaveUnstructuredControlFlow`.

1. Replace `bool checkParallelRegions = true;` in `BufferizationOptions` with `std::optional<bool> mayHaveParallelRegions = std::nullopt`. Also update the documentation of the field.
2. Add a corresponding `bool` field to `OneShotAnalysisState`, with similar naming. (Change name of `containsParallelRegion` so that it's clear that it's the same thing as the options flag.)
3. In the `OneShotAnalysisState` constructor, either take the boolean value from the options or do the traversal as you do here (if it's `nullopt`).
4. Use the `OneShotAnalysisState` field instead of `options.checkParallelRegions` throughout the analysis.
 

https://github.com/llvm/llvm-project/pull/227202


More information about the Mlir-commits mailing list