-
Notifications
You must be signed in to change notification settings - Fork 10.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[flang] Lower BIND(C) assumed length to CFI descriptor #65950
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I build and run tests, I get an assertion. Here's the relevant excerpt from the log file:
FAIL: Flang :: Lower/HLFIR/bindc-assumed-length.f90 (1994 of 2453)
******************** TEST 'Flang :: Lower/HLFIR/bindc-assumed-length.f90' FAILED ********************
Script:
--
: 'RUN: at line 4'; bbc -emit-hlfir -o - /local/home/psteinfeld/main/llvm-project/flang/test/Lower/HLFIR/bindc-assumed-length.f90 2>&1 | /local/home/psteinfeld/main/llvm-project/build/bin/FileCheck /local/home/psteinfeld/main/llvm-project/flang/test/Lower/HLFIR/bindc-assumed-length.f90
--
Exit Code: 1
Command Output (stderr):
--
/local/home/psteinfeld/main/llvm-project/flang/test/Lower/HLFIR/bindc-assumed-length.f90:6:10: error: CHECK: expected string not found in input
! CHECK: func.func @foo(
^
<stdin>:1:1: note: scanning from here
bbc: /local/home/psteinfeld/main/llvm-project/flang/include/flang/Optimizer/Builder/BoxValue.h:300: fir::BoxValue::BoxValue(mlir::Value, llvm::ArrayRef<mlir::Value>, llvm::ArrayRef<mlir::Value>, llvm::ArrayRef<mlir::Value>): Assertion `verify()' failed.
^
<stdin>:16:63: note: possible intended match here
#11 0x0000556c5465d0c8 (anonymous namespace)::FirConverter::startNewFunction(Fortran::lower::pft::FunctionLikeUnit&) Bridge.cpp:0:0
^
Input file: <stdin>
Check file: /local/home/psteinfeld/main/llvm-project/flang/test/Lower/HLFIR/bindc-assumed-length.f90
-dump-input=help explains the following input dump.
Input was:
<<<<<<
1: bbc: /local/home/psteinfeld/main/llvm-project/flang/include/flang/Optimizer/Builder/BoxValue.h:300: fir::BoxValue::BoxValue(mlir::Value, llvm::ArrayRef<mlir::Value>, llvm::ArrayRef<mlir::Value>, llvm::ArrayRef<mlir::Value>): Assertion `verify()' failed.
check:6'0 X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
2: PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
check:6'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3: Stack dump:
check:6'0 ~~~~~~~~~~~~
4: 0. Program arguments: bbc -emit-hlfir -o - /local/home/psteinfeld/main/llvm-project/flang/test/Lower/HLFIR/bindc-assumed-length.f90
check:6'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5: #0 0x0000556c5553326b llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/home/psteinfeld/main/llvm-project/build/bin/bbc+0x21ad26b)
check:6'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6: #1 0x0000556c55530924 SignalHandler(int) Signals.cpp:0:0
check:6'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.
.
.
11: #6 0x00007f9e23f5da76 .annobin___GI___assert_fail.end assert.c:0:0
check:6'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12: #7 0x0000556c548e96c0 genBoxDeclare(Fortran::lower::AbstractConverter&, Fortran::lower::SymMap&, Fortran::semantics::Symbol const&, mlir::Value, llvm::ArrayRef<mlir::Value>, llvm::ArrayRef<mlir::Value>, llvm::ArrayRef<mlir::Value>, bool) ConvertVariable.cpp:0:0
check:6'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13: #8 0x0000556c548ea35e Fortran::lower::mapSymbolAttributes(Fortran::lower::AbstractConverter&, Fortran::lower::pft::Variable const&, Fortran::lower::SymMap&, Fortran::lower::StatementContext&, mlir::Value) (/local/home/psteinfeld/main/llvm-project/build/bin/bbc+0x156435e)
check:6'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14: #9 0x0000556c548eca7c Fortran::lower::instantiateVariable(Fortran::lower::AbstractConverter&, Fortran::lower::pft::Variable const&, Fortran::lower::SymMap&, llvm::DenseMap<std::tuple<Fortran::semantics::Scope const*, unsigned long>, mlir::Value, llvm::DenseMapInfo<std::tuple<Fortran::semantics::Scope const*, unsigned long>, void>, llvm::detail::DenseMapPair<std::tuple<Fortran::semantics::Scope const*, unsigned long>, mlir::Value>>&) (/local/home/psteinfeld/main/llvm-project/build/bin/bbc+0x1566a7c)
check:6'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15: #10 0x0000556c54623c6c (anonymous namespace)::FirConverter::instantiateVar(Fortran::lower::pft::Variable const&, llvm::DenseMap<std::tuple<Fortran::semantics::Scope const*, unsigned long>, mlir::Value, llvm::DenseMapInfo<std::tuple<Fortran::semantics::Scope const*, unsigned long>, void>, llvm::detail::DenseMapPair<std::tuple<Fortran::semantics::Scope const*, unsigned long>, mlir::Value>>&) Bridge.cpp:0:0
check:6'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
16: #11 0x0000556c5465d0c8 (anonymous namespace)::FirConverter::startNewFunction(Fortran::lower::pft::FunctionLikeUnit&) Bridge.cpp:0:0
check:6'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
check:6'1 ? possible intended match
17: #12 0x0000556c5465e06e (anonymous namespace)::FirConverter::lowerFunc(Fortran::lower::pft::FunctionLikeUnit&) Bridge.cpp:0:0
check:6'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18: #13 0x0000556c54653f17 Fortran::lower::LoweringBridge::lower(Fortran::parser::Program const&, Fortran::semantics::SemanticsContext const&) (/local/home/psteinfeld/main/llvm-project/build/bin/bbc+0x12cdf17)
check:6'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19: #14 0x0000556c53533e93 main (/local/home/psteinfeld/main/llvm-project/build/bin/bbc+0x1ade93)
check:6'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20: #15 0x00007f9e23f51493 __libc_start_main (/lib64/libc.so.6+0x23493)
check:6'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
21: #16 0x0000556c535457ee _start (/local/home/psteinfeld/main/llvm-project/build/bin/bbc+0x1bf7ee)
check:6'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>>>>
--
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Thanks Pete, I could reproduce and added a fix. There was an assert that was not valid anymore and some more work on the callee side since lowering code is not meant to track scalar characters as descriptors. |
Thanks, Jean. All looks good now. |
Outside of BIND(C), assumed length character scalar and explicit shape are passed by address + an extra length argument (fir.boxchar in FIR). The standard mandates that they be passed via CFI descriptor in BIND(C) interface (fir.box in FIR). This patch fix the handling for this case.
Lowering hit and assert with the previous patch because it is not meant to manipulate scalars characters as fir.box. Add the code to open the fir.box of BIND(C) characters on the callee side, taking care of dealing with the case where the fir.box is optional and cannot be addressed unconditionally.
191d579
to
4b1846f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All builds and tests correctly and looks good.
Outside of BIND(C), assumed length character scalar and explicit shape are passed by address + an extra length argument (fir.boxchar in FIR). The standard mandates that they be passed via CFI descriptor in BIND(C) interface (fir.box in FIR). This patch fix the handling for this case.
Outside of BIND(C), assumed length character scalar and explicit shape are passed by address + an extra length argument (fir.boxchar in FIR).
The standard mandates that they be passed via CFI descriptor in BIND(C) interface (fir.box in FIR). This patch fix the handling for this case.