Skip to content

Missing Flang semantics check causes ICE #153173

@skatrak

Description

@skatrak

The following invalid OpenMP program causes a compiler crash rather than emitting a semantics error:

! test.f90
program main
  implicit none
  integer, parameter :: n = 100
  integer, parameter :: expected = n+2
  integer :: i
  integer :: counter

  counter = 0
  !$omp target map(tofrom:counter)
    counter = counter+1
    !$omp teams distribute reduction(+:counter)
    do i=1, n
      counter = counter+1
    end do
    counter = counter+1
  !$omp end target

  print '("Result: "I0)', counter
end program

This is triggered both when offloading and when compiling exclusively for the host device.

flang -fopenmp --offload-arch=gfx1030 test.f90
flang -fopenmp test.f90

The specific OpenMP restriction being violated by the previous example is found in the specification version 6.0, page 395, lines 33 -- 35:

[...] If a teams region is nested inside a target region, the corresponding target construct must not contain any statements, declarations or directives outside of the corresponding teams construct.

Metadata

Metadata

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions