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

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


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

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.

>From c77d8ee15baf9b34f6afaf349692537c6812ca75 Mon Sep 17 00:00:00 2001
From: Sergio Afonso <safonsof at amd.com>
Date: Wed, 3 Jul 2024 11:40:42 +0100
Subject: [PATCH] [Flang][OpenMP] Use InsertionGuard in DataSharingProcessor

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.
---
 flang/lib/Lower/OpenMP/DataSharingProcessor.cpp | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

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());
   }
 }
 



More information about the flang-commits mailing list