llvm / llvm-project

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

[flang][OpenMP] failure in lowering `taskgroup` construct with `allocate` to llvm-ir #57786

Open SouraVX opened 2 years ago

SouraVX commented 2 years ago

Reproducer:

subroutine omp_taskgroup
use omp_lib
integer :: allocated_x
!$omp taskgroup allocate(omp_high_bw_mem_alloc: allocated_x)
!$omp task
   call work()
!$omp end task
end subroutine

Err Log:

$ bbc taskgroup.f90 -o -|tco
Relevant pieces of Err:
loc("taskgroup.mlir":4:3): error: null operand found
"llvm.func"() ({
  %0 = "llvm.mlir.constant"() {value = 1 : i32} : () -> i32
  %1 = "llvm.mlir.constant"() {value = 1 : i64} : () -> i64
  %2 = "llvm.alloca"(%1) {bindc_name = "allocated_x", in_type = i32, operand_segment_sizes = array<i32: 0, 0>, uniq_name = "_QFomp_taskgroupEallocated_x"} : (i64) -> !llvm.ptr<i32>
  "omp.taskgroup"(<<NULL VALUE>>, %0) ({
    "omp.task"() ({
      "llvm.call"() {callee = @_QPwork, fastmathFlags = #llvm.fastmath<>} : () -> ()
      "omp.terminator"() : () -> ()
    }) {operand_segment_sizes = array<i32: 0, 0, 0, 0, 0, 0>} : () -> ()
    "omp.terminator"() : () -> ()
  }) {operand_segment_sizes = array<i32: 0, 1, 1>} : (<<NULL TYPE>>, i32) -> ()
  "llvm.return"() : () -> ()
}) {CConv = #llvm.cconv<ccc>, function_type = !llvm.func<void ()>, linkage = #llvm.linkage<external>, sym_name = "_QPomp_taskgroup"} : () -> ()
llvmbot commented 2 years ago

@llvm/issue-subscribers-openmp

llvmbot commented 2 years ago

@llvm/issue-subscribers-flang-ir

PeixinQiao commented 2 years ago

@SouraVX I think the root cause is there is no conversion for taskgroup operation from OpenMP Op in FIR side to OpenMP Op in MLIR side. The code is here. You can refer to @kiranchandramohan 's previous patch for Critical construct https://reviews.llvm.org/D130343.

llvmbot commented 1 year ago

@llvm/issue-subscribers-bug