Skip to content

[flang][cuda] Remove meaningless warning on CUDA shared arguments #152404

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
Aug 7, 2025

Conversation

clementval
Copy link
Contributor

The warning in issued during the compatibility check makes little sense. Just remove it as it is confusing.

@llvmbot llvmbot added flang Flang issues not falling into any other category flang:semantics labels Aug 6, 2025
@llvmbot
Copy link
Member

llvmbot commented Aug 6, 2025

@llvm/pr-subscribers-flang-semantics

Author: Valentin Clement (バレンタイン クレメン) (clementval)

Changes

The warning in issued during the compatibility check makes little sense. Just remove it as it is confusing.


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

5 Files Affected:

  • (modified) flang/include/flang/Support/Fortran.h (+2-2)
  • (modified) flang/lib/Evaluate/characteristics.cpp (+2-2)
  • (modified) flang/lib/Semantics/check-call.cpp (+1-6)
  • (modified) flang/lib/Support/Fortran.cpp (+2-5)
  • (removed) flang/test/Semantics/cuf17.cuf (-18)
diff --git a/flang/include/flang/Support/Fortran.h b/flang/include/flang/Support/Fortran.h
index 0b4fc1a608e9e..ea0344ecb0830 100644
--- a/flang/include/flang/Support/Fortran.h
+++ b/flang/include/flang/Support/Fortran.h
@@ -95,8 +95,8 @@ static constexpr IgnoreTKRSet ignoreTKRAll{IgnoreTKR::Type, IgnoreTKR::Kind,
 std::string AsFortran(IgnoreTKRSet);
 
 bool AreCompatibleCUDADataAttrs(std::optional<CUDADataAttr>,
-    std::optional<CUDADataAttr>, IgnoreTKRSet, std::optional<std::string> *,
-    bool allowUnifiedMatchingRule, bool isHostDeviceProcedure,
+    std::optional<CUDADataAttr>, IgnoreTKRSet, bool allowUnifiedMatchingRule,
+    bool isHostDeviceProcedure,
     const LanguageFeatureControl *features = nullptr);
 
 static constexpr char blankCommonObjectName[] = "__BLNK__";
diff --git a/flang/lib/Evaluate/characteristics.cpp b/flang/lib/Evaluate/characteristics.cpp
index 89547733ea33c..37c62c93a87df 100644
--- a/flang/lib/Evaluate/characteristics.cpp
+++ b/flang/lib/Evaluate/characteristics.cpp
@@ -400,7 +400,7 @@ bool DummyDataObject::IsCompatibleWith(const DummyDataObject &actual,
   }
   if (!attrs.test(Attr::Value) &&
       !common::AreCompatibleCUDADataAttrs(cudaDataAttr, actual.cudaDataAttr,
-          ignoreTKR, warning,
+          ignoreTKR,
           /*allowUnifiedMatchingRule=*/false,
           /*=isHostDeviceProcedure*/ false)) {
     if (whyNot) {
@@ -1816,7 +1816,7 @@ bool DistinguishUtils::Distinguishable(
       x.intent != common::Intent::In) {
     return true;
   } else if (!common::AreCompatibleCUDADataAttrs(x.cudaDataAttr, y.cudaDataAttr,
-                 x.ignoreTKR | y.ignoreTKR, nullptr,
+                 x.ignoreTKR | y.ignoreTKR,
                  /*allowUnifiedMatchingRule=*/false,
                  /*=isHostDeviceProcedure*/ false)) {
     return true;
diff --git a/flang/lib/Semantics/check-call.cpp b/flang/lib/Semantics/check-call.cpp
index 6f2503285013d..83f59f0cac3df 100644
--- a/flang/lib/Semantics/check-call.cpp
+++ b/flang/lib/Semantics/check-call.cpp
@@ -1058,12 +1058,11 @@ static void CheckExplicitDataArg(const characteristics::DummyDataObject &dummy,
             dummyName);
       }
     }
-    std::optional<std::string> warning;
     bool isHostDeviceProc{procedure.cudaSubprogramAttrs &&
         *procedure.cudaSubprogramAttrs ==
             common::CUDASubprogramAttrs::HostDevice};
     if (!common::AreCompatibleCUDADataAttrs(dummyDataAttr, actualDataAttr,
-            dummy.ignoreTKR, &warning, /*allowUnifiedMatchingRule=*/true,
+            dummy.ignoreTKR, /*allowUnifiedMatchingRule=*/true,
             isHostDeviceProc, &context.languageFeatures())) {
       auto toStr{[](std::optional<common::CUDADataAttr> x) {
         return x ? "ATTRIBUTES("s +
@@ -1074,10 +1073,6 @@ static void CheckExplicitDataArg(const characteristics::DummyDataObject &dummy,
           "%s has %s but its associated actual argument has %s"_err_en_US,
           dummyName, toStr(dummyDataAttr), toStr(actualDataAttr));
     }
-    if (warning && context.ShouldWarn(common::UsageWarning::CUDAUsage)) {
-      messages.Say(common::UsageWarning::CUDAUsage, "%s"_warn_en_US,
-          std::move(*warning));
-    }
   }
 
   // Warning for breaking F'2023 change with character allocatables
diff --git a/flang/lib/Support/Fortran.cpp b/flang/lib/Support/Fortran.cpp
index 8e286be1624df..3a8ebbb7d61ef 100644
--- a/flang/lib/Support/Fortran.cpp
+++ b/flang/lib/Support/Fortran.cpp
@@ -103,8 +103,8 @@ std::string AsFortran(IgnoreTKRSet tkr) {
 /// dummy argument attribute while `y` represents the actual argument attribute.
 bool AreCompatibleCUDADataAttrs(std::optional<CUDADataAttr> x,
     std::optional<CUDADataAttr> y, IgnoreTKRSet ignoreTKR,
-    std::optional<std::string> *warning, bool allowUnifiedMatchingRule,
-    bool isHostDeviceProcedure, const LanguageFeatureControl *features) {
+    bool allowUnifiedMatchingRule, bool isHostDeviceProcedure,
+    const LanguageFeatureControl *features) {
   bool isCudaManaged{features
           ? features->IsEnabled(common::LanguageFeature::CudaManaged)
           : false};
@@ -145,9 +145,6 @@ bool AreCompatibleCUDADataAttrs(std::optional<CUDADataAttr> x,
                     *y == CUDADataAttr::Shared ||
                     *y == CUDADataAttr::Constant)) ||
             (!y && (isCudaUnified || isCudaManaged))) {
-          if (y && *y == CUDADataAttr::Shared && warning) {
-            *warning = "SHARED attribute ignored"s;
-          }
           return true;
         }
       } else if (*x == CUDADataAttr::Managed) {
diff --git a/flang/test/Semantics/cuf17.cuf b/flang/test/Semantics/cuf17.cuf
deleted file mode 100644
index daeb59033561c..0000000000000
--- a/flang/test/Semantics/cuf17.cuf
+++ /dev/null
@@ -1,18 +0,0 @@
-! RUN: bbc -emit-hlfir -fcuda %s 2>&1 | FileCheck %s
-
-module mod1
-contains
-
-attributes(device) subroutine sub1(adev)
-  real, device :: adev(10)
-end
-
-attributes(global) subroutine sub2()
-  real, shared :: adev(10)
-  !WARNING: SHARED attribute ignored
-  call sub1(adev)
-end subroutine
-
-end module
-
-! CHECK: warning: SHARED attribute ignored

@clementval clementval merged commit a196281 into llvm:main Aug 7, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:semantics flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants