r360809 - [OpenMP][Bugfix] Move double and float versions of abs under c++ macro

Gheorghe-Teodor Bercea via cfe-commits cfe-commits at lists.llvm.org
Wed May 15 13:28:23 PDT 2019


Author: gbercea
Date: Wed May 15 13:28:23 2019
New Revision: 360809

URL: http://llvm.org/viewvc/llvm-project?rev=360809&view=rev
Log:
[OpenMP][Bugfix] Move double and float versions of abs under c++ macro

Summary:
This is a fix for the reported bug:

[[ https://bugs.llvm.org/show_bug.cgi?id=41861 | 41861 ]]

abs functions need to be moved under the c++ macro to avoid conflicts with included headers.

Reviewers: tra, jdoerfert, hfinkel, ABataev, caomhin

Reviewed By: jdoerfert

Subscribers: guansong, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D61959

Modified:
    cfe/trunk/lib/Headers/__clang_cuda_cmath.h
    cfe/trunk/lib/Headers/__clang_cuda_math_forward_declares.h
    cfe/trunk/test/Headers/Inputs/include/cstdlib
    cfe/trunk/test/Headers/nvptx_device_cmath_functions.c
    cfe/trunk/test/Headers/nvptx_device_cmath_functions.cpp
    cfe/trunk/test/Headers/nvptx_device_cmath_functions_cxx17.cpp
    cfe/trunk/test/Headers/nvptx_device_math_functions.c
    cfe/trunk/test/Headers/nvptx_device_math_functions.cpp
    cfe/trunk/test/Headers/nvptx_device_math_functions_cxx17.cpp

Modified: cfe/trunk/lib/Headers/__clang_cuda_cmath.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_cmath.h?rev=360809&r1=360808&r2=360809&view=diff
==============================================================================
--- cfe/trunk/lib/Headers/__clang_cuda_cmath.h (original)
+++ cfe/trunk/lib/Headers/__clang_cuda_cmath.h Wed May 15 13:28:23 2019
@@ -48,9 +48,9 @@
 #if !(defined(_OPENMP) && defined(__cplusplus))
 __DEVICE__ long long abs(long long __n) { return ::llabs(__n); }
 __DEVICE__ long abs(long __n) { return ::labs(__n); }
-#endif
 __DEVICE__ float abs(float __x) { return ::fabsf(__x); }
 __DEVICE__ double abs(double __x) { return ::fabs(__x); }
+#endif
 __DEVICE__ float acos(float __x) { return ::acosf(__x); }
 __DEVICE__ float asin(float __x) { return ::asinf(__x); }
 __DEVICE__ float atan(float __x) { return ::atanf(__x); }

Modified: cfe/trunk/lib/Headers/__clang_cuda_math_forward_declares.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_math_forward_declares.h?rev=360809&r1=360808&r2=360809&view=diff
==============================================================================
--- cfe/trunk/lib/Headers/__clang_cuda_math_forward_declares.h (original)
+++ cfe/trunk/lib/Headers/__clang_cuda_math_forward_declares.h Wed May 15 13:28:23 2019
@@ -39,10 +39,10 @@
 #if !(defined(_OPENMP) && defined(__cplusplus))
 __DEVICE__ long abs(long);
 __DEVICE__ long long abs(long long);
-#endif
-__DEVICE__ int abs(int) __NOEXCEPT;
 __DEVICE__ double abs(double);
 __DEVICE__ float abs(float);
+#endif
+__DEVICE__ int abs(int) __NOEXCEPT;
 __DEVICE__ double acos(double);
 __DEVICE__ float acos(float);
 __DEVICE__ double acosh(double);

Modified: cfe/trunk/test/Headers/Inputs/include/cstdlib
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/Inputs/include/cstdlib?rev=360809&r1=360808&r2=360809&view=diff
==============================================================================
--- cfe/trunk/test/Headers/Inputs/include/cstdlib (original)
+++ cfe/trunk/test/Headers/Inputs/include/cstdlib Wed May 15 13:28:23 2019
@@ -3,9 +3,11 @@
 #if __cplusplus >= 201703L
 extern int abs (int __x) throw()  __attribute__ ((__const__)) ;
 extern long int labs (long int __x) throw() __attribute__ ((__const__)) ;
+extern float fabs (float __x) throw() __attribute__ ((__const__)) ;
 #else
 extern int abs (int __x) __attribute__ ((__const__)) ;
 extern long int labs (long int __x) __attribute__ ((__const__)) ;
+extern float fabs (float __x) __attribute__ ((__const__)) ;
 #endif
 
 namespace std

Modified: cfe/trunk/test/Headers/nvptx_device_cmath_functions.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/nvptx_device_cmath_functions.c?rev=360809&r1=360808&r2=360809&view=diff
==============================================================================
--- cfe/trunk/test/Headers/nvptx_device_cmath_functions.c (original)
+++ cfe/trunk/test/Headers/nvptx_device_cmath_functions.c Wed May 15 13:28:23 2019
@@ -17,5 +17,9 @@ void test_sqrt(double a1) {
     double l2 = pow(a1, a1);
     // CHECK-YES: call double @__nv_modf(double
     double l3 = modf(a1 + 3.5, &a1);
+    // CHECK-YES: call double @__nv_fabs(double
+    double l4 = fabs(a1);
+    // CHECK-YES: call i32 @__nv_abs(i32
+    double l5 = abs((int)a1);
   }
 }

Modified: cfe/trunk/test/Headers/nvptx_device_cmath_functions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/nvptx_device_cmath_functions.cpp?rev=360809&r1=360808&r2=360809&view=diff
==============================================================================
--- cfe/trunk/test/Headers/nvptx_device_cmath_functions.cpp (original)
+++ cfe/trunk/test/Headers/nvptx_device_cmath_functions.cpp Wed May 15 13:28:23 2019
@@ -18,5 +18,9 @@ void test_sqrt(double a1) {
     double l2 = pow(a1, a1);
     // CHECK-YES: call double @__nv_modf(double
     double l3 = modf(a1 + 3.5, &a1);
+    // CHECK-YES: call double @__nv_fabs(double
+    double l4 = fabs(a1);
+    // CHECK-YES: call i32 @__nv_abs(i32
+    double l5 = abs((int)a1);
   }
 }

Modified: cfe/trunk/test/Headers/nvptx_device_cmath_functions_cxx17.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/nvptx_device_cmath_functions_cxx17.cpp?rev=360809&r1=360808&r2=360809&view=diff
==============================================================================
--- cfe/trunk/test/Headers/nvptx_device_cmath_functions_cxx17.cpp (original)
+++ cfe/trunk/test/Headers/nvptx_device_cmath_functions_cxx17.cpp Wed May 15 13:28:23 2019
@@ -18,5 +18,9 @@ void test_sqrt(double a1) {
     double l2 = pow(a1, a1);
     // CHECK-YES: call double @__nv_modf(double
     double l3 = modf(a1 + 3.5, &a1);
+    // CHECK-YES: call double @__nv_fabs(double
+    double l4 = fabs(a1);
+    // CHECK-YES: call i32 @__nv_abs(i32
+    double l5 = abs((int)a1);
   }
 }

Modified: cfe/trunk/test/Headers/nvptx_device_math_functions.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/nvptx_device_math_functions.c?rev=360809&r1=360808&r2=360809&view=diff
==============================================================================
--- cfe/trunk/test/Headers/nvptx_device_math_functions.c (original)
+++ cfe/trunk/test/Headers/nvptx_device_math_functions.c Wed May 15 13:28:23 2019
@@ -17,5 +17,9 @@ void test_sqrt(double a1) {
     double l2 = pow(a1, a1);
     // CHECK-YES: call double @__nv_modf(double
     double l3 = modf(a1 + 3.5, &a1);
+    // CHECK-YES: call double @__nv_fabs(double
+    double l4 = fabs(a1);
+    // CHECK-YES: call i32 @__nv_abs(i32
+    double l5 = abs((int)a1);
   }
 }

Modified: cfe/trunk/test/Headers/nvptx_device_math_functions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/nvptx_device_math_functions.cpp?rev=360809&r1=360808&r2=360809&view=diff
==============================================================================
--- cfe/trunk/test/Headers/nvptx_device_math_functions.cpp (original)
+++ cfe/trunk/test/Headers/nvptx_device_math_functions.cpp Wed May 15 13:28:23 2019
@@ -18,5 +18,9 @@ void test_sqrt(double a1) {
     double l2 = pow(a1, a1);
     // CHECK-YES: call double @__nv_modf(double
     double l3 = modf(a1 + 3.5, &a1);
+    // CHECK-YES: call double @__nv_fabs(double
+    double l4 = fabs(a1);
+    // CHECK-YES: call i32 @__nv_abs(i32
+    double l5 = abs((int)a1);
   }
 }

Modified: cfe/trunk/test/Headers/nvptx_device_math_functions_cxx17.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/nvptx_device_math_functions_cxx17.cpp?rev=360809&r1=360808&r2=360809&view=diff
==============================================================================
--- cfe/trunk/test/Headers/nvptx_device_math_functions_cxx17.cpp (original)
+++ cfe/trunk/test/Headers/nvptx_device_math_functions_cxx17.cpp Wed May 15 13:28:23 2019
@@ -18,5 +18,9 @@ void test_sqrt(double a1) {
     double l2 = pow(a1, a1);
     // CHECK-YES: call double @__nv_modf(double
     double l3 = modf(a1 + 3.5, &a1);
+    // CHECK-YES: call double @__nv_fabs(double
+    double l4 = fabs(a1);
+    // CHECK-YES: call i32 @__nv_abs(i32
+    double l5 = abs((int)a1);
   }
 }




More information about the cfe-commits mailing list