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] Incorrect location information for OpenMP constructs/clauses #57215

Closed
kiranchandramohan opened this issue Aug 18, 2022 · 5 comments
Labels
bug Indicates an unexpected problem or unintended behavior flang:ir good first issue https://github.com/llvm/llvm-project/contribute openmp

Comments

@kiranchandramohan
Copy link
Contributor

kiranchandramohan commented Aug 18, 2022

@clementval reports that the location information for OpenMP constructs and clauses is incorrect.

In lowering, the getCurrentLocation function is used. getCurrentLocation refers to the location of the last Fortran construct. The same issue in OpenACC was fixed in https://reviews.llvm.org/D131659 using the genLocation function. A similar approach could be used for OpenMP as well.

Reproducer

For the following Fortran OpenMP program,

$ cat openmp_loc.f90 
subroutine sb(x,y)
  integer :: x, y
  !$omp parallel
      x = y
  !$omp end parallel
end subroutine

we get the following location information. As can be seen the location of the OpenMP construct is printed as loc1 (= line 1 column 1), this is incorrect.

$ ./bin/flang-new -fc1 -fopenmp  -emit-fir -mmlir --mlir-print-debuginfo openmp_loc.f90 -o -
#loc1 = loc("./openmp_loc.f90":1:1)
module attributes {fir.defaultkind = "a1c4d8i4l4r4", fir.kindmap = "", llvm.target_triple = "aarch64-unknown-linux-gnu"} {
  func.func @_QPsb(%arg0: !fir.ref<i32> {fir.bindc_name = "x"} loc("./openmp_loc.f90":1:1), %arg1: !fir.ref<i32> {fir.bindc_name = "y"} loc("./openmp_loc.f90":1:1)) {
    omp.parallel   {
      %0 = fir.load %arg1 : !fir.ref<i32> loc(#loc2)
      fir.store %0 to %arg0 : !fir.ref<i32> loc(#loc2)
      omp.terminator loc(#loc1)
    } loc(#loc1)
    return loc(#loc3)
  } loc(#loc1)
} loc(#loc0)
#loc0 = loc(unknown)
#loc2 = loc("./openmp_loc.f90":4:7)
#loc3 = loc("./openmp_loc.f90":6:1
@llvmbot
Copy link
Collaborator

llvmbot commented Aug 18, 2022

@llvm/issue-subscribers-flang-ir

@kiranchandramohan kiranchandramohan added the good first issue https://github.com/llvm/llvm-project/contribute label Aug 18, 2022
@llvmbot
Copy link
Collaborator

llvmbot commented Aug 18, 2022

@llvm/issue-subscribers-good-first-issue

@psteinfeld psteinfeld added the bug Indicates an unexpected problem or unintended behavior label Jun 7, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Jun 7, 2023

@llvm/issue-subscribers-bug

@llvmbot
Copy link
Collaborator

llvmbot commented Jun 7, 2023

@llvm/issue-subscribers-openmp

kiranchandramohan added a commit that referenced this issue Jun 27, 2023
This patch fixes location information of a few OpenMP constructs
and clauses. More fixes will come in follow-up patches.

This patch follows the same fixes for OpenACC (D131659).

Addresses some of the issues in #57215

Reviewed By: clementval

Differential Revision: https://reviews.llvm.org/D153887
@kiranchandramohan
Copy link
Contributor Author

This issue is fixed by the above commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior flang:ir good first issue https://github.com/llvm/llvm-project/contribute openmp
Projects
None yet
Development

No branches or pull requests

3 participants