[flang-commits] [flang] [flang] Implement lowering for the PAUSE statement (Fixes #166821) (PR #167115)

via flang-commits flang-commits at lists.llvm.org
Thu Nov 20 06:59:45 PST 2025


================
@@ -263,12 +263,56 @@ void Fortran::lower::genSyncTeamStatement(
 
 void Fortran::lower::genPauseStatement(
     Fortran::lower::AbstractConverter &converter,
-    const Fortran::parser::PauseStmt &) {
+    const Fortran::parser::PauseStmt &stmt) {
+  
   fir::FirOpBuilder &builder = converter.getFirOpBuilder();
   mlir::Location loc = converter.getCurrentLocation();
-  mlir::func::FuncOp callee =
-      fir::runtime::getRuntimeFunc<mkRTKey(PauseStatement)>(loc, builder);
-  fir::CallOp::create(builder, loc, callee, mlir::ValueRange{});
+  Fortran::lower::StatementContext stmtCtx;
+
+  llvm::SmallVector<mlir::Value> operands;
+  mlir::func::FuncOp callee;
+  mlir::FunctionType calleeType;
+
+  if (stmt.v.has_value()) {
+    const auto &code = stmt.v.value();
+    auto expr = converter.genExprValue(*Fortran::semantics::GetExpr(code), stmtCtx);
+    LLVM_DEBUG(llvm::dbgs() << "pause expression: "; expr.dump(); llvm::dbgs() << '\n');
----------------
jeanPerier wrote:

I do not think we should start using `LLVM_DEBUG` for that purpose in this file.
There are other driver options to dump expressions from the parse tree (like `-fc1 -fdebug-dump-parse-tree` or other `-fdebug` options) and there are just so many expressions being translated in this file that the output would be very verbose which would drawn the more structural info produced by this file with `LLVM_DEBUG`.

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


More information about the flang-commits mailing list