flang-compiler / f18-llvm-project Goto Github PK
View Code? Open in Web Editor NEWThis project forked from llvm/llvm-project
Fork of llvm/llvm-project for f18. In sync with f18-mlir and f18.
Home Page: http://llvm.org
This project forked from llvm/llvm-project
Fork of llvm/llvm-project for f18. In sync with f18-mlir and f18.
Home Page: http://llvm.org
Taking lapack from http://www.netlib.org/lapack/lapack-lite-3.1.0.tgz
Compile command of cd SRC; bbc stgevc.f
Also see bbc slaebz.f
, dlaebz.f
, etc.
We get a stack trace pointing to PFT.
#9 0x0000000002148d09 Fortran::lower::pft::Evaluation::isIntermediateConstructStmt() const /f18-llvm-project/flang/include/flang/Lower/PFTBuilder.h:222:5
#10 0x00000000020e9c33 (anonymous namespace)::FirConverter::genFIR(Fortran::lower::pft::Evaluation&, bool) /f18-llvm-project/flang/lib/Lower/Bridge.cpp:1598:16
e.g.,
ASSIGN 1010 TO i
1010 FORMAT ...
WRITE(i02, i)
[ 7%] Building Fortran object SRC/CMakeFiles/lapack.dir/spstrf.f.o
LLVM ERROR: missing intrinsic: maxloc
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
(Source is https://github.com/Reference-LAPACK/lapack.git)
See also spstf2.f, dpstrf.f, dpstf2.f, cpstrf.f, cpstf2.f, zpstrf.f, zpstf2.f
fm401.f:375: undefined reference to
_FortranAioBeginRewind'
`
flang fm024.o -o fm024.out
./fm024.out > fm024.log
IEEE arithmetic exceptions signaled: INEXACT diff fm024.log
650 FAIL -1 32767
With a small snippet to implement IOLENGTH
of INQUIRE
statement I see stack trace from ConvertExpr
causing issue.
I tried adding a snippet as
const auto *intVar{std::get_if<parser::InquireStmt::Iolength>(&stmt.u)};
auto unit = converter.genExprAddr(*Fortran::semantics::GetExpr(*intVar));
after querying the InquireStmt
variant .
I have no idea what this stack trace represents.
I am not sure is that a genuine issue or due to some incomplete implementation.
2. - #8 0x000055d4eae6f0b8 fir::ExtendedValue (anonymous namespace)::ExprLowering::gen<Fortran::evaluate::SomeType>(Fortran::evaluate:> const&) **/home/amd/f18_git/firdev/f18-llvm-project/flang/lib/Lower/ConvertExpr.cpp:1305:3**
3. - #9 0x000055d4eae6646c (anonymous namespace)::ExprLowering::gen() /home/amd/f18_git/firdev/f18-llvm-project/flang/lib/Lower/ConverExpr.cpp:52:52
4. - #10 0x000055d4eae6cd94 Fortran::lower::createSomeAddress(mlir::Location, Fortran::lower::AbstractConverter&, Fortran::evaluate::Exonst&, Fortran::lower::SymMap&) /home/amd/f18_git/firdev/f18-llvm-project/flang/lib/Lower/ConvertExpr.cpp:1378:57
5. - #11 0x000055d4eade552d (anonymous namespace)::FirConverter::createFIRAddr(mlir::Location, Fortran::evaluate::Expr<Fortran::evaluat8_git/firdev/f18-llvm-project/flang/lib/Lower/Bridge.cpp:384:3
6. - #12 0x000055d4eade4dcf (anonymous namespace)::FirConverter::genExprAddr(Fortran::evaluate::Expr<Fortran::evaluate::SomeType> const_git/firdev/f18-llvm-project/flang/lib/Lower/Bridge.cpp:281:3
7. - #13 0x000055d4eaf28ec9 Fortran::lower::genInquireStatement(Fortran::lower::AbstractConverter&, Fortran::parser::InquireStmt const&vm-project/flang/lib/Lower/IO.cpp:1471:78
8. - #14 0x000055d4eade9c23 (anonymous namespace)::FirConverter::genFIR(Fortran::parser::InquireStmt const&) /home/amd/f18_git/firdev/Bridge.cpp:1108:50
flang -c fm255.f
fm255.f:909:2: Label '164' is not in scope
0162 GO TO 0164
^^^^^^^^^^^^^^^
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0. Program arguments: f18 -module-suffix .f18.mod -intrinsic-module-directory flang/install/include/flang -c fm255.f
#0 0x00005601da0be80a llvm::sys::PrintStackTrace(llvm::raw_ostream&) (f18+0x1fb80a)
#1 0x00005601da0bc7d4 llvm::sys::RunSignalHandlers() (f18+0x1f97d4)
#2 0x00005601da0bc918 SignalHandler(int) (f18+0x1f9918)
#3 0x00007f4f7df75890 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12890)
#4 0x00005601dadbfbfc mlir::Operation::create(mlir::Location, mlir::OperationName, llvm::ArrayRef<mlir::Type>, llvm::ArrayRef<mlir::Value>, mlir::MutableDictionaryAttr, llvm::ArrayRef<mlir::Block*>, unsigned int) (f18+0xefcbfc)
#5 0x00005601dadbfd58 mlir::Operation::create(mlir::Location, mlir::OperationName, llvm::ArrayRef<mlir::Type>, llvm::ArrayRef<mlir::Value>, mlir::MutableDictionaryAttr, llvm::ArrayRef<mlir::Block*>, mlir::RegionRange) (f18+0xefcd58)
#6 0x00005601dadbff44 mlir::Operation::create(mlir::OperationState const&) (f18+0xefcf44)
#7 0x00005601dad920ac mlir::OpBuilder::createOperation(mlir::OperationState const&) (f18+0xecf0ac)
#8 0x00005601da5e5dfe (anonymous namespace)::FirConverter::genFIR(Fortran::parser::AssignedGotoStmt const&) (f18+0x722dfe)
#9 0x00005601da5e1bb9 (anonymous namespace)::FirConverter::genFIR(Fortran::lower::pft::Evaluation&, bool) (.part.11155) (f18+0x71ebb9)
#10 0x00005601da5e4121 std::__detail::__variant::...
#11 0x00005601da5e1c56 (anonymous namespace)::FirConverter::genFIR(Fortran::lower::pft::Evaluation&, bool) (.part.11155) (f18+0x71ec56)
#12 0x00005601da5eaf37 (anonymous namespace)::FirConverter::lowerFunc(Fortran::lower::pft::FunctionLikeUnit&) (f18+0x727f37)
#13 0x00005601da5db055 Fortran::lower::LoweringBridge::lower(Fortran::parser::Program const&, fir::NameUniquer&, Fortran::semantics::SemanticsContext const&) (f18+0x718055)
#14 0x00005601da0ae864 CompileFortran(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, Fortran::parser::Options, DriverOptions&, Fortran::common::IntrinsicTypeDefaultKinds const&) (.localalias.2) (f18+0x1eb864)
#15 0x00005601da006e61 main (f18+0x143e61)
#16 0x00007f4f7cc1cb97 __libc_start_main /build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:344:0
#17 0x00005601da014aea _start (f18+0x151aea)
flang: line 29: 86019 Segmentation fault ${wd}/bin/f18 -module-suffix .f18.mod -intrinsic-module-directory flang/install/include/flang $*
makefile:931: recipe for target 'fm255.o' failed
make: *** [fm255.o] Error 139
---------------------------------- executing test fm255
./fm255.out > fm255.log
/bin/sh: 1: ./fm255.out: not found
makefile:923: recipe for target 'fm255.run' failed
make: *** [fm255.run] Error 127
program main
integer, dimension(2) :: A, B
A = B
end program main
The A = B assignment causes the compile time error
error: loc("array_assignment.f":8:7): 'fir.store' op store value type must match memory reference type
Caused by the store op found here
FAIL: Flang :: Lower/end-to-end-character-assignment.f90 (201 of 400)
******************** TEST 'Flang :: Lower/end-to-end-character-assignment.f90' FAILED ********************
Exception in thread Thread-3:
...
implementation is only for structured loops. Unstructured loops should probably also be forced to have 1 iteration using the same switch.
flang -c fm097.f
error: loc("fm097.f":383:7): 'fir.cmpf' op requires all operands to have the same type
llvm ir generation did not succeed
need to be lowered
flang -c fm503.f
Need to figure out what to do with the 4 TODO items in this file.
Probably a duplicate of #181
flang -c fcvs/src/fm013.f
invalid assigned goto target
UNREACHABLE executed at /local/home/sjs/flang/f18-llvm-project/flang/lib/Lower/Bridge.cpp:658!
program main
implicit none
real :: x
x = 0.025
write(*,110) 'x=', x
110 format (A,F5.3)
end program main
This program prints out
x=.0250
instead of
x=0.025
See ConvertExpr.cpp createCharCompare().
flang fm020.o -o fm020.out
fm020.o: In function _QQmain' fcvs/src/fm020.f:152: undefined reference to
_QPifon01'
My mock driver fails to preprocess x.F files. We need a flang driver.
failure with internal testing.
Load of a variable is wrongly optimized out after a fir.if where the variable is modified:
Input FIR (important load at %4
given fir.store
in fir.if
):
func @foo(%arg0: !fir.ref<f32>) -> f32 {
%0 = fir.alloca f32 {name = "x"}
%1 = fir.load %arg0 : !fir.ref<f32>
fir.store %1 to %0 : !fir.ref<f32>
%cst = constant 0.000000e+00 : f32
%2 = fir.load %0 : !fir.ref<f32>
%3 = fir.cmpf "olt", %2, %cst : f32
fir.if %3 {
%7 = fir.load %0 : !fir.ref<f32>
%8 = fir.negf %7 : f32
fir.store %8 to %0 : !fir.ref<f32>
} else {
}
%cst_0 = constant 1.000000e+00 : f32
%4 = fir.load %0 : !fir.ref<f32>
%5 = fir.addf %4, %cst_0 : f32
fir.store %5 to %0 : !fir.ref<f32>
%6 = fir.load %0 : !fir.ref<f32>
return %6 : f32
}
tco -o -: (%10
is wrong)
define float @foo(float* %0) !dbg !3 {
%2 = alloca float, i64 1, align 4, !dbg !7
%3 = load float, float* %0, align 4, !dbg !9
store float %3, float* %2, align 4, !dbg !10
%4 = load float, float* %2, align 4, !dbg !11
%5 = fcmp olt float %4, 0.000000e+00, !dbg !12
br i1 %5, label %6, label %9, !dbg !13
6: ; preds = %1
%7 = load float, float* %2, align 4, !dbg !14
%8 = fneg float %7, !dbg !15
store float %8, float* %2, align 4, !dbg !16
br label %9, !dbg !13
9: ; preds = %6, %1
%10 = fadd float %4, 1.000000e+00, !dbg !17
store float %10, float* %2, align 4, !dbg !18
%11 = load float, float* %2, align 4, !dbg !19
ret float %11, !dbg !20
}
With -dsiable-cse
, the output form tco
after block 9 is as expected:
9: ; preds = %6, %1
%10 = load float, float* %2, align 4, !dbg !17
%11 = fadd float %10, 1.000000e+00, !dbg !18
UNREACHABLE executed at f18-llvm-project/flang/lib/Lower/Bridge.cpp:658!
fcvs tests fm311 and fm351
flang -c /proj/ta/tests/fcvs/src/fm351.f
/proj/ta/tests/fcvs/src/fm351.f:52:31: error: Internal error: Expression analysis failed on: Expr -> Designator -> DataRef -> ArrayElement
| DataRef -> Name = 'iadn11'
| SectionSubscript -> Integer -> Expr -> Designator -> DataRef -> Name = 'idon04'
IFOS02(IDON04,IDON05) = IADN11(IDON04) / IADN11(IDON05)
^^^^^^^^^^^^^^
When compiled, the following loop steps past the upper bound.
program main
implicit none
INTEGER :: i
DO i = 1, 2, 3
WRITE(*,*) i
END DO
end program main
resulting in the do loop iterating twice and printing out:
1
4
rather than
1
The text of a FORMAT statement is converting into an immediate literal string value rather than hash consed into a global like a CHARACTER literal and then just referenced.
When using the read
statement to read in a string like in the following program the compiler gives the error 'std.call' op incorrect number of operands for callee
program main
character(30) :: str
read(*,*) str
end program main
flang -c fm109.f
flang fm109.o -o fm109.out
---------------------------------- executing test fm109
./fm109.out > fm109.log
diff: file - fm109.log:
-
diff: file - ref/fm109.log:
-15.
diff: files differ at line 126 ---- test FAIL
lapack-3.1.0/INSTALL/secondtst.f
undefined reference to '_FortranAioOutputReal32'
Code is generated as part of outputing a REAL_4.
flang -c fm256.f
flang fm256.o -o fm256.out
---------------------------------- executing test fm256
./fm256.out > fm256.log
...
7 FAIL 104 106
at line 19 ---- test FAILS
When the program reaches a read
statement it hangs indefinitely. Also if there is a read
statement in the program print
statements prior it do not seem to work either, as seen in the following fortran program:
program main
implicit none
integer*8 :: i, j
i = 1
print *, i
print *, "Hello\nWorld"
do j = 1, 10000000000
i = i + 1
end do
read(*,*) i
print *, i
do j = 1, 10000000000
i = i + 1
end do
end program main
(I used the do loops and top to see what parts of the program were running)
flang -c fm203.f
not yet implemented
UNREACHABLE executed at f18-llvm-project/flang/lib/Lower/ConvertExpr.cpp:238!
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0. Program arguments: f18 -module-suffix .f18.mod -intrinsic-module-directory . -c ... fm203.f
failure with internal testing
fm401.f:374: undefined reference to
_FortranAioBeginEndfile'
`
Lower/CharacterExpr.cpp:178: void Fortran::lower::CharacterExprHelper::createStoreCharAt(const fir::CharBoxValue&, mlir::Value, mlir::Value): Assertion `!needToMaterialize(str) && "not in memory"' failed.
slasy2, dlasy2
flang -c fm098.f
error: loc("fm098.f":399:7): 'std.cmpi' op requires all operands to have the same type
llvm ir generation did not succeed
BLOCK DATA is not lowered.
Array in IO statement crashes the compiler (incorrect FIR, error: 'std.call' op incorrect number of operands for callee).
This is known to crash FCVS (FORTRAN Compiler Validation System) tests: fm100.f, fm101.f, fm105.f, fm106.f,fm107.f, fm110.f, fm403.f, fm411.f, fm413.f, fm900.f, and fm903.f (this last one also suffers from lack of array character support in lib/Lower/CharacterExpr.cpp).
Reproducer:
subroutine read_test()
real :: itest(10)
read *, itest
end subroutine
or
subroutine print_test()
real :: itest(10)
print *, itest
end subroutine
or
subroutine write_test()
real :: itest(10)
write (*,*) itest
end subroutine
Quick analysis: Array are simply not yet handled, but rather than nicely crash, the code attempts to use Ascii read/write runtime functions because this are the default cases in getInputFunc/getOutputFunc.
Fixes: type dispatch of getOutputFunc/getInputFunc could be harden and a clear TODO error message emitted for un-handled types. Then, the real fix would be to actually support arrays, which would include also updating genInputItemList
and genOutputItemList
to handle arrays. See:
f18-llvm-project/flang/lib/Lower/IO.cpp
Line 285 in 71bbcf1
f18-llvm-project/flang/lib/Lower/IO.cpp
Line 218 in 71bbcf1
Note there might be other places in IO.cpp that are impacted by arrays.
Handling arrays in IO statement could be done through making a descriptor and passing this to OutputDescriptor
/InputDescriptor
. I think this is the best solution, but at the time of this bug reporting, lowering anything with descriptors has not yet been attempted (they are actively being worked on in FIR though). The alternative would be to emit loops and call the scalar input/output but that is probably not a good idea (more complex code gen, and probably worse resulting performance).
bbc lapack/SRC/sbdsvdx.f
(LAPACK sources from https://github.com/Reference-LAPACK/lapack.git)
7%] Building Fortran object SRC/CMakeFiles/lapack.dir/sbdsvdx.f.o
LLVM ERROR: missing intrinsic: maxval
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
...
See also dbdsvdx.f
Running test fm056:
flang fm056.o fm057.o fm058.o fm059.o -o fm056.out
fcvs/src/fm058.f:37: undefined reference to `_QFfs058Pff059'
clang-11: error: linker command failed with exit code 1 (use -v to see invocation)
flang -c fm252.f
LLVM ERROR: unexpected character type
Stack dump:
0. Program arguments: f18 -module-suffix .f18.mod -intrinsic-module-directory ... -c fm252.f
from lapack 3.1.0:
bbc slatme.f
(also dlatme.f
)
unexpected character type
UNREACHABLE executed at flang/lib/Lower/FIRBuilder.cpp:290!
#8 0x0000000001e793a7 (anonymous namespace)::CharacterOpsBuilderImpl::toDataLengthPair(mlir::Value)
flang -c fm301.f
error: loc("fm301.f":653:7): Statement function calls not yet handled in lowering
Right now, the TODO macro prints out a file name and line number. As the code changes, these values may change, potentially causing duplicate bug reports, which is a burden on the reporter.
Perhaps the macro could be extended with a descriptive message or a unique id.
Running test fm050
flang fm050.o fm051.o fm052.o fm053.o fm054.o fm055.o -o fm050.out
./fm050.out > fm050.log
400 FAIL 0.21654E+01 0.31654E+01
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.