[flang-commits] [PATCH] D123388: [flang] Lower optionals in GET_COMMAND_ARGUMENT and GET_ENVIRONMENT_VARIABLE

Jean Perier via Phabricator via flang-commits flang-commits at lists.llvm.org
Fri Apr 8 06:50:31 PDT 2022


jeanPerier created this revision.
jeanPerier added reviewers: clementval, schweitz, josh.mottley.arm.
jeanPerier added a project: Flang.
Herald added subscribers: mehdi_amini, jdoerfert.
Herald added a project: All.
jeanPerier requested review of this revision.

Handle dynamic optional argument in GET_COMMAND_ARGUMENT and GET_ENVIRONMENT_VARIABLE
(previously compiled but caused segfaults). The previous code
handled static presence/absence aspects, but not when an absent dummy optional was
passed to one of the optional intrinsic arguments.

Simplify the runtime call lowering to simply lower the runtime call without
dealing with optionality there. This keeps the optional handling logic in
IntrinsicCall.cpp.

Note that the new code will generate some extra "if (not null addr )/then/else"
when the actual arguments are always there at runtime. That makes the implementation
a lot simpler/safer, and I think it is OK for now (I do not expect these runtime
function to be called in hot loop nests).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D123388

Files:
  flang/include/flang/Optimizer/Builder/FIRBuilder.h
  flang/include/flang/Optimizer/Builder/Runtime/Command.h
  flang/lib/Lower/IntrinsicCall.cpp
  flang/lib/Optimizer/Builder/FIRBuilder.cpp
  flang/lib/Optimizer/Builder/Runtime/Command.cpp
  flang/test/Lower/Intrinsics/get_command_argument-optional.f90
  flang/test/Lower/Intrinsics/get_command_argument.f90
  flang/test/Lower/Intrinsics/get_environment_variable-optional.f90
  flang/test/Lower/Intrinsics/get_environment_variable.f90
  flang/unittests/Optimizer/Builder/Runtime/CommandTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123388.421513.patch
Type: text/x-patch
Size: 46912 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220408/8dfe245a/attachment-0001.bin>


More information about the flang-commits mailing list