Skip to content

Commit 20dd931

Browse files
akuegeltensorflower-gardener
authored andcommitted
Apply patch to fix compile error on windows (NFC).
PiperOrigin-RevId: 782820048
1 parent 3c068b7 commit 20dd931

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
diff --git a/llvm/include/llvm/ADT/Hashing.h b/llvm/include/llvm/ADT/Hashing.h
2+
index 0093c281aac8..ad131015a7d9 100644
3+
--- a/llvm/include/llvm/ADT/Hashing.h
4+
+++ b/llvm/include/llvm/ADT/Hashing.h
5+
@@ -136,7 +136,7 @@ namespace detail {
6+
7+
inline uint64_t fetch64(const char *p) {
8+
uint64_t result;
9+
- memcpy(&result, p, sizeof(result));
10+
+ std::memcpy(&result, p, sizeof(result));
11+
if (sys::IsBigEndianHost)
12+
sys::swapByteOrder(result);
13+
return result;
14+
@@ -144,7 +144,7 @@ inline uint64_t fetch64(const char *p) {
15+
16+
inline uint32_t fetch32(const char *p) {
17+
uint32_t result;
18+
- memcpy(&result, p, sizeof(result));
19+
+ std::memcpy(&result, p, sizeof(result));
20+
if (sys::IsBigEndianHost)
21+
sys::swapByteOrder(result);
22+
return result;
23+
@@ -379,7 +379,7 @@ bool store_and_advance(char *&buffer_ptr, char *buffer_end, const T& value,
24+
if (buffer_ptr + store_size > buffer_end)
25+
return false;
26+
const char *value_data = reinterpret_cast<const char *>(&value);
27+
- memcpy(buffer_ptr, value_data + offset, store_size);
28+
+ std::memcpy(buffer_ptr, value_data + offset, store_size);
29+
buffer_ptr += store_size;
30+
return true;
31+
}
32+
@@ -513,7 +513,7 @@ public:
33+
// with the variadic combine because that formation can have varying
34+
// argument types.
35+
size_t partial_store_size = buffer_end - buffer_ptr;
36+
- memcpy(buffer_ptr, &data, partial_store_size);
37+
+ std::memcpy(buffer_ptr, &data, partial_store_size);
38+
39+
// If the store fails, our buffer is full and ready to hash. We have to
40+
// either initialize the hash state (on the first full buffer) or mix
41+
diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h
42+
index 0b8bb48b8fe5..80f7734b8690 100644
43+
--- a/llvm/include/llvm/ADT/SmallVector.h
44+
+++ b/llvm/include/llvm/ADT/SmallVector.h
45+
@@ -518,7 +518,7 @@ protected:
46+
// use memcpy here. Note that I and E are iterators and thus might be
47+
// invalid for memcpy if they are equal.
48+
if (I != E)
49+
- memcpy(reinterpret_cast<void *>(Dest), I, (E - I) * sizeof(T));
50+
+ std::memcpy(reinterpret_cast<void *>(Dest), I, (E - I) * sizeof(T));
51+
}
52+
53+
/// Double the size of the allocated memory, guaranteeing space for at
54+
@@ -561,7 +561,7 @@ protected:
55+
public:
56+
void push_back(ValueParamT Elt) {
57+
const T *EltPtr = reserveForParamAndGetAddress(Elt);
58+
- memcpy(reinterpret_cast<void *>(this->end()), EltPtr, sizeof(T));
59+
+ std::memcpy(reinterpret_cast<void *>(this->end()), EltPtr, sizeof(T));
60+
this->set_size(this->size() + 1);
61+
}
62+

third_party/xla/third_party/llvm/workspace.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def repo(name):
2020
"//third_party/llvm:generated.patch", # Autogenerated, don't remove.
2121
"//third_party/llvm:build.patch",
2222
"//third_party/llvm:mathextras.patch",
23+
"//third_party/llvm:memcpy.patch",
2324
"//third_party/llvm:toolchains.patch",
2425
"//third_party/llvm:zstd.patch",
2526
],

0 commit comments

Comments
 (0)