Skip to content
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

[flang] Make REAL/COMPLEX(10) a hard error for non-x86 targets #124655

Merged
merged 1 commit into from
Jan 31, 2025

Conversation

klausler
Copy link
Contributor

Currently the use of REAL/COMPLEX(KIND=10) as a type or literal constant suffix elicits an optional warning message only. This leads to compiler internal errors during lowering when these types appear in code being compiled to non-x86_64 targets. For better error messaging, make the use of these types a hard error in semantics instead when they are not supported by the target architecture.

@llvmbot llvmbot added flang Flang issues not falling into any other category flang:fir-hlfir flang:openmp flang:semantics labels Jan 27, 2025
@llvmbot
Copy link
Member

llvmbot commented Jan 27, 2025

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

@llvm/pr-subscribers-flang-semantics

Author: Peter Klausler (klausler)

Changes

Currently the use of REAL/COMPLEX(KIND=10) as a type or literal constant suffix elicits an optional warning message only. This leads to compiler internal errors during lowering when these types appear in code being compiled to non-x86_64 targets. For better error messaging, make the use of these types a hard error in semantics instead when they are not supported by the target architecture.


Patch is 21.02 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/124655.diff

30 Files Affected:

  • (modified) flang/include/flang/Common/Fortran-features.h (+1-1)
  • (modified) flang/lib/Common/Fortran-features.cpp (-1)
  • (modified) flang/lib/Semantics/expression.cpp (+2-16)
  • (modified) flang/test/Evaluate/rewrite-out_of_range.F90 (+1)
  • (modified) flang/test/Lower/Intrinsics/aint.f90 (+2-1)
  • (modified) flang/test/Lower/Intrinsics/anint.f90 (+2-1)
  • (modified) flang/test/Lower/Intrinsics/dot_product.f90 (+3-2)
  • (modified) flang/test/Lower/Intrinsics/exponent.f90 (+2-1)
  • (modified) flang/test/Lower/Intrinsics/fraction.f90 (+2-1)
  • (modified) flang/test/Lower/Intrinsics/ieee_class_queries.f90 (+2-1)
  • (modified) flang/test/Lower/Intrinsics/ieee_is_normal.f90 (+3-2)
  • (modified) flang/test/Lower/Intrinsics/ieee_next.f90 (+2-1)
  • (modified) flang/test/Lower/Intrinsics/isnan.f90 (+3-2)
  • (modified) flang/test/Lower/Intrinsics/mod.f90 (+3-2)
  • (modified) flang/test/Lower/Intrinsics/nearest.f90 (+2-1)
  • (modified) flang/test/Lower/Intrinsics/norm2.f90 (+3-2)
  • (modified) flang/test/Lower/Intrinsics/reduce.f90 (+2-1)
  • (modified) flang/test/Lower/Intrinsics/scale.f90 (+2-1)
  • (modified) flang/test/Lower/Intrinsics/set_exponent.f90 (+3-2)
  • (modified) flang/test/Lower/Intrinsics/spacing.f90 (+3-2)
  • (modified) flang/test/Lower/OpenMP/parallel-firstprivate-clause-scalar.f90 (+2-1)
  • (modified) flang/test/Lower/basic-function.f90 (+2-1)
  • (modified) flang/test/Lower/math-lowering/aint.f90 (+7-6)
  • (modified) flang/test/Lower/math-lowering/anint.f90 (+7-6)
  • (modified) flang/test/Lower/math-lowering/sign.f90 (+7-6)
  • (modified) flang/test/Lower/real-descriptors.f90 (+2-1)
  • (modified) flang/test/Lower/real-operations-1.f90 (+2-1)
  • (modified) flang/test/Semantics/kinds01.f90 (+1)
  • (modified) flang/test/Semantics/kinds02.f90 (+1)
  • (modified) flang/test/Semantics/resolve41.f90 (+1-1)
diff --git a/flang/include/flang/Common/Fortran-features.h b/flang/include/flang/Common/Fortran-features.h
index 9549e8bfbbef0b..96c4de74cd6a8d 100644
--- a/flang/include/flang/Common/Fortran-features.h
+++ b/flang/include/flang/Common/Fortran-features.h
@@ -71,7 +71,7 @@ ENUM_CLASS(UsageWarning, Portability, PointerToUndefinable,
     ZeroDoStep, UnusedForallIndex, OpenMPUsage, DataLength, IgnoredDirective,
     HomonymousSpecific, HomonymousResult, IgnoredIntrinsicFunctionType,
     PreviousScalarUse, RedeclaredInaccessibleComponent, ImplicitShared,
-    IndexVarRedefinition, IncompatibleImplicitInterfaces, BadTypeForTarget,
+    IndexVarRedefinition, IncompatibleImplicitInterfaces,
     VectorSubscriptFinalization, UndefinedFunctionResult, UselessIomsg,
     MismatchingDummyProcedure, SubscriptedEmptyArray, UnsignedLiteralTruncation,
     CompatibleDeclarationsFromDistinctModules)
diff --git a/flang/lib/Common/Fortran-features.cpp b/flang/lib/Common/Fortran-features.cpp
index 3565275915a312..bbf16a4f7ac672 100644
--- a/flang/lib/Common/Fortran-features.cpp
+++ b/flang/lib/Common/Fortran-features.cpp
@@ -79,7 +79,6 @@ LanguageFeatureControl::LanguageFeatureControl() {
   warnUsage_.set(UsageWarning::ImplicitShared);
   warnUsage_.set(UsageWarning::IndexVarRedefinition);
   warnUsage_.set(UsageWarning::IncompatibleImplicitInterfaces);
-  warnUsage_.set(UsageWarning::BadTypeForTarget);
   warnUsage_.set(UsageWarning::VectorSubscriptFinalization);
   warnUsage_.set(UsageWarning::UndefinedFunctionResult);
   warnUsage_.set(UsageWarning::UselessIomsg);
diff --git a/flang/lib/Semantics/expression.cpp b/flang/lib/Semantics/expression.cpp
index 3ec6f385ceb86e..22f5f633d3b396 100644
--- a/flang/lib/Semantics/expression.cpp
+++ b/flang/lib/Semantics/expression.cpp
@@ -4079,8 +4079,7 @@ bool ExpressionAnalyzer::CheckIntrinsicKind(
     return true;
   } else if (foldingContext_.targetCharacteristics().CanSupportType(
                  category, kind)) {
-    Warn(common::UsageWarning::BadTypeForTarget,
-        "%s(KIND=%jd) is not an enabled type for this target"_warn_en_US,
+    Say("%s(KIND=%jd) is not an enabled type for this target"_err_en_US,
         ToUpperCase(EnumToString(category)), kind);
     return true;
   } else {
@@ -4102,20 +4101,7 @@ bool ExpressionAnalyzer::CheckIntrinsicSize(
       return false;
     }
   }
-  if (foldingContext_.targetCharacteristics().IsTypeEnabled(
-          category, kind)) { // C712, C714, C715, C727
-    return true;
-  } else if (foldingContext_.targetCharacteristics().CanSupportType(
-                 category, kind)) {
-    Warn(common::UsageWarning::BadTypeForTarget,
-        "%s*%jd is not an enabled type for this target"_warn_en_US,
-        ToUpperCase(EnumToString(category)), size);
-    return true;
-  } else {
-    Say("%s*%jd is not a supported type"_err_en_US,
-        ToUpperCase(EnumToString(category)), size);
-    return false;
-  }
+  return CheckIntrinsicKind(category, kind);
 }
 
 bool ExpressionAnalyzer::AddImpliedDo(parser::CharBlock name, int kind) {
diff --git a/flang/test/Evaluate/rewrite-out_of_range.F90 b/flang/test/Evaluate/rewrite-out_of_range.F90
index b5df610ff2fbbb..70dc0da47445f3 100644
--- a/flang/test/Evaluate/rewrite-out_of_range.F90
+++ b/flang/test/Evaluate/rewrite-out_of_range.F90
@@ -1,4 +1,5 @@
 ! Tests rewriting of OUT_OF_RANGE()
+! REQUIRES: x86-registered-target
 ! RUN: %flang_fc1 -fdebug-unparse -cpp %s 2>&1 | FileCheck %s --check-prefixes=CHECK%if target=x86_64{{.*}} %{,CHECK-X86-64%}
 
 logical round
diff --git a/flang/test/Lower/Intrinsics/aint.f90 b/flang/test/Lower/Intrinsics/aint.f90
index fb459953a06c3f..6a1a0351f496c3 100644
--- a/flang/test/Lower/Intrinsics/aint.f90
+++ b/flang/test/Lower/Intrinsics/aint.f90
@@ -1,4 +1,5 @@
-! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s
+! REQUIRES: x86_64-registered-target
+! RUN: bbc -target x86_64-unknown-linux-gnu -emit-fir -hlfir=false -target x86_64-unknown-linux-gnu %s -o - | FileCheck %s
 
 ! CHECK-LABEL: func @_QPaint_test(
 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<f32>{{.*}}, %[[VAL_1:.*]]: !fir.ref<f32>{{.*}}) {
diff --git a/flang/test/Lower/Intrinsics/anint.f90 b/flang/test/Lower/Intrinsics/anint.f90
index 4148d18f15b30d..d4792295ca6cfa 100644
--- a/flang/test/Lower/Intrinsics/anint.f90
+++ b/flang/test/Lower/Intrinsics/anint.f90
@@ -1,4 +1,5 @@
-! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s
+! REQUIRES: x86_64-registered-target
+! RUN: bbc -target x86_64-unknown-linux-gnu -emit-fir -hlfir=false -target x86_64-unknown-linux-gnu %s -o - | FileCheck %s
 
 ! CHECK-LABEL: func.func @_QPanint_test(
 ! CHECK-SAME:                           %[[VAL_0:.*]]: !fir.ref<f32> {fir.bindc_name = "a"},
diff --git a/flang/test/Lower/Intrinsics/dot_product.f90 b/flang/test/Lower/Intrinsics/dot_product.f90
index 9a825c4b9acf19..df3e4fccec7365 100644
--- a/flang/test/Lower/Intrinsics/dot_product.f90
+++ b/flang/test/Lower/Intrinsics/dot_product.f90
@@ -1,5 +1,6 @@
-! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s
-! RUN: %flang_fc1 -emit-fir -flang-deprecated-no-hlfir %s -o - | FileCheck %s
+! REQUIRES: x86_64-registered-target
+! RUN: bbc -target x86_64-unknown-linux-gnu -emit-fir -hlfir=false %s -o - | FileCheck %s
+! RUN: %flang_fc1 -target x86_64-unknown-linux-gnu -emit-fir -flang-deprecated-no-hlfir %s -o - | FileCheck %s
 
 ! DOT_PROD
 ! CHECK-LABEL: dot_prod_int_default
diff --git a/flang/test/Lower/Intrinsics/exponent.f90 b/flang/test/Lower/Intrinsics/exponent.f90
index e4db238c6d5a2b..0a0e7a08341540 100644
--- a/flang/test/Lower/Intrinsics/exponent.f90
+++ b/flang/test/Lower/Intrinsics/exponent.f90
@@ -1,4 +1,5 @@
-! RUN: bbc -emit-fir %s -o - | FileCheck %s
+! REQUIRES: x86_64-registered-target
+! RUN: bbc -target x86_64-unknown-linux-gnu -emit-fir %s -o - | FileCheck %s
 
 ! EXPONENT
 ! CHECK-LABEL: exponent_test
diff --git a/flang/test/Lower/Intrinsics/fraction.f90 b/flang/test/Lower/Intrinsics/fraction.f90
index f9fff725eb27a5..b49dd9ee3427e4 100644
--- a/flang/test/Lower/Intrinsics/fraction.f90
+++ b/flang/test/Lower/Intrinsics/fraction.f90
@@ -1,4 +1,5 @@
-! RUN: bbc -emit-fir %s -o - | FileCheck %s
+! REQUIRES: x86_64-registered-target
+! RUN: bbc -target x86_64-unknown-linux-gnu -emit-fir %s -o - | FileCheck %s
  
 ! FRACTION
 ! CHECK-LABE: fraction_test
diff --git a/flang/test/Lower/Intrinsics/ieee_class_queries.f90 b/flang/test/Lower/Intrinsics/ieee_class_queries.f90
index b2f9df83a902a0..ac04f967fca4d3 100644
--- a/flang/test/Lower/Intrinsics/ieee_class_queries.f90
+++ b/flang/test/Lower/Intrinsics/ieee_class_queries.f90
@@ -1,5 +1,6 @@
 ! REQUIRES: flang-supports-f128-math
-! RUN: bbc -emit-fir -o - %s | FileCheck %s
+! REQUIRES: x86_64-registered-target
+! RUN: bbc -target x86_64-unknown-linux-gnu -emit-fir -o - %s | FileCheck %s
 
   ! CHECK-LABEL: func @_QQmain
   use ieee_arithmetic, only: ieee_is_finite, ieee_is_nan, ieee_is_negative, &
diff --git a/flang/test/Lower/Intrinsics/ieee_is_normal.f90 b/flang/test/Lower/Intrinsics/ieee_is_normal.f90
index 9b864c9a9849c3..445427e2d403e6 100644
--- a/flang/test/Lower/Intrinsics/ieee_is_normal.f90
+++ b/flang/test/Lower/Intrinsics/ieee_is_normal.f90
@@ -1,5 +1,6 @@
-! RUN: bbc -emit-fir %s -o - | FileCheck %s
-! RUN: flang -fc1 -emit-fir %s -o - | FileCheck %s
+! REQUIRES: x86_64-registered-target
+! RUN: bbc -target x86_64-unknown-linux-gnu -emit-fir %s -o - | FileCheck %s
+! RUN: %flang_fc1 -target x86_64-unknown-linux-gnu -emit-fir %s -o - | FileCheck %s
 
 ! CHECK-LABEL: ieee_is_normal_f16
 subroutine ieee_is_normal_f16(r)
diff --git a/flang/test/Lower/Intrinsics/ieee_next.f90 b/flang/test/Lower/Intrinsics/ieee_next.f90
index eb9cc028368a5a..f2025c2c7bfd36 100644
--- a/flang/test/Lower/Intrinsics/ieee_next.f90
+++ b/flang/test/Lower/Intrinsics/ieee_next.f90
@@ -1,4 +1,5 @@
-! RUN: bbc -emit-fir -o - %s | FileCheck %s
+! REQUIRES: x86_64-registered-target
+! RUN: bbc -target x86_64-unknown-linux-gnu -emit-fir -o - %s | FileCheck %s
 
 ! CHECK-LABEL: c.func @_QQmain
 program p
diff --git a/flang/test/Lower/Intrinsics/isnan.f90 b/flang/test/Lower/Intrinsics/isnan.f90
index 62b98c8ea98bee..a19ea79080118a 100644
--- a/flang/test/Lower/Intrinsics/isnan.f90
+++ b/flang/test/Lower/Intrinsics/isnan.f90
@@ -1,5 +1,6 @@
-! RUN: bbc -emit-fir %s -o - | FileCheck %s
-! RUN: flang -fc1 -emit-fir %s -o - | FileCheck %s
+! REQUIRES: x86_64-registered-target
+! RUN: bbc -target x86_64-unknown-linux-gnu -emit-fir %s -o - | FileCheck %s
+! RUN: %flang_fc1 -target x86_64-unknown-linux-gnu -emit-fir %s -o - | FileCheck %s
 
 ! CHECK-LABEL: isnan_f32
 subroutine isnan_f32(r)
diff --git a/flang/test/Lower/Intrinsics/mod.f90 b/flang/test/Lower/Intrinsics/mod.f90
index 3f5385ac303ab4..a583d0ce09ea3a 100644
--- a/flang/test/Lower/Intrinsics/mod.f90
+++ b/flang/test/Lower/Intrinsics/mod.f90
@@ -1,5 +1,6 @@
-! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s
-! RUN: %flang_fc1 -emit-fir -flang-deprecated-no-hlfir %s -o - | FileCheck %s
+! REQUIRES: x86_64-registered-target
+! RUN: bbc -target x86_64-unknown-linux-gnu -emit-fir -hlfir=false %s -o - | FileCheck %s
+! RUN: %flang_fc1 -target x86_64-unknown-linux-gnu -emit-fir -flang-deprecated-no-hlfir %s -o - | FileCheck %s
 
 ! CHECK-LABEL: func @_QPmod_testr4(
 ! CHECK-SAME: %[[arg0:.*]]: !fir.ref<f32>{{.*}}, %[[arg1:.*]]: !fir.ref<f32>{{.*}}, %[[arg2:.*]]: !fir.ref<f32>{{.*}}) {
diff --git a/flang/test/Lower/Intrinsics/nearest.f90 b/flang/test/Lower/Intrinsics/nearest.f90
index 5920d299d5fdf3..0b807329196a2d 100644
--- a/flang/test/Lower/Intrinsics/nearest.f90
+++ b/flang/test/Lower/Intrinsics/nearest.f90
@@ -1,4 +1,5 @@
-! RUN: bbc -emit-fir %s -o - | FileCheck %s
+! REQUIRES: x86_64-registered-target
+! RUN: bbc -target x86_64-unknown-linux-gnu -emit-fir %s -o - | FileCheck %s
 
 ! CHECK-LABEL: c.func @_QPnearest_test1
   ! CHECK:     %[[V_0:[0-9]+]] = fir.dummy_scope : !fir.dscope
diff --git a/flang/test/Lower/Intrinsics/norm2.f90 b/flang/test/Lower/Intrinsics/norm2.f90
index ac761ae3f53817..497ec8eb6e3797 100644
--- a/flang/test/Lower/Intrinsics/norm2.f90
+++ b/flang/test/Lower/Intrinsics/norm2.f90
@@ -1,5 +1,6 @@
-! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s
-! RUN: %flang_fc1 -emit-fir -flang-deprecated-no-hlfir %s -o - | FileCheck %s
+! REQUIRES: x86_64-registered-target
+! RUN: bbc -target x86_64-unknown-linux-gnu -emit-fir -hlfir=false %s -o - | FileCheck %s
+! RUN: %flang_fc1 -target x86_64-unknown-linux-gnu -emit-fir -flang-deprecated-no-hlfir %s -o - | FileCheck %s
 
 ! CHECK-LABEL: func @_QPnorm2_test_4(
 ! CHECK-SAME: %[[arg0:.*]]: !fir.box<!fir.array<?xf32>>{{.*}}) -> f32
diff --git a/flang/test/Lower/Intrinsics/reduce.f90 b/flang/test/Lower/Intrinsics/reduce.f90
index 8d7ec89d27474c..ff533304f03d61 100644
--- a/flang/test/Lower/Intrinsics/reduce.f90
+++ b/flang/test/Lower/Intrinsics/reduce.f90
@@ -1,4 +1,5 @@
-! RUN: bbc -emit-hlfir %s -o - | FileCheck %s
+! REQUIRES: x86_64-registered-target
+! RUN: bbc -target x86_64-unknown-linux-gnu -emit-hlfir %s -o - | FileCheck %s
 
 module reduce_mod
 
diff --git a/flang/test/Lower/Intrinsics/scale.f90 b/flang/test/Lower/Intrinsics/scale.f90
index 91892838ea5131..d4f849af392115 100644
--- a/flang/test/Lower/Intrinsics/scale.f90
+++ b/flang/test/Lower/Intrinsics/scale.f90
@@ -1,4 +1,5 @@
-! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s
+! REQUIRES: x86_64-registered-target
+! RUN: bbc -target x86_64-unknown-linux-gnu -emit-fir -hlfir=false %s -o - | FileCheck %s
 
 ! CHECK-LABEL: scale_test1
 subroutine scale_test1(x, i)
diff --git a/flang/test/Lower/Intrinsics/set_exponent.f90 b/flang/test/Lower/Intrinsics/set_exponent.f90
index fedbad78747a96..129b2b6e3f9e82 100644
--- a/flang/test/Lower/Intrinsics/set_exponent.f90
+++ b/flang/test/Lower/Intrinsics/set_exponent.f90
@@ -1,5 +1,6 @@
-! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s
-! RUN: %flang_fc1 -emit-fir -flang-deprecated-no-hlfir %s -o - | FileCheck %s
+! REQUIRES: x86_64-registered-target
+! RUN: bbc -target x86_64-unknown-linux-gnu -emit-fir -hlfir=false %s -o - | FileCheck %s
+! RUN: %flang_fc1 -target x86_64-unknown-linux-gnu -emit-fir -flang-deprecated-no-hlfir %s -o - | FileCheck %s
 
 ! SET_EXPONENT
 ! CHECK-LABEL: set_exponent_test
diff --git a/flang/test/Lower/Intrinsics/spacing.f90 b/flang/test/Lower/Intrinsics/spacing.f90
index 151f4e2a6d236e..f12388a0249ae7 100644
--- a/flang/test/Lower/Intrinsics/spacing.f90
+++ b/flang/test/Lower/Intrinsics/spacing.f90
@@ -1,5 +1,6 @@
-! RUN: bbc -emit-fir %s -o - | FileCheck %s
-! RUN: %flang_fc1 -emit-fir %s -o - | FileCheck %s
+! REQUIRES: x86_64-registered-target
+! RUN: bbc -target x86_64-unknown-linux-gnu -emit-fir %s -o - | FileCheck %s
+! RUN: %flang_fc1 -target x86_64-unknown-linux-gnu -emit-fir %s -o - | FileCheck %s
 
 ! CHECK-LABEL: func @_QPspacing_test(
 real*4 function spacing_test(x)
diff --git a/flang/test/Lower/OpenMP/parallel-firstprivate-clause-scalar.f90 b/flang/test/Lower/OpenMP/parallel-firstprivate-clause-scalar.f90
index f0bee355543a67..2e2a85be488b2d 100644
--- a/flang/test/Lower/OpenMP/parallel-firstprivate-clause-scalar.f90
+++ b/flang/test/Lower/OpenMP/parallel-firstprivate-clause-scalar.f90
@@ -1,7 +1,8 @@
 ! This test checks lowering of `FIRSTPRIVATE` clause for scalar types.
 
+! REQUIRES: x86_64-registered-target
 ! REQUIRES: shell
-! RUN: bbc -fopenmp -emit-hlfir %s -o - \
+! RUN: bbc -target x86_64-unknown-linux-gnu -fopenmp -emit-hlfir %s -o - \
 ! RUN: | FileCheck %s --check-prefix=CHECK
 
 !CHECK:  omp.private {type = firstprivate} @[[ARG2_LOGICAL_PRIVATIZER:_QFfirstprivate_logicalEarg2_firstprivate_ref_l8]] : !fir.ref<!fir.logical<1>> alloc
diff --git a/flang/test/Lower/basic-function.f90 b/flang/test/Lower/basic-function.f90
index 5f2fabe1b325d2..90761e13d53f62 100644
--- a/flang/test/Lower/basic-function.f90
+++ b/flang/test/Lower/basic-function.f90
@@ -1,4 +1,5 @@
-! RUN: bbc %s -o "-" -emit-fir -hlfir=false | FileCheck %s
+! REQUIRES: x86_64-registered-target
+! RUN: bbc -target x86_64-unknown-linux-gnu %s -o "-" -emit-fir -hlfir=false | FileCheck %s
 
 integer(1) function fct1()
 end
diff --git a/flang/test/Lower/math-lowering/aint.f90 b/flang/test/Lower/math-lowering/aint.f90
index e8b17aad675c1c..352e2bceac1a2f 100644
--- a/flang/test/Lower/math-lowering/aint.f90
+++ b/flang/test/Lower/math-lowering/aint.f90
@@ -1,9 +1,10 @@
-! RUN: bbc -emit-fir %s -o - --math-runtime=fast | FileCheck --check-prefixes=ALL %s
-! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=fast %s -o - | FileCheck --check-prefixes=ALL %s
-! RUN: bbc -emit-fir %s -o - --math-runtime=relaxed | FileCheck --check-prefixes=ALL %s
-! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=relaxed %s -o - | FileCheck --check-prefixes=ALL %s
-! RUN: bbc -emit-fir %s -o - --math-runtime=precise | FileCheck --check-prefixes=ALL %s
-! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=precise %s -o - | FileCheck --check-prefixes=ALL %s
+! REQUIRES: x86_64-registered-target
+! RUN: bbc -target x86_64-unknown-linux-gnu -emit-fir %s -o - --math-runtime=fast | FileCheck --check-prefixes=ALL %s
+! RUN: %flang_fc1 -target x86_64-unknown-linux-gnu -emit-fir -mllvm -math-runtime=fast %s -o - | FileCheck --check-prefixes=ALL %s
+! RUN: bbc -target x86_64-unknown-linux-gnu -emit-fir %s -o - --math-runtime=relaxed | FileCheck --check-prefixes=ALL %s
+! RUN: %flang_fc1 -target x86_64-unknown-linux-gnu -emit-fir -mllvm -math-runtime=relaxed %s -o - | FileCheck --check-prefixes=ALL %s
+! RUN: bbc -target x86_64-unknown-linux-gnu -emit-fir %s -o - --math-runtime=precise | FileCheck --check-prefixes=ALL %s
+! RUN: %flang_fc1 -target x86_64-unknown-linux-gnu -emit-fir -mllvm -math-runtime=precise %s -o - | FileCheck --check-prefixes=ALL %s
 
 function test_real4(x)
   real :: x, test_real4
diff --git a/flang/test/Lower/math-lowering/anint.f90 b/flang/test/Lower/math-lowering/anint.f90
index 45dc3ef1d858ed..b0a22923da739c 100644
--- a/flang/test/Lower/math-lowering/anint.f90
+++ b/flang/test/Lower/math-lowering/anint.f90
@@ -1,9 +1,10 @@
-! RUN: bbc -emit-fir %s -o - --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %s
-! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=fast %s -o - | FileCheck --check-prefixes=ALL,FAST %s
-! RUN: bbc -emit-fir %s -o - --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %s
-! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=relaxed %s -o - | FileCheck --check-prefixes=ALL,RELAXED %s
-! RUN: bbc -emit-fir %s -o - --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %s
-! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=precise %s -o - | FileCheck --check-prefixes=ALL,PRECISE %s
+! REQUIRES: x86_64-registered-target
+! RUN: bbc -target x86_64-unknown-linux-gnu -emit-fir %s -o - --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %s
+! RUN: %flang_fc1 -target x86_64-unknown-linux-gnu -emit-fir -mllvm -math-runtime=fast %s -o - | FileCheck --check-prefixes=ALL,FAST %s
+! RUN: bbc -target x86_64-unknown-linux-gnu -emit-fir %s -o - --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %s
+! RUN: %flang_fc1 -target x86_64-unknown-linux-gnu -emit-fir -mllvm -math-runtime=relaxed %s -o - | FileCheck --check-prefixes=ALL,RELAXED %s
+! RUN: bbc -target x86_64-unknown-linux-gnu -emit-fir %s -o - --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %s
+! RUN: %flang_fc1 -target x86_64-unknown-linux-gnu -emit-fir -mllvm -math-runtime=precise %s -o - | FileCheck --check-prefixes=ALL,PRECISE %s
 
 function test_real4(x)
   real :: x, test_real4
diff --git a/flang/test/Lower/math-lowering/sign.f90 b/flang/test/Lower/math-lowering/sign.f90
index fbb47cdebef309..e7ce79b7653a3e 100644
--- a/flang/test/Lower/math-lowering/sign.f90
+++ b/flang/test/Lower/math-lowering/sign.f90
@@ -1,9 +1,10 @@
-! RUN: bbc -emit-fir %s -o - --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %s
-! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=fast %s -o - | FileCheck --check-prefixes=ALL,FAST %s
-! RUN: bbc -emit-fir %s -o - --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %s
-! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=relaxed %s -o - | FileCheck --check-prefixes=ALL,RELAXED %s
-! RUN: bbc -emit-fir %s -o - --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %s
-! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=precise %s -o - | FileCheck --check-prefixes=ALL,PRECISE %s
+! REQUIRES: x86_64-registered-target
+! RUN: bbc -target x86_64-unknown-linux-gnu -emit-fir %s -o - --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %s
+! RUN: %flang_fc1 -target x86_64-unknown-linux-gnu -emit-fir -mllvm -math-runtime=fast %s -o - | FileCheck --check-prefixes=ALL,FAST %s
+! RUN: bbc -target x86_64-unknown-linux-gnu -emit-fir %s -o - --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %s
+! RUN: %flang_fc1 -target x86_64-unknown-linux-gnu -emit-fir -mllvm -math-runtime=relaxed %s -o - | FileCheck --check-prefixes=ALL,RELAXED %s
+! RUN: bbc -target x86_64-unknown-linux-gnu -emit-fir %s -o - --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %s
+! RUN: %flang_fc1 -target x86_64-unknown-linux-gnu -emit-fir -mllvm -math-runtime=precise %s -o - | FileCheck --check-prefixes=ALL,PRECISE %s
 
 function test_real4(x, y)
   real :: x, y, test_real4
diff --git a/flang/test/Lower/real-descriptors.f90 b/flang/test/Lower/real-descriptors.f90
index ff7fdc68e7b3a1..ee6d80861eace3 100644
--- a/flang/test/Lower/real-descriptors.f90
+++ b/flang/test/Lower/real-descriptors.f90
@@ -1,4 +1,5 @@
-! RUN: bbc %s -o - | tco | FileCheck %s
+! REQUIRES: x86_64-registered-target
+! RUN: bbc -target x86_64-unknown-linux-gnu %s -o - | tco | FileCheck %s
 
 ! CHECK-LABEL: define void @_QQmain()
 program p
diff --git a/flang/test/Lower/real-operations-1.f90 b/flang/test/Lower/real-operations-1.f90
index 137d0b5264c25d..66d345cd13b0e9 100644
--- a/flang/test/Lower/real-operations-1.f90
+++ b/flang/test/Lower/real-operations-1.f90
@@ -1,4 +1,5 @@
-! RUN: bbc -hlfir=false %s -o - | FileCheck %s
+! REQUIRES: x86_64-registered-target
+! RUN: bbc -target x86_64-unknown-linux-gnu -hlfir=false %s -o - | FileCheck %s
 
 ! Test real add on real kinds.
 
diff --git a/flang/test/Semantics/kinds01.f90 b/flang/test/Semantics/kinds01.f90
index 5238a90719fe46..82c4d76da3710c 100644
--- a/flang/test/Semantics/kinds01.f90
+++ b/flang/test/Semantics/kinds01.f90
@@ -1,3 +1,4 @@
+! REQUIRES: x86_64-registered-target
 ! RUN: %python %S/tes...
[truncated]

Copy link
Contributor

@jeanPerier jeanPerier left a comment

Choose a reason for hiding this comment

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

The compiler change looks good to me, but I do not like disabling tests on ARM/Power architectures just because they had one line using KIND=10.

Lit tests CHECK lines can be tuned to only do some checks on some architectures (like it is done in test/Evaluate/rewrite-out_of_range.F90 for instance).

Is there a macro detecting X86_64 that flang can use wrap parts of the code using KIND=10 (I tried __x86_64__, but that does not seem to work)?

Otherwise, the 10s could also be replaced by SELECTED_REAL_KIND.

@luporl
Copy link
Contributor

luporl commented Jan 28, 2025

Is there a macro detecting X86_64 that flang can use wrap parts of the code using KIND=10 (I tried __x86_64__, but that does not seem to work)?

It is __x86_64__ indeed, but preprocessing must be on. An example is flang/test/Lower/assignment.f90.

@jeanPerier
Copy link
Contributor

jeanPerier commented Jan 28, 2025

It is x86_64 indeed, but preprocessing must be on. An example is flang/test/Lower/assignment.f90.

Ah, that makes sense. bbc does not do it, so the lowering test driver need to change (bbc goal is to remain simple). @klausler, no need to update the lowering tests then, you can keep them as in your patch, I will re-enable them with other update to these tests to drop the "hlfir=false" anyway.

@kkwli
Copy link
Collaborator

kkwli commented Jan 28, 2025

I see the following LIT failures on ppc64le-*-linux.

Failed Tests (10):
  Flang :: Lower/HLFIR/convert-variable.f90
  Flang :: Lower/Intrinsics/abs.f90
  Flang :: Lower/Intrinsics/fma_real16.f90
  Flang :: Lower/Intrinsics/modulo.f90
  Flang :: Lower/Intrinsics/powi_real16.f90
  Flang :: Lower/Intrinsics/random_number_real16.f90
  Flang :: Lower/Intrinsics/rrspacing.f90
  Flang :: Lower/Intrinsics/sign.f90
  Flang :: Lower/assignment.f90
  Flang :: Lower/math-lowering/abs.f90

@klausler
Copy link
Contributor Author

I see the following LIT failures on ppc64le-*-linux.

Failed Tests (10):
  Flang :: Lower/HLFIR/convert-variable.f90
  Flang :: Lower/Intrinsics/abs.f90
  Flang :: Lower/Intrinsics/fma_real16.f90
  Flang :: Lower/Intrinsics/modulo.f90
  Flang :: Lower/Intrinsics/powi_real16.f90
  Flang :: Lower/Intrinsics/random_number_real16.f90
  Flang :: Lower/Intrinsics/rrspacing.f90
  Flang :: Lower/Intrinsics/sign.f90
  Flang :: Lower/assignment.f90
  Flang :: Lower/math-lowering/abs.f90

do you have any more information on those failures? I don't have a Power system any more that can build LLVM.

@kkwli
Copy link
Collaborator

kkwli commented Jan 28, 2025

I see the following LIT failures on ppc64le-*-linux.

Failed Tests (10):
  Flang :: Lower/HLFIR/convert-variable.f90
  Flang :: Lower/Intrinsics/abs.f90
  Flang :: Lower/Intrinsics/fma_real16.f90
  Flang :: Lower/Intrinsics/modulo.f90
  Flang :: Lower/Intrinsics/powi_real16.f90
  Flang :: Lower/Intrinsics/random_number_real16.f90
  Flang :: Lower/Intrinsics/rrspacing.f90
  Flang :: Lower/Intrinsics/sign.f90
  Flang :: Lower/assignment.f90
  Flang :: Lower/math-lowering/abs.f90

do you have any more information on those failures? I don't have a Power system any more that can build LLVM.

Oops forgot to include the details. They are all due to real(16) in the test.

FAIL: Flang :: Lower/HLFIR/convert-variable.f90 (14 of 1062)
******************** TEST 'Flang :: Lower/HLFIR/convert-variable.f90' FAILED ********************
Exit Code: 2

Command Output (stderr):
--
RUN: at line 2: bbc -emit-hlfir /scratch/kli/llvm-project/flang/test/Lower/HLFIR/convert-variable.f90 -o - | /scratch/kli/wrk/f/build-flang-local/bin/FileCheck /scratch/kli/llvm-project/flang/test/Lower/HLFIR/convert-variable.f90
+ bbc -emit-hlfir /scratch/kli/llvm-project/flang/test/Lower/HLFIR/convert-variable.f90 -o -
+ /scratch/kli/wrk/f/build-flang-local/bin/FileCheck /scratch/kli/llvm-project/flang/test/Lower/HLFIR/convert-variable.f90
/scratch/kli/llvm-project/flang/test/Lower/HLFIR/convert-variable.f90:71:3: error: REAL(KIND=16) is not an enabled type for this target
    real(16), value :: x(100)
    ^^^^^^^^^^^^^^^^^^^^^^^^^
bbc: semantic errors in /scratch/kli/llvm-project/flang/test/Lower/HLFIR/convert-variable.f90
FileCheck error: '<stdin>' is empty.
FileCheck command line:  /scratch/kli/wrk/f/build-flang-local/bin/FileCheck /scratch/kli/llvm-project/flang/test/Lower/HLFIR/convert-variable.f90

--

********************

@klausler
Copy link
Contributor Author

does flang-new support 128-bit reals on Power at all?

@kkwli
Copy link
Collaborator

kkwli commented Jan 29, 2025

does flang-new support 128-bit reals on Power at all?

Not at this point.

@eugeneepshteyn
Copy link
Contributor

does flang-new support 128-bit reals on Power at all?

Not at this point.

So perhaps these tests should be disabled for Power? Possibly via UNSUPPORTED?

@klausler
Copy link
Contributor Author

I have added REQUIRES lines to those tests. @kkwli please let me know whether this resolves the problem that you observed on ppc64le. Thanks!

@kkwli
Copy link
Collaborator

kkwli commented Jan 29, 2025

Thanks @klausler. The failures go away. However, this approach will also skip testing of real(4) and real(8) on the platform. I notice that other tests (e.g. acos.f90) separate out the real(16) test (e.g. acos_real16.f90). Is it a feasible solution that all platforms continue to test real(4) and real(8) and only platforms that support read(16) will test the corresponding version of test? If we're okay with this idea, I can put up a PR for further discussion.

@klausler
Copy link
Contributor Author

I'll see whether I can restrict the changes with preprocessing &/or SELECTED_REAL_KIND instead.

@@ -1,7 +1,7 @@
! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s --check-prefixes="CHECK,CMPLX,CMPLX-PRECISE"
! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s --check-prefixes=%if system-aix %{CHECK,CMPLX,CMPLX-PRECISE,F64%} %else %{CHECK,CMPLX,CMPLX-PRECISE,F128%}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s --check-prefixes=%if system-aix %{CHECK,CMPLX,CMPLX-PRECISE,F64%} %else %{CHECK,CMPLX,CMPLX-PRECISE,F128%}
! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s --check-prefixes=CHECK,CMPLX,CMPLX-PRECISE,%if system-aix %{F64%} %else %{F128%}

@klausler klausler force-pushed the bug191 branch 4 times, most recently from b21577d to be64abc Compare January 30, 2025 23:51
@klausler klausler force-pushed the bug191 branch 2 times, most recently from 83e9319 to a22b579 Compare January 31, 2025 16:53
Currently the use of REAL/COMPLEX(KIND=10) as a type or literal
constant suffix elicits an optional warning message only.  This
leads to compiler internal errors during lowering when these types
appear in code being compiled to non-x86_64 targets.  For better
error messaging, make the use of these types a hard error in semantics
instead when they are not supported by the target architecture.
Copy link
Collaborator

@kkwli kkwli left a comment

Choose a reason for hiding this comment

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

It works for powerpc64le-*-linux and powerpc*-*-aix. Thanks.

@klausler klausler merged commit 2bfb3ba into llvm:main Jan 31, 2025
8 checks passed
@klausler klausler deleted the bug191 branch January 31, 2025 19:43
@@ -1,5 +1,7 @@
! Tests rewriting of OUT_OF_RANGE()
! RUN: %flang_fc1 -fdebug-unparse -cpp %s 2>&1 | FileCheck %s --check-prefixes=CHECK%if target=x86_64{{.*}} %{,CHECK-X86-64%}
! REQUIRES: target=x86-64{{.*}}
Copy link
Collaborator

Choose a reason for hiding this comment

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

@klausler did you mean x86_64 (with an underscore instead of a hyphen) like you did in the predicate of line 4?

(The test is not being run at all as unsupported, not even on x86_64)

Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch!
#126699

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

Successfully merging this pull request may close these issues.

7 participants