From d2f1f530430e9dbdd69c3ed173ced076f4bb933e Mon Sep 17 00:00:00 2001 From: Sourabh Singh Tomar Date: Fri, 25 Sep 2020 23:55:43 +0530 Subject: [PATCH] [flang][OpenMP] Place the insertion point to the start of the block After skeleton of the `Parallel Op` is created set the insertion point to start of the block. So that later `CodeGen` can proceed. Note: This patch reflects the work that can be upstreamed from PR(merged) PR: https://github.com/flang-compiler/f18-llvm-project/pull/424 Reviewed By: schweitz, kiranchandramohan Differential Revision: https://reviews.llvm.org/D88221 --- flang/lib/Lower/OpenMP.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/flang/lib/Lower/OpenMP.cpp b/flang/lib/Lower/OpenMP.cpp index 75ddfba..694ef7e 100644 --- a/flang/lib/Lower/OpenMP.cpp +++ b/flang/lib/Lower/OpenMP.cpp @@ -87,7 +87,6 @@ genOMP(Fortran::lower::AbstractConverter &converter, if (parallelDirective.v == llvm::omp::OMPD_parallel) { auto &firOpBuilder = converter.getFirOpBuilder(); auto currentLocation = converter.getCurrentLocation(); - auto insertPt = firOpBuilder.saveInsertionPoint(); // Clauses. // FIXME: Add support for other clauses. @@ -117,7 +116,9 @@ genOMP(Fortran::lower::AbstractConverter &converter, firOpBuilder.setInsertionPointToStart(&block); // Ensure the block is well-formed. firOpBuilder.create(currentLocation); - firOpBuilder.restoreInsertionPoint(insertPt); + + // Place the insertion point to the start of the first block. + firOpBuilder.setInsertionPointToStart(&block); } } -- 2.7.4