[PATCH] D118993: [flang] Handle character constant for error code in STOP stmt
Valentin Clement via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 4 06:29:18 PST 2022
clementval created this revision.
clementval added reviewers: jeanPerier, kiranchandramohan, PeteSteinfeld, schweitz, svedanayagam.
Herald added a subscriber: mehdi_amini.
Herald added a project: Flang.
clementval requested review of this revision.
Herald added subscribers: llvm-commits, jdoerfert.
Herald added a project: LLVM.
Handle character constant ofr error code in the STOP statement.
Depends on D118992 <https://reviews.llvm.org/D118992>
This patch is part of the upstreaming effort from fir-dev branch.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D118993
Files:
flang/lib/Lower/Runtime.cpp
flang/test/Lower/stop-statement.f90
Index: flang/test/Lower/stop-statement.f90
===================================================================
--- flang/test/Lower/stop-statement.f90
+++ flang/test/Lower/stop-statement.f90
@@ -38,3 +38,15 @@
! CHECK: fir.call @_Fortran{{.*}}StopStatement(%[[c0]], %[[false]], %[[true]])
! CHECK-NEXT: fir.unreachable
end subroutine
+
+! CHECK-LABEL stop_char_lit
+subroutine stop_char_lit
+ ! CHECK-DAG: %[[false:.*]] = arith.constant false
+ ! CHECK-DAG: %[[five:.*]] = arith.constant 5 : index
+ ! CHECK-DAG: %[[lit:.*]] = fir.address_of(@_QQ{{.*}}) : !fir.ref<!fir.char<1,5>>
+ ! CHECK-DAG: %[[buff:.*]] = fir.convert %[[lit]] : (!fir.ref<!fir.char<1,5>>) -> !fir.ref<i8>
+ ! CHECK-DAG: %[[len:.*]] = fir.convert %[[five]] : (index) -> i64
+ ! CHECK: fir.call @{{.*}}StopStatementText(%[[buff]], %[[len]], %[[false]], %[[false]]) :
+ ! CHECK-NEXT: fir.unreachable
+ stop 'crash'
+end subroutine stop_char_lit
Index: flang/lib/Lower/Runtime.cpp
===================================================================
--- flang/lib/Lower/Runtime.cpp
+++ flang/lib/Lower/Runtime.cpp
@@ -49,7 +49,14 @@
llvm::dbgs() << '\n');
expr.match(
[&](const fir::CharBoxValue &x) {
- TODO(loc, "STOP CharBoxValue first operand not lowered yet");
+ callee = fir::runtime::getRuntimeFunc<mkRTKey(StopStatementText)>(
+ loc, builder);
+ calleeType = callee.getType();
+ // Creates a pair of operands for the CHARACTER and its LEN.
+ operands.push_back(
+ builder.createConvert(loc, calleeType.getInput(0), x.getAddr()));
+ operands.push_back(
+ builder.createConvert(loc, calleeType.getInput(1), x.getLen()));
},
[&](fir::UnboxedValue x) {
callee = fir::runtime::getRuntimeFunc<mkRTKey(StopStatement)>(
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118993.405946.patch
Type: text/x-patch
Size: 1852 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220204/c2d66415/attachment.bin>
More information about the llvm-commits
mailing list