diff --git a/flang/lib/Lower/OpenMP.cpp b/flang/lib/Lower/OpenMP.cpp --- a/flang/lib/Lower/OpenMP.cpp +++ b/flang/lib/Lower/OpenMP.cpp @@ -87,7 +87,6 @@ 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 @@ 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); } }