GithubHelp home page GithubHelp logo

flang-compiler / f18-llvm-project Goto Github PK

View Code? Open in Web Editor NEW

This project forked from llvm/llvm-project

28.0 28.0 16.0 2.03 GB

Fork of llvm/llvm-project for f18. In sync with f18-mlir and f18.

Home Page: http://llvm.org

f18-llvm-project's People

Contributors

akyrtzi avatar arsenm avatar chandlerc avatar chapuni avatar d0k avatar ddunbar avatar douggregor avatar dwblaikie avatar echristo avatar eefriedman avatar ericwf avatar espindola avatar isanbard avatar kcc avatar labath avatar lattner avatar lebedevri avatar lhames avatar maskray avatar nico avatar resistor avatar rksimon avatar rnk avatar rotateright avatar rui314 avatar stoklund avatar tkremenek avatar tobiasgrosser avatar topperc avatar zygoloid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

f18-llvm-project's Issues

fm203 fm205 nyi ConvertExpr.cpp:238

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

fm203 fm205 fm301 assertion failure

Lower/CharacterExpr.cpp:178: void Fortran::lower::CharacterExprHelper::createStoreCharAt(const fir::CharBoxValue&, mlir::Value, mlir::Value): Assertion `!needToMaterialize(str) && "not in memory"' failed.

fm311 fm351 Expression analysis failed on: Expr -> Designator -> DataRef -> ArrayElement

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)
                                ^^^^^^^^^^^^^^

Incorrect formatting

      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

character LEN failure

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)

Array assignment does not lower

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

FIR CSE bug: load wrongly optimized-out.

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

Read statements causes fortran runtime to hang

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)

fm255: crashes in lowering an assigned goto

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

TODO() could offer a descriptive message

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.

appears to be a crash in PFT code

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

fm109 fails

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

Reading in a string causes compiler error

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

fm256 7 FAIL 104 106

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

fm100 fm101 fm103 fm105 fm106 fm107 fm108 Arrays in IO statement not yet handled

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:

static void genInputItemList(Fortran::lower::AbstractConverter &converter,

genOutputItemList(Fortran::lower::AbstractConverter &converter,

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).

Loop lowering stepping out of bounds

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

invalid assigned goto target

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!

Iolength in Inquire statement fails with a stack trace.

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.