Skip to content

[Flang][OpenMP] Fix type in getBaseObject causing crashes in certain scenarios #95472

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

Merged
merged 1 commit into from
Jun 14, 2024

Conversation

agozillon
Copy link
Contributor

This typo would unfortunately cause code like the following to ICE, where common block symbols/names are used in a map clause:

subroutine sb()
implicit none
integer:: b, c
common /var/ b, c

!$omp target map(tofrom: /var/)
b = 1
c = 2
!$omp end target
end subroutine

…scenarios

This type would unfortunately cause code like the following to ICE, where common block symbols/names are used in a map clause:

subroutine sb()
  implicit none
  integer:: b, c
  common /var/ b, c

!$omp target map(tofrom: /var/)
   b = 1
   c = 2
!$omp end target
end subroutine
@agozillon agozillon requested a review from kparzysz June 13, 2024 20:53
@llvmbot llvmbot added flang Flang issues not falling into any other category flang:fir-hlfir labels Jun 13, 2024
@llvmbot
Copy link
Member

llvmbot commented Jun 13, 2024

@llvm/pr-subscribers-flang-fir-hlfir

Author: None (agozillon)

Changes

This typo would unfortunately cause code like the following to ICE, where common block symbols/names are used in a map clause:

subroutine sb()
implicit none
integer:: b, c
common /var/ b, c

!$omp target map(tofrom: /var/)
b = 1
c = 2
!$omp end target
end subroutine


Full diff: https://github.com/llvm/llvm-project/pull/95472.diff

1 Files Affected:

  • (modified) flang/lib/Lower/OpenMP/Clauses.cpp (+1-1)
diff --git a/flang/lib/Lower/OpenMP/Clauses.cpp b/flang/lib/Lower/OpenMP/Clauses.cpp
index 1e3fea7c4cdc7..6bae62cd85860 100644
--- a/flang/lib/Lower/OpenMP/Clauses.cpp
+++ b/flang/lib/Lower/OpenMP/Clauses.cpp
@@ -153,7 +153,7 @@ Object makeObject(const parser::OmpObject &object,
 std::optional<Object> getBaseObject(const Object &object,
                                     semantics::SemanticsContext &semaCtx) {
   // If it's just the symbol, then there is no base.
-  if (!object.id())
+  if (!object.ref())
     return std::nullopt;
 
   auto maybeRef = evaluate::ExtractDataRef(*object.ref());

@kparzysz kparzysz merged commit e910f61 into llvm:main Jun 14, 2024
10 checks passed
@kparzysz
Copy link
Contributor

Thanks for the fix!

@agozillon
Copy link
Contributor Author

@kparzysz Thank you for the quick review and handling the merge! :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:fir-hlfir flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants