This is an archive of the discontinued LLVM Phabricator instance.

[flang] Handle parent component in user function argument for special cases
ClosedPublic

Authored by clementval on Mar 13 2023, 6:11 AM.

Details

Summary

In some cases the argument is already handled by a fir.rebox operation. Just
adapat the type to match the parent component in that case.

Depends on D145928

Diff Detail

Event Timeline

clementval created this revision.Mar 13 2023, 6:11 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptMar 13 2023, 6:11 AM
clementval requested review of this revision.Mar 13 2023, 6:11 AM
PeteSteinfeld requested changes to this revision.Mar 13 2023, 7:06 AM

I get errors from check-flang:

******************** TEST 'Flang :: Lower/polymorphic.f90' FAILED ********************
Script:
--
: 'RUN: at line 1';   bbc -polymorphic-type -emit-fir /local/home/psteinfeld/main/931/flang/test/Lower/polymorphic.f90 -o - | /local/home/psteinfeld/main/931/build/bin/FileCheck /local/home/psteinfeld/main/931/flang/test/Lower/polymorphic.f90
--
Exit Code: 2

Command Output (stderr):
--
bbc: /local/home/psteinfeld/main/931/llvm/include/llvm/Support/Casting.h:663: decltype(auto) llvm::dyn_cast(From*) [with To = fir::EmboxOp; From = mlir::Operation]: Assertion `detail::isPresent(Val) && "dyn_cast on a non-existent value"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: bbc -polymorphic-type -emit-fir /local/home/psteinfeld/main/931/flang/test/Lower/polymorphic.f90 -o -
 #0 0x00005651e153756b llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/home/psteinfeld/main/931/build/bin/bbc+0x1c7b56b)
 #1 0x00005651e1534de4 SignalHandler(int) Signals.cpp:0:0
 #2 0x000014887cdfdc20 __restore_rt sigaction.c:0:0
 #3 0x000014887b5ec37f raise (/lib64/libc.so.6+0x3737f)
 #4 0x000014887b5d6db5 abort (/lib64/libc.so.6+0x21db5)
 #5 0x000014887b5d6c89 _nl_load_domain.cold.0 loadmsgcat.c:0:0
 #6 0x000014887b5e4a76 .annobin___GI___assert_fail.end assert.c:0:0
 #7 0x00005651e07f0c36 Fortran::lower::updateBoxForParentComponent(Fortran::lower::AbstractConverter&, fir::ExtendedValue, Fortran::evaluate::Expr<Fortran::evaluate::SomeType> const&) (/local/home/psteinfeld/main/931/build/bin/bbc+0xf34c36)
 #8 0x00005651e08e01a2 (anonymous namespace)::ScalarExprLowering::genRawProcedureRef(Fortran::evaluate::ProcedureRef const&, std::optional<mlir::Type>) ConvertExpr.cpp:0:0
 #9 0x00005651e08e0803 (anonymous namespace)::ScalarExprLowering::genProcedureRef(Fortran::evaluate::ProcedureRef const&, std::optional<mlir::Type>) ConvertExpr.cpp:0:0
This revision now requires changes to proceed.Mar 13 2023, 7:06 AM

I get errors from check-flang:

******************** TEST 'Flang :: Lower/polymorphic.f90' FAILED ********************
Script:
--
: 'RUN: at line 1';   bbc -polymorphic-type -emit-fir /local/home/psteinfeld/main/931/flang/test/Lower/polymorphic.f90 -o - | /local/home/psteinfeld/main/931/build/bin/FileCheck /local/home/psteinfeld/main/931/flang/test/Lower/polymorphic.f90
--
Exit Code: 2

Command Output (stderr):
--
bbc: /local/home/psteinfeld/main/931/llvm/include/llvm/Support/Casting.h:663: decltype(auto) llvm::dyn_cast(From*) [with To = fir::EmboxOp; From = mlir::Operation]: Assertion `detail::isPresent(Val) && "dyn_cast on a non-existent value"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: bbc -polymorphic-type -emit-fir /local/home/psteinfeld/main/931/flang/test/Lower/polymorphic.f90 -o -
 #0 0x00005651e153756b llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/home/psteinfeld/main/931/build/bin/bbc+0x1c7b56b)
 #1 0x00005651e1534de4 SignalHandler(int) Signals.cpp:0:0
 #2 0x000014887cdfdc20 __restore_rt sigaction.c:0:0
 #3 0x000014887b5ec37f raise (/lib64/libc.so.6+0x3737f)
 #4 0x000014887b5d6db5 abort (/lib64/libc.so.6+0x21db5)
 #5 0x000014887b5d6c89 _nl_load_domain.cold.0 loadmsgcat.c:0:0
 #6 0x000014887b5e4a76 .annobin___GI___assert_fail.end assert.c:0:0
 #7 0x00005651e07f0c36 Fortran::lower::updateBoxForParentComponent(Fortran::lower::AbstractConverter&, fir::ExtendedValue, Fortran::evaluate::Expr<Fortran::evaluate::SomeType> const&) (/local/home/psteinfeld/main/931/build/bin/bbc+0xf34c36)
 #8 0x00005651e08e01a2 (anonymous namespace)::ScalarExprLowering::genRawProcedureRef(Fortran::evaluate::ProcedureRef const&, std::optional<mlir::Type>) ConvertExpr.cpp:0:0
 #9 0x00005651e08e0803 (anonymous namespace)::ScalarExprLowering::genProcedureRef(Fortran::evaluate::ProcedureRef const&, std::optional<mlir::Type>) ConvertExpr.cpp:0:0

