[flang-commits] [flang] [Flang][OpenMP] Use InsertionGuard in DataSharingProcessor (PR #97562)

via flang-commits flang-commits at lists.llvm.org
Wed Jul 3 05:11:41 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-flang-fir-hlfir

Author: Sergio Afonso (skatrak)

<details>
<summary>Changes</summary>

This patch removes the introduction of `fir.undef` operations as a way to keep track of insertion points inside of the `DataSharingProcessor`, and it replaces them with an `InsertionGuard` to avoid creating such operations inside of loop wrappers.

Leaving any `fir.undef` operation inside of a loop wrapper would result in a verifier error, since they enforce strict requirements on the contents of their code regions.

---
Full diff: https://github.com/llvm/llvm-project/pull/97562.diff


1 Files Affected:

- (modified) flang/lib/Lower/OpenMP/DataSharingProcessor.cpp (+1-4) 


``````````diff
diff --git a/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp b/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp
index e2b55fcc64062..7df3905c29990 100644
--- a/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp
+++ b/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp
@@ -72,11 +72,8 @@ void DataSharingProcessor::processStep2(mlir::Operation *op, bool isLoop) {
     firOpBuilder.setInsertionPointAfter(op);
     insertDeallocs();
   } else {
-    // insert dummy instruction to mark the insertion position
-    mlir::Value undefMarker = firOpBuilder.create<fir::UndefOp>(
-        op->getLoc(), firOpBuilder.getIndexType());
+    mlir::OpBuilder::InsertionGuard guard(firOpBuilder);
     insertDeallocs();
-    firOpBuilder.setInsertionPointAfter(undefMarker.getDefiningOp());
   }
 }
 

``````````

</details>


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


More information about the flang-commits mailing list