@@ -38,7 +38,17 @@ llvm::cl::opt<bool, false, opts::FlagParser<bool>> enablePGOIndirectCalls(
3838 " pgo-indirect-calls" , llvm::cl::ZeroOrMore, llvm::cl::Hidden,
3939 llvm::cl::desc (" (*) Enable PGO of indirect calls" ),
4040 llvm::cl::init(true ));
41+
42+ uint64_t inLittleEndian (uint64_t x) {
43+ #if LDC_LLVM_VER >= 2200
44+ return llvm::support::endian::byte_swap<uint64_t >(x,
45+ llvm::endianness::little);
46+ #else
47+ return llvm::support::endian::byte_swap<uint64_t , llvm::endianness::little>(
48+ x);
49+ #endif
4150}
51+ } // anonymous namespace
4252
4353// / \brief Stable hasher for PGO region counters.
4454// /
@@ -115,9 +125,7 @@ class PGOHash {
115125
116126 // Pass through MD5 if enough work has built up.
117127 if (Count && Count % NumTypesPerWord == 0 ) {
118- uint64_t Swapped =
119- llvm::support::endian::byte_swap<uint64_t , llvm::endianness::little>(
120- Working);
128+ uint64_t Swapped = inLittleEndian (Working);
121129 MD5.update (llvm::ArrayRef<uint8_t >((uint8_t *)&Swapped, sizeof (Swapped)));
122130 Working = 0 ;
123131 }
@@ -137,9 +145,7 @@ class PGOHash {
137145
138146 // Check for remaining work in Working.
139147 if (Working) {
140- uint64_t Swapped =
141- llvm::support::endian::byte_swap<uint64_t , llvm::endianness::little>(
142- Working);
148+ uint64_t Swapped = inLittleEndian (Working);
143149 MD5.update (llvm::ArrayRef<uint8_t >((uint8_t *)&Swapped, sizeof (Swapped)));
144150 }
145151
0 commit comments