[libFuzzer] Fix endianness issue in ForEachNonZeroByte()

The usage pattern of Bundle variable assumes the machine is little
endian, which is not the case on SystemZ. Fix by converting Bundle to
little-endian when necessary.

GitOrigin-RevId: a4e537d9c47aa378a24636e2d90d208389ad93ab
diff --git a/FuzzerTracePC.h b/FuzzerTracePC.h
index 501f3b5..4601300 100644
--- a/FuzzerTracePC.h
+++ b/FuzzerTracePC.h
@@ -194,10 +194,12 @@
 
   // Iterate by Step bytes at a time.
   for (; P < End; P += Step)
-    if (LargeType Bundle = *reinterpret_cast<const LargeType *>(P))
+    if (LargeType Bundle = *reinterpret_cast<const LargeType *>(P)) {
+      Bundle = HostToLE(Bundle);
       for (size_t I = 0; I < Step; I++, Bundle >>= 8)
         if (uint8_t V = Bundle & 0xff)
           Handle8bitCounter(FirstFeature, P - Begin + I, V);
+    }
 
   // Iterate by 1 byte until the end.
   for (; P < End; P++)
diff --git a/FuzzerUtil.h b/FuzzerUtil.h
index 4ae3583..e90be08 100644
--- a/FuzzerUtil.h
+++ b/FuzzerUtil.h
@@ -106,6 +106,12 @@
   return reinterpret_cast<uint8_t *>(X);
 }
 
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+template <typename T> T HostToLE(T X) { return X; }
+#else
+template <typename T> T HostToLE(T X) { return Bswap(X); }
+#endif
+
 }  // namespace fuzzer
 
 #endif  // LLVM_FUZZER_UTIL_H