[llvm] r286066 - [BitcodeWriter] Replace a manual byteswap with read32be.

Benjamin Kramer via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 6 05:26:42 PST 2016


Author: d0k
Date: Sun Nov  6 07:26:39 2016
New Revision: 286066

URL: http://llvm.org/viewvc/llvm-project?rev=286066&view=rev
Log:
[BitcodeWriter] Replace a manual byteswap with read32be.

No functional change intended.

Modified:
    llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp

Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=286066&r1=286065&r2=286066&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original)
+++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Sun Nov  6 07:26:39 2016
@@ -3630,15 +3630,10 @@ void ModuleBitcodeWriter::writeModuleHas
   SHA1 Hasher;
   Hasher.update(ArrayRef<uint8_t>((const uint8_t *)&(Buffer)[BlockStartPos],
                                   Buffer.size() - BlockStartPos));
-  auto Hash = Hasher.result();
-  SmallVector<uint64_t, 20> Vals;
-  auto LShift = [&](unsigned char Val, unsigned Amount)
-                    -> uint64_t { return ((uint64_t)Val) << Amount; };
+  StringRef Hash = Hasher.result();
+  uint32_t Vals[5];
   for (int Pos = 0; Pos < 20; Pos += 4) {
-    uint32_t SubHash = LShift(Hash[Pos + 0], 24);
-    SubHash |= LShift(Hash[Pos + 1], 16) | LShift(Hash[Pos + 2], 8) |
-               (unsigned)(unsigned char)Hash[Pos + 3];
-    Vals.push_back(SubHash);
+    Vals[Pos / 4] = support::endian::read32be(Hash.data() + Pos);
   }
 
   // Emit the finished record.




More information about the llvm-commits mailing list