[flang-commits] [flang] [llvm] [Flang][OpenMP][Runtime] Minor Flang runtime for OpenMP AMDGPU (PR #152631)
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Tue Aug 19 07:38:31 PDT 2025
================
@@ -79,7 +98,52 @@ fill_n(A *start, std::size_t count, const B &value) {
using std::fill_n;
#endif // !STD_FILL_N_UNSUPPORTED
-#if STD_MEMMOVE_UNSUPPORTED
+#if STD_MEMSET_USE_BUILTIN
+static inline RT_API_ATTRS void memset(
+ void *dest, unsigned char value, std::size_t count) {
+ __builtin_memset(dest, value, count);
+}
+#elif STD_MEMSET_UNSUPPORTED
+static inline RT_API_ATTRS void memset(
+ void *dest, unsigned char value, std::size_t count) {
+ char *to{reinterpret_cast<char *>(dest)};
+ while (count--) {
+ *to++ = value;
+ }
+ return;
+}
+#else
+using std::memset;
+#endif
+
+#if STD_MEMCPY_USE_BUILTIN
+static inline RT_API_ATTRS void memcpy(
+ void *dest, const void *src, std::size_t count) {
+ __builtin_memcpy(dest, src, count);
+}
+#elif STD_MEMCPY_UNSUPPORTED
+static inline RT_API_ATTRS void memcpy(
+ void *dest, const void *src, std::size_t count) {
+ char *to{reinterpret_cast<char *>(dest)};
+ const char *from{reinterpret_cast<const char *>(src)};
+ if (to == from) {
+ return;
+ }
+ while (count--) {
+ *to++ = *from++;
+ }
+ return;
----------------
klausler wrote:
You don't need a `return;` statement before the closing brace of a function.
https://github.com/llvm/llvm-project/pull/152631
More information about the flang-commits
mailing list