[clang] 9ce931b - [HIP] Fix no matching constructor for init of shared_ptr and malloc
Aaron En Ye Shi via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 22 07:33:52 PDT 2021
Author: Aaron En Ye Shi
Date: 2021-07-22T14:32:41Z
New Revision: 9ce931bd71855ced2146f77120df07e4bf381cec
URL: https://github.com/llvm/llvm-project/commit/9ce931bd71855ced2146f77120df07e4bf381cec
DIFF: https://github.com/llvm/llvm-project/commit/9ce931bd71855ced2146f77120df07e4bf381cec.diff
LOG: [HIP] Fix no matching constructor for init of shared_ptr and malloc
Allow standard header versions of malloc and free to be defined
before introducing the device versions.
Fixes: SWDEV-295901
Reviewed By: yaxunl
Differential Revision: https://reviews.llvm.org/D106463
Added:
Modified:
clang/lib/Headers/__clang_hip_runtime_wrapper.h
Removed:
################################################################################
diff --git a/clang/lib/Headers/__clang_hip_runtime_wrapper.h b/clang/lib/Headers/__clang_hip_runtime_wrapper.h
index 59d5cfef2df8..73021d256cba 100644
--- a/clang/lib/Headers/__clang_hip_runtime_wrapper.h
+++ b/clang/lib/Headers/__clang_hip_runtime_wrapper.h
@@ -46,6 +46,28 @@ extern "C" {
}
#endif //__cplusplus
+#if !defined(__HIPCC_RTC__)
+#include <cmath>
+#include <cstdlib>
+#include <stdlib.h>
+#else
+typedef __SIZE_TYPE__ size_t;
+// Define macros which are needed to declare HIP device API's without standard
+// C/C++ headers. This is for readability so that these API's can be written
+// the same way as non-hipRTC use case. These macros need to be popped so that
+// they do not pollute users' name space.
+#pragma push_macro("NULL")
+#pragma push_macro("uint32_t")
+#pragma push_macro("uint64_t")
+#pragma push_macro("CHAR_BIT")
+#pragma push_macro("INT_MAX")
+#define NULL (void *)0
+#define uint32_t __UINT32_TYPE__
+#define uint64_t __UINT64_TYPE__
+#define CHAR_BIT __CHAR_BIT__
+#define INT_MAX __INTMAX_MAX__
+#endif // __HIPCC_RTC__
+
typedef __SIZE_TYPE__ __hip_size_t;
#ifdef __cplusplus
@@ -64,11 +86,11 @@ __attribute__((weak)) inline __device__ void *free(void *__ptr) {
#else
__attribute__((weak)) inline __device__ void *malloc(__hip_size_t __size) {
__builtin_trap();
- return nullptr;
+ return (void *)0;
}
__attribute__((weak)) inline __device__ void *free(void *__ptr) {
__builtin_trap();
- return nullptr;
+ return (void *)0;
}
#endif
@@ -76,28 +98,6 @@ __attribute__((weak)) inline __device__ void *free(void *__ptr) {
} // extern "C"
#endif //__cplusplus
-#if !defined(__HIPCC_RTC__)
-#include <cmath>
-#include <cstdlib>
-#include <stdlib.h>
-#else
-typedef __SIZE_TYPE__ size_t;
-// Define macros which are needed to declare HIP device API's without standard
-// C/C++ headers. This is for readability so that these API's can be written
-// the same way as non-hipRTC use case. These macros need to be popped so that
-// they do not pollute users' name space.
-#pragma push_macro("NULL")
-#pragma push_macro("uint32_t")
-#pragma push_macro("uint64_t")
-#pragma push_macro("CHAR_BIT")
-#pragma push_macro("INT_MAX")
-#define NULL (void *)0
-#define uint32_t __UINT32_TYPE__
-#define uint64_t __UINT64_TYPE__
-#define CHAR_BIT __CHAR_BIT__
-#define INT_MAX __INTMAX_MAX__
-#endif // __HIPCC_RTC__
-
#include <__clang_hip_libdevice_declares.h>
#include <__clang_hip_math.h>
More information about the cfe-commits
mailing list