f18-llvm-project icon indicating copy to clipboard operation
f18-llvm-project copied to clipboard

F95 program without assumed rank arrays gets "not yet implemented Assumed Rank in procedure interface"

Open sscalpone opened this issue 4 years ago • 2 comments

program srk
  use,intrinsic :: ieee_exceptions
  integer,parameter :: k = selected_real_kind(15)
  real (k) :: r
  logical :: l
  l = ieee_support_flag(ieee_divide_by_zero,r)
end program
flang -c srk.f90 |& head -20
error: /proj/build/f18/Linux_x86_64/flang/lib/Lower/CallInterface.cpp:694: not yet implemented Assumed Rank in procedure interface
LLVM ERROR: aborting
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /proj/nv/f18/Linux_x86_64/install/bin/f18 -module-suffix .f18.mod -c srk.f90
 #0 0x00005572d546699d llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/proj/nv/f18/Linux_x86_64/install/bin/f18+0x28e399d)
 #1 0x00005572d5464894 llvm::sys::RunSignalHandlers() (/proj/nv/f18/Linux_x86_64/install/bin/f18+0x28e1894)
 #2 0x00005572d5464a0b SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f8e92312980 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12980)
 #4 0x00007f8e911a8fb7 raise /build/glibc-S9d2JN/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
 #5 0x00007f8e911aa921 abort /build/glibc-S9d2JN/glibc-2.27/stdlib/abort.c:81:0
 #6 0x00005572d53df026 llvm::report_fatal_error(llvm::Twine const&, bool) (/proj/nv/f18/Linux_x86_64/install/bin/f18+0x285c026)
 #7 0x00005572d53df148 (/proj/nv/f18/Linux_x86_64/install/bin/f18+0x285c148)
 #8 0x00005572d33f17b5 (/proj/nv/f18/Linux_x86_64/install/bin/f18+0x86e7b5)
 #9 0x00005572d415900a Fortran::lower::CallInterfaceImpl<Fortran::lower::CallerInterface>::handleExplicitDummy(Fortran::evaluate::characteristics::DummyArgument const*, Fortran::evaluate::characteristics::DummyDataObject const&, Fortran::evaluate::ActualArgument const* const&) (/proj/nv/f18/Linux_x86_64/install/bin/f18+0x15d600a)
