Skip to content

Commit 0e8d546

Browse files
[flang] Address review feedback
1 parent fd9d218 commit 0e8d546

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

flang/lib/Lower/Runtime.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,6 @@ void Fortran::lower::genPauseStatement(
276276
if (stmt.v.has_value()) {
277277
const auto &code = stmt.v.value();
278278
auto expr = converter.genExprValue(*Fortran::semantics::GetExpr(code), stmtCtx);
279-
LLVM_DEBUG(llvm::dbgs() << "pause expression: "; expr.dump(); llvm::dbgs() << '\n');
280279
expr.match(
281280
// Character-valued expression -> call PauseStatementText (CHAR, LEN)
282281
[&](const fir::CharBoxValue &x) {
@@ -290,7 +289,7 @@ void Fortran::lower::genPauseStatement(
290289
},
291290
// Numeric/unboxed value -> call PauseStatement which accepts an integer code.
292291
[&](fir::UnboxedValue x) {
293-
callee = fir::runtime::getRuntimeFunc<mkRTKey(PauseStatement)>(loc, builder);
292+
callee = fir::runtime::getRuntimeFunc<mkRTKey(PauseStatementInt)>(loc, builder);
294293
calleeType = callee.getFunctionType();
295294
if (calleeType.getNumInputs() >= 1) {
296295
mlir::Value cast =
@@ -299,7 +298,8 @@ void Fortran::lower::genPauseStatement(
299298
}
300299
},
301300
[&](auto) {
302-
mlir::emitError(loc, "unhandled expression in PAUSE");
301+
fir::emitFatalError(loc, "unhandled expression in PAUSE");
302+
// mlir::emitError(loc, "unhandled expression in PAUSE");
303303
std::exit(1);
304304
});
305305
} else {
@@ -309,10 +309,8 @@ void Fortran::lower::genPauseStatement(
309309

310310
fir::CallOp::create(builder, loc, callee, operands);
311311

312-
// NOTE: PAUSE should not unconditionally terminate the current block.
313-
// Unlike STOP, PAUSE does not necessarily abandon control flow, so do not
314-
// subsequent control flow (e.g. GOTO/branches) to be generated.
315-
// insert genUnreachable() here. Leaving the block un-terminated allows
312+
// NOTE: PAUSE does not terminate the current block. The program may resume
313+
// and continue normal execution, so we do not emit control-flow terminators.
316314
}
317315

318316
void Fortran::lower::genPointerAssociate(fir::FirOpBuilder &builder,

flang/test/Lower/pause-statement.f90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
! RUN: bbc %s -emit-fir -hlfir=false --canonicalize -o - | FileCheck %s
1+
! RUN: bbc %s -emit-fir --canonicalize -o - | FileCheck %s
22

33
! CHECK-LABEL: pause_test
44
subroutine pause_test()
@@ -10,7 +10,7 @@ subroutine pause_test()
1010
! CHECK-LABEL: pause_code
1111
subroutine pause_code()
1212
pause 42
13-
! CHECK: fir.call @_Fortran{{.*}}PauseStatement
13+
! CHECK: fir.call @_Fortran{{.*}}PauseStatementInt
1414
! CHECK-NEXT: return
1515
end subroutine
1616

@@ -26,4 +26,4 @@ subroutine pause_msg()
2626
end subroutine
2727

2828
! CHECK-DAG: func private @_Fortran{{.*}}PauseStatement
29-
! CHECK-DAG: func private @_Fortran{{.*}}PauseStatementText
29+
! CHECK-DAG: func private @_Fortran{{.*}}PauseStatementText

0 commit comments

Comments
 (0)