[flang-commits] [flang] [flang] Use `createOpWithBody` for section op, NFC (PR #74659)

Krzysztof Parzyszek via flang-commits flang-commits at lists.llvm.org
Wed Dec 6 14:04:07 PST 2023


https://github.com/kparzysz created https://github.com/llvm/llvm-project/pull/74659

Replace explicit calls to
```
  op = builder.create<SectionOp>(...)
  createBodyOfOp<SectionOp>(op, ...)
```
with a single call to
```
  createOpWithBody<SectionOp>(...)
```

This is NFC, that's what the `createOpWithBody` function does.

>From ffe19f9f43fb671a107c093bf75ef5c75b693d98 Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek <Krzysztof.Parzyszek at amd.com>
Date: Wed, 6 Dec 2023 15:56:01 -0600
Subject: [PATCH] [flang] Use `createOpWithBody` for section op, NFC

Replace explicit calls to
```
  op = builder.create<SectionOp>(...)
  createBodyOfOp<SectionOp>(op, ...)
```
with a single call to
```
  createOpWithBody<SectionOp>(...)
```

This is NFC, that's what the `createOpWithBody` function does.
---
 flang/lib/Lower/OpenMP.cpp | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/flang/lib/Lower/OpenMP.cpp b/flang/lib/Lower/OpenMP.cpp
index 0fa1ac76d57edb..31d5df040c5d69 100644
--- a/flang/lib/Lower/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP.cpp
@@ -3233,7 +3233,6 @@ static void
 genOMP(Fortran::lower::AbstractConverter &converter,
        Fortran::lower::pft::Evaluation &eval,
        const Fortran::parser::OpenMPSectionConstruct &sectionConstruct) {
-  fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
   mlir::Location currentLocation = converter.getCurrentLocation();
   const Fortran::parser::OpenMPConstruct *parentOmpConstruct =
       eval.parentConstruct->getIf<Fortran::parser::OpenMPConstruct>();
@@ -3251,10 +3250,9 @@ genOMP(Fortran::lower::AbstractConverter &converter,
               .t);
   // Currently only private/firstprivate clause is handled, and
   // all privatization is done within `omp.section` operations.
-  mlir::omp::SectionOp sectionOp =
-      firOpBuilder.create<mlir::omp::SectionOp>(currentLocation);
-  createBodyOfOp<mlir::omp::SectionOp>(sectionOp, converter, currentLocation,
-                                       eval, &sectionsClauseList);
+  genOpWithBody<mlir::omp::SectionOp>(converter, eval, currentLocation,
+                                      /*outerCombined=*/false,
+                                      &sectionsClauseList);
 }
 
 static void



More information about the flang-commits mailing list