[llvm] f035c01 - InstrProf::getFunctionBitmap: Fix BE hosts (#80608)

NAKAMURA Takumi via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 4 22:05:33 PST 2024


Author: NAKAMURA Takumi
Date: 2024-02-05T15:04:57+09:00
New Revision: f035c018a6a581c38680651d4856631d9c6ccb0a

URL: https://github.com/llvm/llvm-project/commit/f035c018a6a581c38680651d4856631d9c6ccb0a
DIFF: https://github.com/llvm/llvm-project/commit/f035c018a6a581c38680651d4856631d9c6ccb0a.diff

LOG: InstrProf::getFunctionBitmap: Fix BE hosts (#80608)

Added: 
    

Modified: 
    llvm/lib/ProfileData/InstrProfReader.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/ProfileData/InstrProfReader.cpp b/llvm/lib/ProfileData/InstrProfReader.cpp
index 773bfe520b8db..0d8d43daae960 100644
--- a/llvm/lib/ProfileData/InstrProfReader.cpp
+++ b/llvm/lib/ProfileData/InstrProfReader.cpp
@@ -1446,12 +1446,15 @@ Error IndexedInstrProfReader::getFunctionBitmap(StringRef FuncName,
   size_t I = 0, E = BitmapBytes.size();
   Bitmap.resize(E * CHAR_BIT);
   BitVector::apply(
-      [&](auto x) {
-        decltype(x) W = 0;
+      [&](auto X) {
+        using XTy = decltype(X);
+        alignas(XTy) uint8_t W[sizeof(X)];
         size_t N = std::min(E - I, sizeof(W));
-        std::memcpy((void *)&W, &BitmapBytes[I], N);
+        std::memset(W, 0, sizeof(W));
+        std::memcpy(W, &BitmapBytes[I], N);
         I += N;
-        return W;
+        return support::endian::read<XTy, llvm::endianness::little,
+                                     support::aligned>(W);
       },
       Bitmap, Bitmap);
   assert(I == E);


        


More information about the llvm-commits mailing list