[OpenMP] Make complex soft-float functions on the GPU weak definitions
authorJohannes Doerfert <johannes@jdoerfert.de>
Thu, 9 Jul 2020 06:04:16 +0000 (01:04 -0500)
committerJohannes Doerfert <johannes@jdoerfert.de>
Thu, 9 Jul 2020 06:06:55 +0000 (01:06 -0500)
To avoid linkage errors we have to ensure the linkage allows multiple
definitions of these compiler inserted functions. Since they are on the
cold path of complex computations, we want to avoid `inline`. Instead,
we opt for `weak` and `noinline` for now.

clang/lib/Headers/__clang_cuda_complex_builtins.h
clang/test/Headers/nvptx_device_math_complex.c
clang/test/Headers/nvptx_device_math_complex.cpp

index d698be7..c48c754 100644 (file)
@@ -18,7 +18,7 @@
 #pragma push_macro("__DEVICE__")
 #ifdef _OPENMP
 #pragma omp declare target
-#define __DEVICE__ __attribute__((noinline, nothrow, cold))
+#define __DEVICE__ __attribute__((noinline, nothrow, cold, weak))
 #else
 #define __DEVICE__ __device__ inline
 #endif
index 9b96b5d..0e21259 100644 (file)
 #include <complex.h>
 #endif
 
-// CHECK-DAG: define {{.*}} @__mulsc3
-// CHECK-DAG: define {{.*}} @__muldc3
-// CHECK-DAG: define {{.*}} @__divsc3
-// CHECK-DAG: define {{.*}} @__divdc3
+// CHECK-DAG: define weak {{.*}} @__mulsc3
+// CHECK-DAG: define weak {{.*}} @__muldc3
+// CHECK-DAG: define weak {{.*}} @__divsc3
+// CHECK-DAG: define weak {{.*}} @__divdc3
 
 // CHECK-DAG: call float @__nv_scalbnf(
 void test_scmplx(float _Complex a) {
index 15434d9..58ed24b 100644 (file)
@@ -5,10 +5,10 @@
 
 #include <complex>
 
-// CHECK-DAG: define {{.*}} @__mulsc3
-// CHECK-DAG: define {{.*}} @__muldc3
-// CHECK-DAG: define {{.*}} @__divsc3
-// CHECK-DAG: define {{.*}} @__divdc3
+// CHECK-DAG: define weak {{.*}} @__mulsc3
+// CHECK-DAG: define weak {{.*}} @__muldc3
+// CHECK-DAG: define weak {{.*}} @__divsc3
+// CHECK-DAG: define weak {{.*}} @__divdc3
 
 // CHECK-DAG: call float @__nv_scalbnf(
 void test_scmplx(std::complex<float> a) {