[clang] [flang] [flang] Changes to "unsafe Cray pointers" option (PR #175223)
Eugene Epshteyn via cfe-commits
cfe-commits at lists.llvm.org
Sat Jan 10 15:42:25 PST 2026
https://github.com/eugeneepshteyn updated https://github.com/llvm/llvm-project/pull/175223
>From 830cd396326893c398987c4a35f58fac66d5f988 Mon Sep 17 00:00:00 2001
From: Eugene Epshteyn <eepshteyn at nvidia.com>
Date: Fri, 9 Jan 2026 14:10:05 -0500
Subject: [PATCH 1/2] [flang] Changes to "unsafe Cray pointers" option
---
clang/lib/Driver/ToolChains/Flang.cpp | 2 +-
flang/docs/Aliasing.md | 2 +-
flang/lib/Optimizer/Analysis/AliasAnalysis.cpp | 2 +-
.../Analysis/AliasAnalysis/alias-analysis-cray-pointers.fir | 2 +-
flang/test/Driver/unsafe-cray-pointers.f90 | 4 ++--
flang/test/Transforms/tbaa-cray-pointer.fir | 2 +-
6 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp
index 558a27e5adcc5..baf9a998a0932 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -207,7 +207,7 @@ void Flang::addCodegenOptions(const ArgList &Args,
options::OPT_fno_unsafe_cray_pointers, false)) {
// TODO: currently passed as MLIR option
CmdArgs.push_back("-mmlir");
- CmdArgs.push_back("-funsafe-cray-pointers");
+ CmdArgs.push_back("-unsafe-cray-pointers");
}
Args.addOptInFlag(CmdArgs, options::OPT_fexperimental_loop_fusion,
diff --git a/flang/docs/Aliasing.md b/flang/docs/Aliasing.md
index 8d81e14762364..8cd19b6685924 100644
--- a/flang/docs/Aliasing.md
+++ b/flang/docs/Aliasing.md
@@ -289,7 +289,7 @@ In order to disable optimizations that assume that there is no aliasing between
Cray pointer targets and entities they alias with, add the TARGET attribute to
variables aliasing with a Cray pointer (the `target` variable in this example).
-There is also a flag `-mmlir -funsafe-cray-pointers` which causes the compiler
+There is also a flag `-funsafe-cray-pointers` which causes the compiler
to assume that cray pointers alias with all data whether or not it has the
TARGET attribute.
diff --git a/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp b/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
index 0dc9dda3aa0f5..cb6a0828196fb 100644
--- a/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
+++ b/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
@@ -29,7 +29,7 @@ using namespace mlir;
#define DEBUG_TYPE "fir-alias-analysis"
llvm::cl::opt<bool> supportCrayPointers(
- "funsafe-cray-pointers",
+ "unsafe-cray-pointers",
llvm::cl::desc("Support Cray POINTERs that ALIAS with non-TARGET data"),
llvm::cl::init(false));
diff --git a/flang/test/Analysis/AliasAnalysis/alias-analysis-cray-pointers.fir b/flang/test/Analysis/AliasAnalysis/alias-analysis-cray-pointers.fir
index 4df3f67915b9c..ef3b12d9c449c 100644
--- a/flang/test/Analysis/AliasAnalysis/alias-analysis-cray-pointers.fir
+++ b/flang/test/Analysis/AliasAnalysis/alias-analysis-cray-pointers.fir
@@ -1,6 +1,6 @@
// Check that cray pointers might alias with everything.
-// RUN: fir-opt %s -funsafe-cray-pointers -pass-pipeline='builtin.module(func.func(test-fir-alias-analysis))' -mlir-disable-threading 2>&1 | FileCheck %s
+// RUN: fir-opt %s -unsafe-cray-pointers -pass-pipeline='builtin.module(func.func(test-fir-alias-analysis))' -mlir-disable-threading 2>&1 | FileCheck %s
// RUN: fir-opt %s -pass-pipeline='builtin.module(func.func(test-fir-alias-analysis))' -mlir-disable-threading 2>&1 | FileCheck --check-prefix=DEFAULT %s
// Fortran source:
diff --git a/flang/test/Driver/unsafe-cray-pointers.f90 b/flang/test/Driver/unsafe-cray-pointers.f90
index bd8cafc1602f3..55536cca314ce 100644
--- a/flang/test/Driver/unsafe-cray-pointers.f90
+++ b/flang/test/Driver/unsafe-cray-pointers.f90
@@ -1,5 +1,5 @@
! RUN: %flang -funsafe-cray-pointers -### %s 2>&1 | FileCheck %s --check-prefix=CHECK-ON
! RUN: %flang -fno-unsafe-cray-pointers -### %s 2>&1 | FileCheck %s --check-prefix=CHECK-OFF
-! CHECK-ON: "-mmlir" "-funsafe-cray-pointers"
-! CHECK-OFF-NOT: "-mmlir" "-funsafe-cray-pointers"
+! CHECK-ON: "-mmlir" "-unsafe-cray-pointers"
+! CHECK-OFF-NOT: "-mmlir" "-unsafe-cray-pointers"
diff --git a/flang/test/Transforms/tbaa-cray-pointer.fir b/flang/test/Transforms/tbaa-cray-pointer.fir
index 54406271aaa58..7c668b1b903ba 100644
--- a/flang/test/Transforms/tbaa-cray-pointer.fir
+++ b/flang/test/Transforms/tbaa-cray-pointer.fir
@@ -1,4 +1,4 @@
-// RUN: fir-opt -funsafe-cray-pointers --fir-add-alias-tags %s | FileCheck %s
+// RUN: fir-opt -unsafe-cray-pointers --fir-add-alias-tags %s | FileCheck %s
// Fortran source:
// subroutine test()
>From 420c993a92ec3a31a749698f7a8be3b49ed9d678 Mon Sep 17 00:00:00 2001
From: Eugene Epshteyn <eepshteyn at nvidia.com>
Date: Sat, 10 Jan 2026 18:42:17 -0500
Subject: [PATCH 2/2] Update flang/docs/Aliasing.md
Co-authored-by: Tarun Prabhu <tarunprabhu at gmail.com>
---
flang/docs/Aliasing.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/flang/docs/Aliasing.md b/flang/docs/Aliasing.md
index 8cd19b6685924..19cb0fe72886c 100644
--- a/flang/docs/Aliasing.md
+++ b/flang/docs/Aliasing.md
@@ -289,7 +289,7 @@ In order to disable optimizations that assume that there is no aliasing between
Cray pointer targets and entities they alias with, add the TARGET attribute to
variables aliasing with a Cray pointer (the `target` variable in this example).
-There is also a flag `-funsafe-cray-pointers` which causes the compiler
+There is also a flag, `-funsafe-cray-pointers`, which causes the compiler
to assume that cray pointers alias with all data whether or not it has the
TARGET attribute.
More information about the cfe-commits
mailing list