llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.42k stars 12.16k forks source link

[Flang] Compilation error of using %VAL for an actual argument #118239

Open ohno-fj opened 2 days ago

ohno-fj commented 2 days ago
Version of flang : 20.0.0(590f451b60d434b26c634a07125fb05baf461fa0)/AArch64

Using %VAL (which specifies that the actual argument should be passed by value) for an actual argument results in a compilation error (LLVM IR failed).

The following are the test program, Flang, Gfortran and ifx compilation/execution result.

snggf047_22.f90:

program main
  logical::a1
  data a1/.true./
  call sa(%val(a1))
  write(6,*) "a1 = ", a1
end program main

subroutine sa(x1)
  logical::x1
end subroutine sa
$ flang snggf047_22.f90
error: loc("/work/home/ohno/CT/test/fort/tp/reproducerJ/MCS/v3f/snggf047_22.f90":4:3): unsupported types for logical conversion: 'i32' -> '!llvm.ptr'
error: loc("/work/home/ohno/CT/test/fort/tp/reproducerJ/MCS/v3f/snggf047_22.f90":4:3): failed to legalize operation 'fir.convert'
error: Lowering to LLVM IR failed
error: loc("/work/home/ohno/CT/test/fort/tp/reproducerJ/MCS/v3f/snggf047_22.f90":1:1): cannot be converted to LLVM IR: missing `LLVMTranslationDialectInterface` registration for dialect for op: func.func
error: failed to create the LLVM module
$
$ gfortran snggf047_2.f90; ./a.out
 a1 =  T
$
$ ifx snggf047_2.f90; ./a.out
 a1 =  T
$
llvmbot commented 2 days ago

@llvm/issue-subscribers-flang-ir

Author: None (ohno-fj)

``` Version of flang : 20.0.0(590f451b60d434b26c634a07125fb05baf461fa0)/AArch64 ``` Using `%VAL (which specifies that the actual argument should be passed by value)` for an `actual argument` results in a compilation error (`LLVM IR failed`). The following are the test program, Flang, Gfortran and ifx compilation/execution result. snggf047_22.f90: ```fortran program main logical::a1 data a1/.true./ call sa(%val(a1)) write(6,*) "a1 = ", a1 end program main subroutine sa(x1) logical::x1 end subroutine sa ``` ``` $ flang snggf047_22.f90 error: loc("/work/home/ohno/CT/test/fort/tp/reproducerJ/MCS/v3f/snggf047_22.f90":4:3): unsupported types for logical conversion: 'i32' -> '!llvm.ptr' error: loc("/work/home/ohno/CT/test/fort/tp/reproducerJ/MCS/v3f/snggf047_22.f90":4:3): failed to legalize operation 'fir.convert' error: Lowering to LLVM IR failed error: loc("/work/home/ohno/CT/test/fort/tp/reproducerJ/MCS/v3f/snggf047_22.f90":1:1): cannot be converted to LLVM IR: missing `LLVMTranslationDialectInterface` registration for dialect for op: func.func error: failed to create the LLVM module $ ``` ``` $ gfortran snggf047_2.f90; ./a.out a1 = T $ ``` ``` $ ifx snggf047_2.f90; ./a.out a1 = T $ ```