-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[ASan][HIP] Add ASan declarations and macros. #167522
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@llvm/pr-subscribers-clang @llvm/pr-subscribers-backend-x86 Author: Amit Kumar Pandey (ampandey-1995) Changes__clang_hip_libdevice_declares.h Add device declarations for the following AddressSanitizer hooks:
Full diff: https://github.com/llvm/llvm-project/pull/167522.diff 1 Files Affected:
diff --git a/clang/lib/Headers/__clang_hip_libdevice_declares.h b/clang/lib/Headers/__clang_hip_libdevice_declares.h
index fa8d918248dd0..cf4b9d486b903 100644
--- a/clang/lib/Headers/__clang_hip_libdevice_declares.h
+++ b/clang/lib/Headers/__clang_hip_libdevice_declares.h
@@ -338,6 +338,21 @@ __device__ __attribute__((const)) __2f16 __ocml_sqrt_2f16(__2f16);
__device__ __attribute__((const)) __2f16 __ocml_trunc_2f16(__2f16);
__device__ __attribute__((const)) __2f16 __ocml_pown_2f16(__2f16, __2i16);
+__device__ void __asan_poison_memory_region(const void *addr, size_t size);
+__device__ void __asan_unpoison_memory_region(const void *addr, size_t size);
+__device__ int __asan_address_is_poisoned(const void *addr);
+__device__ void *__asan_region_is_poisoned(void *beg, size_t size);
+
+#if __has_feature(address_sanitizer)
+#define ASAN_POISON_MEMORY_REGION(addr, size) \
+ __asan_poison_memory_region((addr), (size))
+#define ASAN_UNPOISON_MEMORY_REGION(addr, size) \
+ __asan_unpoison_memory_region((addr), (size))
+#else
+#define ASAN_POISON_MEMORY_REGION(addr, size) ((void)(addr), (void)(size))
+#define ASAN_UNPOISON_MEMORY_REGION(addr, size) ((void)(addr), (void)(size))
+#endif
+
#ifdef __cplusplus
} // extern "C"
#endif
|
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
df51a60 to
a836959
Compare
This patch adds the following device ASan hooks and guarded macros in
__clang_hip_libdevice_declares.h
- Function Declarations
- __asan_poison_memory_region
- __asan_unpoison_memory_region
- __asan_address_is_poisoned
- __asan_region_is_poisoned
- Macros
- ASAN_POISON_MEMORY_REGION
- ASAN_UNPOISON_MEMORY_REGION
a836959 to
fad918f
Compare
Switch from 'size_t' to '__SIZE_TYPE__'
644fb07 to
5d7b6ad
Compare
b-sumner
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks good. @yxsamliu do you have any concerns about it?
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/190/builds/31126 Here is the relevant piece of the build log for the reference |
This patch adds the following device ASan hooks and guarded macros in
__clang_hip_libdevice_declares.h
Function Declarations
Macros