#10 0x00005572d41593b5 std::__detail::__variant::__gen_vtable_impl<true, std::__detail::__variant::_Multi_array<void (*)(Fortran::common::visitors<Fortran::lower::CallInterfaceImpl<Fortran::lower::CallerInterface>::buildExplicitInterface(Fortran::evaluate::characteristics::Procedure const&)::'lambda'(Fortran::evaluate::characteristics::DummyDataObject const&), Fortran::lower::CallInterfaceImpl<Fortran::lower::CallerInterface>::buildExplicitInterface(Fortran::evaluate::characteristics::Procedure const&)::'lambda0'(Fortran::evaluate::characteristics::DummyProcedure const&), Fortran::lower::CallInterfaceImpl<Fortran::lower::CallerInterface>::buildExplicitInterface(Fortran::evaluate::characteristics::Procedure const&)::'lambda1'(Fortran::evaluate::characteristics::AlternateReturn const&)>&&, std::variant<Fortran::evaluate::characteristics::DummyDataObject, Fortran::evaluate::characteristics::DummyProcedure, Fortran::evaluate::characteristics::AlternateReturn> const&)>, std::tuple<std::variant<Fortran::evaluate::characteristics::DummyDataObject, Fortran::evaluate::characteristics::DummyProcedure, Fortran::evaluate::characteristics::AlternateReturn> const&>, std::integer_sequence<unsigned long, 0ul> >::__visit_invoke(Fortran::common::visitors<Fortran::lower::CallInterfaceImpl<Fortran::lower::CallerInterface>::buildExplicitInterface(Fortran::evaluate::characteristics::Procedure const&)::'lambda'(Fortran::evaluate::characteristics::DummyDataObject const&), Fortran::lower::CallInterfaceImpl<Fortran::lower::CallerInterface>::buildExplicitInterface(Fortran::evaluate::characteristics::Procedure const&)::'lambda0'(Fortran::evaluate::characteristics::DummyProcedure const&), Fortran::lower::CallInterfaceImpl<Fortran::lower::CallerInterface>::buildExplicitInterface(Fortran::evaluate::characteristics::Procedure const&)::'lambda1'(Fortran::evaluate::characteristics::AlternateReturn const&)>&&, std::variant<Fortran::evaluate::characteristics::DummyDataObject, Fortran::evaluate::characteristics::DummyProcedure, Fortran::evaluate::characteristics::AlternateReturn> const&) (/proj/nv/f18/Linux_x86_64/install/bin/f18+0x15d63b5)
#11 0x00005572d41563c2 Fortran::lower::CallInterface<Fortran::lower::CallerInterface>::determineInterface(bool, Fortran::evaluate::characteristics::Procedure const&) (/proj/nv/f18/Linux_x86_64/install/bin/f18+0x15d33c2)
#12 0x00005572d4156617 Fortran::lower::CallInterface<Fortran::lower::CallerInterface>::declare() (/proj/nv/f18/Linux_x86_64/install/bin/f18+0x15d3617)
#13 0x00005572d42cca8c (anonymous namespace)::ScalarExprLowering::genRawProcedureRef(Fortran::evaluate::ProcedureRef const&, llvm::Optional<mlir::Type>) ConvertExpr.cpp:0:0
#14 0x00005572d42cfcd5 (anonymous namespace)::ScalarExprLowering::genProcedureRef(Fortran::evaluate::ProcedureRef const&, llvm::Optional<mlir::Type>) ConvertExpr.cpp:0:0
...

sscalpone avatar Aug 10 '21 05:08 sscalpone

Quick analysis:

  • Isn't IEEE_SUPPORT_FLAG F2003 ?
  • The TODO is legit from a pure lowering point of view. Semantics is resolving IEEE_SUPPORT_FLAG to some function with an assumed rank second argument.
  • I can offer to try making a general TODO in lowering for IEEE functions. From what I understood in previous discussion, they will require lowering to do something special, and currently nothing is done with them (we are lowering their references as if they were user function for defined elsewhere). Does it sounds good to you to add a hard TODO regarding IEEE module functions ?

Note about IEEE functions: Currently I believe no one is working in IEEE functions implementation, it is not on our F95 roadmap. I believe they are technically F2003 because I cannot see them in earlier standards. Though they are probably a quite useful things to implement. Did you add the F95 keyword because they you found them in a program that is otherwise pure F95 ?

Rational of the current TODO:

The TODO looks legit to me because what lowering is seeing for this ieee_support_flag call was resolved to ieee_support_flag_8 declared in the intrinsic module flang/module/ieee_exceptions.f90 here. This can be observed by running f18 -funparse on the program. You can see that the second argument of ieee_support_flag_8 is indeed an assumed rank array. IEEE functions appears in lowering as normal procedures defined in special modules, they are not represented as the core Fortran intrinsics listed in F2018 section 16.7. Right now, lowering is not checking if a "normal" procedure is declared in an intrinsic module or not, hence they fall in the user function path and hit the TODO there.

jeanPerier avatar Aug 10 '21 09:08 jeanPerier

I am executing a test suite from before Fortran 2003. IEEE_SUPPORT_FLAG is from TR N1378. It is post 95 and pre 03. I suppose it is not strictly F95.

Technical Reports These are specifications of additional features intended to be included in the next revision of the standard. The intention is that compilers can begin implementation before the next revision is published.

Technical report 15580 extends Fortran 95 to provide access to features of IEEE arithmetic. The final draft is available as N1378.

sscalpone avatar Aug 10 '21 13:08 sscalpone