diff --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp --- a/flang/lib/Lower/Bridge.cpp +++ b/flang/lib/Lower/Bridge.cpp @@ -547,7 +547,7 @@ } void genFIR(const Fortran::parser::PauseStmt &stmt) { - TODO(toLocation(), "PauseStmt lowering"); + genPauseStatement(*this, stmt); } void genFIR(const Fortran::parser::FailImageStmt &stmt) { diff --git a/flang/lib/Lower/Runtime.cpp b/flang/lib/Lower/Runtime.cpp --- a/flang/lib/Lower/Runtime.cpp +++ b/flang/lib/Lower/Runtime.cpp @@ -73,3 +73,13 @@ builder.create(loc, callee, operands); genUnreachable(builder, loc); } + +void Fortran::lower::genPauseStatement( + Fortran::lower::AbstractConverter &converter, + const Fortran::parser::PauseStmt &) { + fir::FirOpBuilder &builder = converter.getFirOpBuilder(); + mlir::Location loc = converter.getCurrentLocation(); + mlir::FuncOp callee = + fir::runtime::getRuntimeFunc(loc, builder); + builder.create(loc, callee, llvm::None); +} diff --git a/flang/test/Lower/pause-statement.f90 b/flang/test/Lower/pause-statement.f90 new file mode 100644 --- /dev/null +++ b/flang/test/Lower/pause-statement.f90 @@ -0,0 +1,8 @@ +! RUN: bbc %s -emit-fir -o - | FileCheck %s + +! CHECK-LABEL pause_test +subroutine pause_test() + ! CHECK: fir.call @_Fortran{{.*}}PauseStatement() + ! CHECK-NEXT: return + pause +end subroutine