Skip to content

[Flang][OpenMP] Compiler crach on OpenMP atomic capture with complex type swap #191317

@chichunchen

Description

@chichunchen

Flang crashes with an assertion failure when compiling !$omp atomic capture
with complex types in the swap pattern (v = x; x = expr). The crash occurs
in llvm::IntegerType::get() because getScalarSizeInBits() returns 0 for
struct types like {float, float}.

Reproducer (https://godbolt.org/z/s3q433E9e):

subroutine test_swap(x, v, expr)
  complex(4) :: x, v, expr
  !$omp atomic capture
  v = x
  x = expr
  !$omp end atomic
end subroutine
flang -fopenmp -fopenmp-version=40 repro.f90 -c

Error message:

flang-23: warning: argument unused during compilation: '-c' [-Wunused-command-line-argument]
warning: OpenMP support for version 40 in flang is still incomplete
atomic memory access' size must be byte-sized
 i0  %.atomic.load = load atomic i0, ptr %0 monotonic, align 1
IntToPtr result must be a pointer
  %.atomic.ptrCast = inttoptr i0 %5 to { float, float }
atomic memory access' size must be byte-sized
 i0  %7 = cmpxchg ptr %0, i0 %5, i0 %6 monotonic monotonic, align 9223372036854775808
error: failed to create the LLVM module
Compiler returned: 1

Metadata

Metadata

Assignees

Labels

flang:openmpllvm:openmpirbuilderIssues related to problems in the llvm-project/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions