[PATCH] D109943: [Clang] Fix long double availability check

Qiu Chaofan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 17 00:34:10 PDT 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rG0195f8621f18: [Clang] Fix long double availability check (authored by qiucf).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109943/new/

https://reviews.llvm.org/D109943

Files:
  clang/lib/Sema/Sema.cpp
  clang/test/OpenMP/amdgcn_ldbl_check.cpp


Index: clang/test/OpenMP/amdgcn_ldbl_check.cpp
===================================================================
--- /dev/null
+++ clang/test/OpenMP/amdgcn_ldbl_check.cpp
@@ -0,0 +1,27 @@
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang_cc1 -triple x86_64-mingw64 -emit-llvm-bc -target-cpu x86-64 -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -o %t.bc -x c++ %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -aux-triple x86_64-mingw64 -fsyntax-only -target-cpu gfx900 -fopenmp -fopenmp-is-device -fopenmp-host-ir-file-path %t.bc -x c++ %s
+// expected-no-diagnostics
+
+void print(double);
+
+constexpr double operator"" _X (long double a)
+{
+	return (double)a;
+}
+
+int main()
+{
+	auto a = 1._X;
+  print(a);
+#pragma omp target map(tofrom: a)
+	{
+#pragma omp teams num_teams(1) thread_limit(4)
+		{
+			a += 1._X;
+		}
+	}
+  print(a);
+	return 0;
+}
Index: clang/lib/Sema/Sema.cpp
===================================================================
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -1892,8 +1892,10 @@
     bool LongDoubleMismatched = false;
     if (Ty->isRealFloatingType() && Context.getTypeSize(Ty) == 128) {
       const llvm::fltSemantics &Sem = Context.getFloatTypeSemantics(Ty);
-      if (!Ty->isIbm128Type() && !Ty->isFloat128Type() &&
-          &Sem != &Context.getTargetInfo().getLongDoubleFormat())
+      if ((&Sem != &llvm::APFloat::PPCDoubleDouble() &&
+           !Context.getTargetInfo().hasFloat128Type()) ||
+          (&Sem == &llvm::APFloat::PPCDoubleDouble() &&
+           !Context.getTargetInfo().hasIbm128Type()))
         LongDoubleMismatched = true;
     }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109943.373155.patch
Type: text/x-patch
Size: 1629 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210917/a1acd9ea/attachment-0001.bin>


More information about the cfe-commits mailing list