[flang-commits] [flang] [flang][OpenMP] Fix regression in OpenMP master region with private t… (PR #172085)
Priyanshu Singh via flang-commits
flang-commits at lists.llvm.org
Fri Dec 12 13:24:51 PST 2025
https://github.com/dev-priyanshu15 created https://github.com/llvm/llvm-project/pull/172085
…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
>From c1ba03952c0b90dfc52356887dd0ec1da4854bff Mon Sep 17 00:00:00 2001
From: spriyanshucoder <s.priyanshu.coder at gmail.com>
Date: Sat, 13 Dec 2025 02:50:35 +0530
Subject: [PATCH] [flang][OpenMP] Fix regression in OpenMP master region with
private target 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
---
.../lib/Optimizer/Transforms/AddAliasTags.cpp | 18 +++++++------
.../alias-tags-master-private-target.f90 | 26 +++++++++++++++++++
2 files changed, 36 insertions(+), 8 deletions(-)
create mode 100644 flang/test/Transforms/alias-tags-master-private-target.f90
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
More information about the flang-commits
mailing list