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 */


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 */
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to