[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
Mon Feb 7 03:20:13 PST 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa8d48fe0fe52: [flang] Handle character constant for error code in STOP stmt (authored by clementval).
Changed prior to commit:
https://reviews.llvm.org/D118993?vs=405946&id=406378#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D118993/new/
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
@@ -51,3 +51,15 @@
! CHECK: fir.call @_Fortran{{.*}}StopStatement(%[[c0]], %[[false]], %[[bi1]])
! 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.406378.patch
Type: text/x-patch
Size: 1851 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220207/d10a93b3/attachment.bin>
More information about the llvm-commits
mailing list