I get errors from check-flang:

******************** TEST 'Flang :: Lower/polymorphic.f90' FAILED ********************
Script:
--
: 'RUN: at line 1';   bbc -polymorphic-type -emit-fir /local/home/psteinfeld/main/931/flang/test/Lower/polymorphic.f90 -o - | /local/home/psteinfeld/main/931/build/bin/FileCheck /local/home/psteinfeld/main/931/flang/test/Lower/polymorphic.f90
--
Exit Code: 2

Command Output (stderr):
--
bbc: /local/home/psteinfeld/main/931/llvm/include/llvm/Support/Casting.h:663: decltype(auto) llvm::dyn_cast(From*) [with To = fir::EmboxOp; From = mlir::Operation]: Assertion `detail::isPresent(Val) && "dyn_cast on a non-existent value"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: bbc -polymorphic-type -emit-fir /local/home/psteinfeld/main/931/flang/test/Lower/polymorphic.f90 -o -
 #0 0x00005651e153756b llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/home/psteinfeld/main/931/build/bin/bbc+0x1c7b56b)
 #1 0x00005651e1534de4 SignalHandler(int) Signals.cpp:0:0
 #2 0x000014887cdfdc20 __restore_rt sigaction.c:0:0
 #3 0x000014887b5ec37f raise (/lib64/libc.so.6+0x3737f)
 #4 0x000014887b5d6db5 abort (/lib64/libc.so.6+0x21db5)
 #5 0x000014887b5d6c89 _nl_load_domain.cold.0 loadmsgcat.c:0:0
 #6 0x000014887b5e4a76 .annobin___GI___assert_fail.end assert.c:0:0
 #7 0x00005651e07f0c36 Fortran::lower::updateBoxForParentComponent(Fortran::lower::AbstractConverter&, fir::ExtendedValue, Fortran::evaluate::Expr<Fortran::evaluate::SomeType> const&) (/local/home/psteinfeld/main/931/build/bin/bbc+0xf34c36)
 #8 0x00005651e08e01a2 (anonymous namespace)::ScalarExprLowering::genRawProcedureRef(Fortran::evaluate::ProcedureRef const&, std::optional<mlir::Type>) ConvertExpr.cpp:0:0
 #9 0x00005651e08e0803 (anonymous namespace)::ScalarExprLowering::genProcedureRef(Fortran::evaluate::ProcedureRef const&, std::optional<mlir::Type>) ConvertExpr.cpp:0:0

Also added the dependency

PeteSteinfeld accepted this revision.Mar 13 2023, 9:54 AM

All builds and tests correctly and looks good.

This revision is now accepted and ready to land.Mar 13 2023, 9:54 AM