Skip to content

Conversation

kparzysz
Copy link
Contributor

@kparzysz kparzysz commented May 14, 2024

Detect the case when a reduction modifier ends up not being applied after construct decomposition, treat it as an error.

This fixes a regression in the gfortran test suite after #90098.

Detect the case when a reduction modifier ends up not being applied after
construct decomposition, treat it as an error.

This fixes a regression in the gfortran test suite after PR90098.
@kparzysz kparzysz requested review from tblah and omjavaid May 14, 2024 18:37
@llvmbot llvmbot added flang:openmp clang:openmp OpenMP related changes to Clang labels May 14, 2024
@llvmbot
Copy link
Member

llvmbot commented May 14, 2024

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

@llvm/pr-subscribers-flang-openmp

Author: Krzysztof Parzyszek (kparzysz)

Changes

Detect the case when a reduction modifier ends up not being applied after construct decomposition, treat it as an error.

This fixes a regression in the gfortran test suite after PR90098.


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

1 Files Affected:

  • (modified) llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h (+2-1)
diff --git a/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h b/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h
index 5f12c62b832fc..e5fcc493ea590 100644
--- a/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h
+++ b/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h
@@ -930,7 +930,8 @@ bool ConstructDecompositionT<C, H>::applyClause(
       // Apply clause without modifier.
       leaf.clauses.push_back(unmodified);
     }
-    applied = true;
+    // The modifier must be applied to some construct.
+    applied = effectiveApplied;
   }
 
   if (!applied)

Copy link
Contributor

@tblah tblah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it isn't too time consuming, please could you add a test for this to the flang test suite so that we catch this bug with the regular build bots next time.

@llvmbot llvmbot added flang Flang issues not falling into any other category flang:fir-hlfir labels May 15, 2024
Copy link
Contributor

@tblah tblah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding the test

@kparzysz kparzysz merged commit 8d386c6 into llvm:main May 15, 2024
@kparzysz kparzysz deleted the users/kparzysz/gfortran-regression branch May 15, 2024 14:05
@psteinfeld
Copy link
Contributor

@kparzysz, I'm still getting an assertion in Decomposer.cpp with my internal test even with this latest change. Are you still working on this, or should I work to create a small reproducer?

@kparzysz
Copy link
Contributor Author

kparzysz commented May 15, 2024

@kparzysz, I'm still getting an assertion in Decomposer.cpp with my internal test even with this latest change. Are you still working on this, or should I work to create a small reproducer?

This test uses an invalid reduction modifier for this construct. Before this fix we just silently dropped the modifier, now we will assert. I will open a follow-up issue to have this detected in the semantic checks and emit a user-friendly error.

Does your code have this specific combination of reduction/construct? IIRC, it asserted before any of the follow up fixes, so it's likely a different problem. Please do create a testcase for it.

Edit: @psteinfeld In case you missed my previous message: please send me a testcase for the crash you're seeing.

@kparzysz
Copy link
Contributor Author

Created issue #92397, and PR #92406.

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

Successfully merging this pull request may close these issues.

4 participants