[flang-commits] [flang] [flang][OpenMP] Fix regression in OpenMP master region with private t… (PR #172085)
via flang-commits
flang-commits at lists.llvm.org
Fri Dec 12 13:25:43 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-fir-hlfir
Author: Priyanshu Singh (dev-priyanshu15)
<details>
<summary>Changes</summary>
…arget integer
When handling TARGET variables in dummy arguments, the code was calling getFuncArgName() unconditionally. This could cause an assertion failure when getUniqName() returns an unengaged optional for TARGET variables.
Move getFuncArgName() call to only execute when the variable is not a TARGET or POINTER, avoiding the assertion error.
Fixes issue #<!-- -->172075
---
Full diff: https://github.com/llvm/llvm-project/pull/172085.diff
2 Files Affected:
- (modified) flang/lib/Optimizer/Transforms/AddAliasTags.cpp (+10-8)
- (added) flang/test/Transforms/alias-tags-master-private-target.f90 (+26)
``````````diff
diff --git a/flang/lib/Optimizer/Transforms/AddAliasTags.cpp b/flang/lib/Optimizer/Transforms/AddAliasTags.cpp
index 0221c7a8184d7..84515819e9f76 100644
--- a/flang/lib/Optimizer/Transforms/AddAliasTags.cpp
+++ b/flang/lib/Optimizer/Transforms/AddAliasTags.cpp
@@ -691,19 +691,21 @@ void AddAliasTagsPass::runOnAliasInterface(fir::FirAliasTagOpInterface op,
source.kind == fir::AliasAnalysis::SourceKind::Argument) {
LLVM_DEBUG(llvm::dbgs().indent(2)
<< "Found reference to dummy argument at " << *op << "\n");
- std::string name = getFuncArgName(llvm::cast<mlir::Value>(source.origin.u));
// If it is a TARGET or POINTER, then we do not care about the name,
// because the tag points to the root of the subtree currently.
if (source.isTargetOrPointer()) {
tag = state.getFuncTreeWithScope(func, scopeOp).targetDataTree.getTag();
- } else if (!name.empty()) {
- tag = state.getFuncTreeWithScope(func, scopeOp)
- .dummyArgDataTree.getTag(name);
} else {
- LLVM_DEBUG(llvm::dbgs().indent(2)
- << "WARN: couldn't find a name for dummy argument " << *op
- << "\n");
- tag = state.getFuncTreeWithScope(func, scopeOp).dummyArgDataTree.getTag();
+ std::string name = getFuncArgName(llvm::cast<mlir::Value>(source.origin.u));
+ if (!name.empty()) {
+ tag = state.getFuncTreeWithScope(func, scopeOp)
+ .dummyArgDataTree.getTag(name);
+ } else {
+ LLVM_DEBUG(llvm::dbgs().indent(2)
+ << "WARN: couldn't find a name for dummy argument " << *op
+ << "\n");
+ tag = state.getFuncTreeWithScope(func, scopeOp).dummyArgDataTree.getTag();
+ }
}
// TBAA for global variables without descriptors
diff --git a/flang/test/Transforms/alias-tags-master-private-target.f90 b/flang/test/Transforms/alias-tags-master-private-target.f90
new file mode 100644
index 0000000000000..0251376476c64
--- /dev/null
+++ b/flang/test/Transforms/alias-tags-master-private-target.f90
@@ -0,0 +1,26 @@
+! Test case for regression in OpenMP master region with private target integer
+! This test was failing with an assertion error in AddAliasTags.cpp
+! See issue #172075
+
+! RUN: %flang -fopenmp -c -O1 %s -o %t.o 2>&1 | FileCheck %s --allow-empty
+
+module test
+contains
+subroutine omp_master_repro()
+ implicit none
+ integer, parameter :: nim = 4
+ integer, parameter :: nvals = 8
+ integer, target :: ui
+ integer :: hold1(nvals, nim)
+ hold1 = 0
+ !$OMP PARALLEL DEFAULT(NONE) &
+ !$OMP PRIVATE(ui) &
+ !$OMP SHARED(hold1, nim)
+ !$OMP MASTER
+ do ui = 1, nim
+ hold1(:, ui) = 1
+ end do
+ !$OMP END MASTER
+ !$OMP END PARALLEL
+end subroutine omp_master_repro
+end module test
``````````
</details>
https://github.com/llvm/llvm-project/pull/172085
More information about the flang-commits
mailing list