This is an archive of the discontinued LLVM Phabricator instance.

[flang] Handle parent component in user function argument
ClosedPublic

Authored by clementval on Mar 13 2023, 5:39 AM.

Details

Summary

When the argument is a parent component the box needs to
be updated to reflect the correct type. Use updateBoxForParentComponent
to update the argument accordingly.

Depends on D145907

Diff Detail

Event Timeline

clementval created this revision.Mar 13 2023, 5:39 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptMar 13 2023, 5:39 AM
clementval requested review of this revision.Mar 13 2023, 5:39 AM
PeteSteinfeld edited the summary of this revision. (Show Details)Mar 13 2023, 6:37 AM
PeteSteinfeld requested changes to this revision.Mar 13 2023, 7:03 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/928/flang/test/Lower/polymorphic.f90 -o - | /local/home/psteinfeld/main/928/build/bin/FileCheck /local/home/psteinfeld/main/928/flang/test/Lower/polymorphic.f90
--
Exit Code: 2

Command Output (stderr):
--
bbc: /local/home/psteinfeld/main/928/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/928/flang/test/Lower/polymorphic.f90 -o -
 #0 0x0000563e3b5b253b llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/home/psteinfeld/main/928/build/bin/bbc+0x1c7b53b)
 #1 0x0000563e3b5afdb4 SignalHandler(int) Signals.cpp:0:0
 #2 0x0000147555a4fc20 __restore_rt sigaction.c:0:0
 #3 0x000014755423e37f raise (/lib64/libc.so.6+0x3737f)
 #4 0x0000147554228db5 abort (/lib64/libc.so.6+0x21db5)
 #5 0x0000147554228c89 _nl_load_domain.cold.0 loadmsgcat.c:0:0
 #6 0x0000147554236a76 .annobin___GI___assert_fail.end assert.c:0:0
 #7 0x0000563e3a86bc36 Fortran::lower::updateBoxForParentComponent(Fortran::lower::AbstractConverter&, fir::ExtendedValue, Fortran::evaluate::Expr<Fortran::evaluate::SomeType> const&) (/local/home/psteinfeld/main/928/build/bin/bbc+0xf34c36)
 #8 0x0000563e3a95b16a (anonymous namespace)::ScalarExprLowering::genRawProcedureRef(Fortran::evaluate::ProcedureRef const&, std::optional<mlir::Type>) ConvertExpr.cpp:0:0
 #9 0x0000563e3a95b7d3 (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:03 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/928/flang/test/Lower/polymorphic.f90 -o - | /local/home/psteinfeld/main/928/build/bin/FileCheck /local/home/psteinfeld/main/928/flang/test/Lower/polymorphic.f90
--
Exit Code: 2

Command Output (stderr):
--
bbc: /local/home/psteinfeld/main/928/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/928/flang/test/Lower/polymorphic.f90 -o -
 #0 0x0000563e3b5b253b llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/home/psteinfeld/main/928/build/bin/bbc+0x1c7b53b)
 #1 0x0000563e3b5afdb4 SignalHandler(int) Signals.cpp:0:0
 #2 0x0000147555a4fc20 __restore_rt sigaction.c:0:0
 #3 0x000014755423e37f raise (/lib64/libc.so.6+0x3737f)
 #4 0x0000147554228db5 abort (/lib64/libc.so.6+0x21db5)
 #5 0x0000147554228c89 _nl_load_domain.cold.0 loadmsgcat.c:0:0
 #6 0x0000147554236a76 .annobin___GI___assert_fail.end assert.c:0:0
 #7 0x0000563e3a86bc36 Fortran::lower::updateBoxForParentComponent(Fortran::lower::AbstractConverter&, fir::ExtendedValue, Fortran::evaluate::Expr<Fortran::evaluate::SomeType> const&) (/local/home/psteinfeld/main/928/build/bin/bbc+0xf34c36)
 #8 0x0000563e3a95b16a (anonymous namespace)::ScalarExprLowering::genRawProcedureRef(Fortran::evaluate::ProcedureRef const&, std::optional<mlir::Type>) ConvertExpr.cpp:0:0
 #9 0x0000563e3a95b7d3 (anonymous namespace)::ScalarExprLowering::genProcedureRef(Fortran::evaluate::ProcedureRef const&, std::optional<mlir::Type>) ConvertExpr.cpp:0:0

I added https://reviews.llvm.org/D145910 as a dependency. This should fix the issue.

Remove conflict

Clean up the mess

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

All builds and tests correctly and looks good.

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