[PATCH] D106790: prfchwintrin.h: Make _m_prefetchw take a pointer to volatile (PR49124)

Hans Wennborg via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 26 06:15:35 PDT 2021


hans created this revision.
hans added reviewers: thakis, rnk.
hans requested review of this revision.
Herald added a project: clang.

For some reason, Microsoft declares _m_prefetch to take a const void*, but _m_prefetchw to take a /volatile/ const void*.

I can't think of any downside to just casting away the volatile here? (Besides having to suppress the warning in a somewhat ugly way.)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106790

Files:
  clang/lib/Headers/prfchwintrin.h


Index: clang/lib/Headers/prfchwintrin.h
===================================================================
--- clang/lib/Headers/prfchwintrin.h
+++ clang/lib/Headers/prfchwintrin.h
@@ -47,9 +47,12 @@
 /// \param __P
 ///    A pointer specifying the memory address to be prefetched.
 static __inline__ void __attribute__((__always_inline__, __nodebug__))
-_m_prefetchw(void *__P)
+_m_prefetchw(volatile const void *__P)
 {
-  __builtin_prefetch (__P, 1, 3 /* _MM_HINT_T0 */);
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wcast-qual"
+  __builtin_prefetch ((const void*)__P, 1, 3 /* _MM_HINT_T0 */);
+#pragma clang diagnostic pop
 }
 
 #endif /* __PRFCHWINTRIN_H */


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106790.361636.patch
Type: text/x-patch
Size: 687 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210726/12f7fc31/attachment.bin>


More information about the cfe-commits mailing list