[libc-commits] [libc] [libc] Only perform MSAN unpoison in non-constexpr context. (PR #72299)
via libc-commits
libc-commits at lists.llvm.org
Tue Nov 14 10:54:36 PST 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: None (lntue)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/72299.diff
1 Files Affected:
- (modified) libc/src/__support/macros/sanitizer.h (+9-2)
``````````diff
diff --git a/libc/src/__support/macros/sanitizer.h b/libc/src/__support/macros/sanitizer.h
index 6989672b4839d20..fc66c2005c42de7 100644
--- a/libc/src/__support/macros/sanitizer.h
+++ b/libc/src/__support/macros/sanitizer.h
@@ -47,9 +47,16 @@
// Functions to unpoison memory
//-----------------------------------------------------------------------------
-#ifdef LIBC_HAVE_MEMORY_SANITIZER
+#if defined(LIBC_HAVE_MEMORY_SANITIZER) && \
+ LIBC_HAS_BUILTIN(__builtin_constant_p)
+// Only perform MSAN unpoison in non-constexpr context.
#include <sanitizer/msan_interface.h>
-#define MSAN_UNPOISON(addr, size) __msan_unpoison(addr, size)
+#define MSAN_UNPOISON(addr, size) \
+ do { \
+ if (!__builtin_constant_p(*addr)) { \
+ __msan_unpoison(addr, size); \
+ } \
+ } while (0)
#else
#define MSAN_UNPOISON(ptr, size)
#endif
``````````
</details>
https://github.com/llvm/llvm-project/pull/72299
More information about the libc-commits
mailing list