Skip to content
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

[flang][OpenMP] The compilation fails with nowait on target construct with -g. #125088

Open
abidh opened this issue Jan 30, 2025 · 1 comment
Open

Comments

@abidh
Copy link
Contributor

abidh commented Jan 30, 2025

Please see the testcase below.

program nowait_reproducer
   implicit none
   real x

   !$omp target map(tofrom: x) nowait
      x = x + 1
   !$omp end target

end program nowait_reproducer

This is what I get when I try to compile it with -g.

flang -g -O0 test.f90 -fopenmp
flang-20: warning: OpenMP support in flang is still experimental [-Wexperimental-option]
inlinable function call in a function with debug info must have a !dbg location
  call void @__omp_offloading_10302_4986ae0__QQmain_l10(ptr %1)
error: failed to create the LLVM module
@abidh abidh self-assigned this Jan 30, 2025
@llvmbot llvmbot added the flang Flang issues not falling into any other category label Jan 30, 2025
@EugeneZelenko EugeneZelenko added flang:ir flang:openmp and removed flang Flang issues not falling into any other category labels Jan 30, 2025
@llvmbot
Copy link
Member

llvmbot commented Jan 30, 2025

@llvm/issue-subscribers-flang-ir

Author: Abid Qadeer (abidh)

Please see the testcase below.
program nowait_reproducer
   implicit none
   real x

   !$omp target map(tofrom: x) nowait
      x = x + 1
   !$omp end target

end program nowait_reproducer

This is what I get when I try to compile it with -g.

flang -g -O0 test.f90 -fopenmp
flang-20: warning: OpenMP support in flang is still experimental [-Wexperimental-option]
inlinable function call in a function with debug info must have a !dbg location
  call void @<!-- -->__omp_offloading_10302_4986ae0__QQmain_l10(ptr %1)
error: failed to create the LLVM module

abidh added a commit to abidh/llvm-project that referenced this issue Jan 30, 2025
While working on llvm#125088, I
noticed a problem with the TargetBodyGenCallbackTy and
TargetGenArgAccessorsCallbackTy. The OMPIRBuilder and MLIR side Both
maintain their own IRBuilder and when control goes from one to other,
we have to take care to not use a stale debug location. The code
currently rely on restoreIP to set the insertion point and the debug
location. But if the passes InsertPointTy has an empty block,
then the debug location will not be updated (see SetInsertPoint).
This can cause invalid debug location to be attached to instruction and
the verifier will complain.

Similarly when we exit the callback, the debug location of the Builder
is not set to what it was before the callback. This again can cause
verification failures.

This PR resets the debug location at the start and also uses an
InsertPointGuard to restore the debug location at exit.

Both of these problems would have been caught by the unit tests but
they were not setting the debug location of the builder before calling
the createTarget so the problem was hidden. I have updated the tests
accordingly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants