-
Notifications
You must be signed in to change notification settings - Fork 13.5k
flang fails to lower to FIR on empty module contains #86459
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
Comments
@llvm/issue-subscribers-flang-ir Author: Joseph Capriotti (jcapriot)
On using `flang` version `18.1.2` on Windows, distributed through `conda-forge` I am unable to compile a fortran module with an empty contains section, it fails to lowering.
For example, this simple code fails: module test
integer, public :: N
end module with the error message:
This also fails (with the same error): module test
integer, public :: N
contains
end module But this compiles just fine: module test
integer, public :: N
contains
subroutine _placeholder()
end subroutine
end module |
Thanks for the bug report. I could not reproduce on Linux. The error message is weird since ""fir.has_value" is a terminator.... there may be some undefined behavior hit here. Could you try the following with your set-up: Where repro.mlir is:
Could you also do |
Output of the first command is: > flang-new -fc1 -emit-llvm -mmlir --mlir-print-ir-after-failure -o - repro.mlir
warning: overriding the module target triple with x86_64-pc-windows-msvc [-Woverride-module]
; ModuleID = 'FIRModule'
source_filename = "FIRModule"
target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-windows-msvc"
@_QMtestEn = global i32 0
; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #0
; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #0
attributes #0 = { nocallback nofree nosync nounwind willreturn }
!llvm.module.flags = !{!0}
!0 = !{i32 2, !"Debug Info Version", i32 3} second command give the same issue as before: > flang-new -fc1 -emit-hlfir -mmlir --mlir-print-ir-after-failure -o - test.f90
error: loc("Path\\to\\test.f90":2:20): block with no terminator, has "fir.has_value"(%0) : (i32) -> ()
error: verification of lowering to FIR failed |
So I went through the hoops to build flang myself from source and I'm not getting this error. I suspect it's something to do with an error somewhere in how flang is built on conda-forge. |
Thank you @jcapriot for the providing the output and testing with sources from llvm. It could also be a bug that made it in 18.1.2 release but was fixed since then. |
Just got made aware of this issue - feel free to ping me for conda-forge related things. I'm not aware of any "mistake" (or substantial divergence from the default) in building flang in conda-forge, so I'm very interested in fixing this. I encountered something similar in #86463.
Can I ask, did you build flang from |
My working example previously was built off of I then went and installed |
On using
flang
version18.1.2
on Windows, distributed throughconda-forge
I am unable to compile a fortran module with an empty contains section, it fails to lowering.For example, this simple code fails:
with the error message:
This also fails (with the same error):
But this compiles just fine:
The text was updated successfully, but these errors were encountered: