[PATCH] D61959: [OpenMP][Bugfix] Move double and float versions of abs under c++ macro

2019-05-15 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC360809: [OpenMP][Bugfix] Move double and float versions of 
abs under c++ macro (authored by gbercea, committed by ).

Repository:
  rC Clang

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

https://reviews.llvm.org/D61959

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

Index: test/Headers/nvptx_device_cmath_functions.c
===
--- test/Headers/nvptx_device_cmath_functions.c
+++ test/Headers/nvptx_device_cmath_functions.c
@@ -17,5 +17,9 @@
 double l2 = pow(a1, a1);
 // CHECK-YES: call double @__nv_modf(double
 double l3 = modf(a1 + 3.5, );
+// CHECK-YES: call double @__nv_fabs(double
+double l4 = fabs(a1);
+// CHECK-YES: call i32 @__nv_abs(i32
+double l5 = abs((int)a1);
   }
 }
Index: test/Headers/Inputs/include/cstdlib
===
--- test/Headers/Inputs/include/cstdlib
+++ test/Headers/Inputs/include/cstdlib
@@ -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
Index: test/Headers/nvptx_device_math_functions.c
===
--- test/Headers/nvptx_device_math_functions.c
+++ test/Headers/nvptx_device_math_functions.c
@@ -17,5 +17,9 @@
 double l2 = pow(a1, a1);
 // CHECK-YES: call double @__nv_modf(double
 double l3 = modf(a1 + 3.5, );
+// CHECK-YES: call double @__nv_fabs(double
+double l4 = fabs(a1);
+// CHECK-YES: call i32 @__nv_abs(i32
+double l5 = abs((int)a1);
   }
 }
Index: test/Headers/nvptx_device_cmath_functions_cxx17.cpp
===
--- test/Headers/nvptx_device_cmath_functions_cxx17.cpp
+++ test/Headers/nvptx_device_cmath_functions_cxx17.cpp
@@ -18,5 +18,9 @@
 double l2 = pow(a1, a1);
 // CHECK-YES: call double @__nv_modf(double
 double l3 = modf(a1 + 3.5, );
+// CHECK-YES: call double @__nv_fabs(double
+double l4 = fabs(a1);
+// CHECK-YES: call i32 @__nv_abs(i32
+double l5 = abs((int)a1);
   }
 }
Index: test/Headers/nvptx_device_math_functions_cxx17.cpp
===
--- test/Headers/nvptx_device_math_functions_cxx17.cpp
+++ test/Headers/nvptx_device_math_functions_cxx17.cpp
@@ -18,5 +18,9 @@
 double l2 = pow(a1, a1);
 // CHECK-YES: call double @__nv_modf(double
 double l3 = modf(a1 + 3.5, );
+// CHECK-YES: call double @__nv_fabs(double
+double l4 = fabs(a1);
+// CHECK-YES: call i32 @__nv_abs(i32
+double l5 = abs((int)a1);
   }
 }
Index: test/Headers/nvptx_device_cmath_functions.cpp
===
--- test/Headers/nvptx_device_cmath_functions.cpp
+++ test/Headers/nvptx_device_cmath_functions.cpp
@@ -18,5 +18,9 @@
 double l2 = pow(a1, a1);
 // CHECK-YES: call double @__nv_modf(double
 double l3 = modf(a1 + 3.5, );
+// CHECK-YES: call double @__nv_fabs(double
+double l4 = fabs(a1);
+// CHECK-YES: call i32 @__nv_abs(i32
+double l5 = abs((int)a1);
   }
 }
Index: test/Headers/nvptx_device_math_functions.cpp
===
--- test/Headers/nvptx_device_math_functions.cpp
+++ test/Headers/nvptx_device_math_functions.cpp
@@ -18,5 +18,9 @@
 double l2 = pow(a1, a1);
 // CHECK-YES: call double @__nv_modf(double
 double l3 = modf(a1 + 3.5, );
+// CHECK-YES: call double @__nv_fabs(double
+double l4 = fabs(a1);
+// CHECK-YES: call i32 @__nv_abs(i32
+double l5 = abs((int)a1);
   }
 }
Index: lib/Headers/__clang_cuda_cmath.h
===
--- lib/Headers/__clang_cuda_cmath.h
+++ lib/Headers/__clang_cuda_cmath.h
@@ -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

[PATCH] D61959: [OpenMP][Bugfix] Move double and float versions of abs under c++ macro

2019-05-15 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea created this revision.
gtbercea added reviewers: tra, jdoerfert, hfinkel, ABataev, caomhin.
Herald added subscribers: cfe-commits, guansong.
Herald added a project: clang.

This is a fix for the reported bug:

41861 

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


Repository:
  rC Clang

https://reviews.llvm.org/D61959

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

Index: test/Headers/nvptx_device_math_functions_cxx17.cpp
===
--- test/Headers/nvptx_device_math_functions_cxx17.cpp
+++ test/Headers/nvptx_device_math_functions_cxx17.cpp
@@ -18,5 +18,9 @@
 double l2 = pow(a1, a1);
 // CHECK-YES: call double @__nv_modf(double
 double l3 = modf(a1 + 3.5, );
+// CHECK-YES: call double @__nv_fabs(double
+double l4 = fabs(a1);
+// CHECK-YES: call i32 @__nv_abs(i32
+double l5 = abs((int)a1);
   }
 }
Index: test/Headers/nvptx_device_math_functions.cpp
===
--- test/Headers/nvptx_device_math_functions.cpp
+++ test/Headers/nvptx_device_math_functions.cpp
@@ -18,5 +18,9 @@
 double l2 = pow(a1, a1);
 // CHECK-YES: call double @__nv_modf(double
 double l3 = modf(a1 + 3.5, );
+// CHECK-YES: call double @__nv_fabs(double
+double l4 = fabs(a1);
+// CHECK-YES: call i32 @__nv_abs(i32
+double l5 = abs((int)a1);
   }
 }
Index: test/Headers/nvptx_device_math_functions.c
===
--- test/Headers/nvptx_device_math_functions.c
+++ test/Headers/nvptx_device_math_functions.c
@@ -17,5 +17,9 @@
 double l2 = pow(a1, a1);
 // CHECK-YES: call double @__nv_modf(double
 double l3 = modf(a1 + 3.5, );
+// CHECK-YES: call double @__nv_fabs(double
+double l4 = fabs(a1);
+// CHECK-YES: call i32 @__nv_abs(i32
+double l5 = abs((int)a1);
   }
 }
Index: test/Headers/nvptx_device_cmath_functions_cxx17.cpp
===
--- test/Headers/nvptx_device_cmath_functions_cxx17.cpp
+++ test/Headers/nvptx_device_cmath_functions_cxx17.cpp
@@ -18,5 +18,9 @@
 double l2 = pow(a1, a1);
 // CHECK-YES: call double @__nv_modf(double
 double l3 = modf(a1 + 3.5, );
+// CHECK-YES: call double @__nv_fabs(double
+double l4 = fabs(a1);
+// CHECK-YES: call i32 @__nv_abs(i32
+double l5 = abs((int)a1);
   }
 }
Index: test/Headers/nvptx_device_cmath_functions.cpp
===
--- test/Headers/nvptx_device_cmath_functions.cpp
+++ test/Headers/nvptx_device_cmath_functions.cpp
@@ -18,5 +18,9 @@
 double l2 = pow(a1, a1);
 // CHECK-YES: call double @__nv_modf(double
 double l3 = modf(a1 + 3.5, );
+// CHECK-YES: call double @__nv_fabs(double
+double l4 = fabs(a1);
+// CHECK-YES: call i32 @__nv_abs(i32
+double l5 = abs((int)a1);
   }
 }
Index: test/Headers/nvptx_device_cmath_functions.c
===
--- test/Headers/nvptx_device_cmath_functions.c
+++ test/Headers/nvptx_device_cmath_functions.c
@@ -17,5 +17,9 @@
 double l2 = pow(a1, a1);
 // CHECK-YES: call double @__nv_modf(double
 double l3 = modf(a1 + 3.5, );
+// CHECK-YES: call double @__nv_fabs(double
+double l4 = fabs(a1);
+// CHECK-YES: call i32 @__nv_abs(i32
+double l5 = abs((int)a1);
   }
 }
Index: test/Headers/Inputs/include/cstdlib
===
--- test/Headers/Inputs/include/cstdlib
+++ test/Headers/Inputs/include/cstdlib
@@ -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
Index: lib/Headers/__clang_cuda_math_forward_declares.h
===
--- lib/Headers/__clang_cuda_math_forward_declares.h
+++ lib/Headers/__clang_cuda_math_forward_declares.h
@@ -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;