[flang-commits] [flang] [flang] Add EXECUTE_COMMAND_LINE runtime and lowering intrinsics implementation (PR #74077)

via flang-commits flang-commits at lists.llvm.org
Wed Dec 13 06:32:05 PST 2023


================
@@ -0,0 +1,51 @@
+! RUN: bbc -emit-fir %s -o - | FileCheck %s
+
+! CHECK-LABEL: func.func @_QPall_args_optional(
+! CHECK-SAME: %[[commandArg:.*]]: !fir.boxchar<1> {fir.bindc_name = "command", fir.optional},
+! CHECK-SAME: %[[waitArg:.*]]: !fir.ref<!fir.logical<4>> {fir.bindc_name = "iswait", fir.optional},
+! CHECK-SAME: %[[exitstatArg:.*]]: !fir.ref<i32> {fir.bindc_name = "exitval", fir.optional},
+! CHECK-SAME: %[[cmdstatArg:.*]]: !fir.ref<i32> {fir.bindc_name = "cmdval", fir.optional},
+! CHECK-SAME: %[[cmdmsgArg:.*]]: !fir.boxchar<1> {fir.bindc_name = "msg", fir.optional}) {
+subroutine all_args_optional(command, isWait, exitVal, cmdVal, msg)
+  CHARACTER(*), OPTIONAL :: command, msg
+  INTEGER, OPTIONAL :: exitVal, cmdVal
+  LOGICAL, OPTIONAL :: isWait
+  ! Note: command is not optional in execute_command_line and must be present
+  call execute_command_line(command, isWait, exitVal, cmdVal, msg)
+! CHECK:         %0 = fir.declare %[[cmdstatArg]] {fortran_attrs = #fir.var_attrs<optional>, uniq_name = "_QFall_args_optionalEcmdval"} : (!fir.ref<i32>) -> !fir.ref<i32>
----------------
jeanPerier wrote:

The test is using hard coded SSA numbers, this is brittle (especially when testing with -emit-fir which runs some high level pass like CSE).

You can use this script to help with the check generation: https://github.com/llvm/llvm-project/blob/main/mlir/utils/generate-test-checks.py

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


More information about the flang-commits mailing list