From 4c684b91d562d96ab5a34bb989693e92ba9ec9eb Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Mon, 11 May 2020 22:08:07 -0700 Subject: [PATCH] Revert part of D49132 "[gcov] Fix gcov profiling on big-endian machines" D49132 is partially correct. For 64-bit values, the lower 32-bit part comes before the higher 32-bit part (in a little-endian manner). For 32-bit values, libgcov reads/writes 32-bit values in native endianness. --- compiler-rt/lib/profile/GCDAProfiling.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/compiler-rt/lib/profile/GCDAProfiling.c b/compiler-rt/lib/profile/GCDAProfiling.c index fe39ce9..eb23a06 100644 --- a/compiler-rt/lib/profile/GCDAProfiling.c +++ b/compiler-rt/lib/profile/GCDAProfiling.c @@ -235,18 +235,6 @@ static uint32_t read_32bit_value() { return val; } -static uint32_t read_le_32bit_value() { - uint32_t val = 0; - int i; - - if (new_file) - return (uint32_t)-1; - - for (i = 0; i < 4; i++) - val |= write_buffer[cur_pos++] << (8*i); - return val; -} - static uint64_t read_64bit_value() { // GCOV uses a lo-/hi-word format even on big-endian systems. // See also GCOVBuffer::readInt64 in LLVM. @@ -501,7 +489,7 @@ void llvm_gcda_emit_arcs(uint32_t num_counters, uint64_t *counters) { if (!output_file) return; - val = read_le_32bit_value(); + val = read_32bit_value(); if (val != (uint32_t)-1) { /* There are counters present in the file. Merge them. */ @@ -553,7 +541,7 @@ void llvm_gcda_summary_info() { if (!output_file) return; - val = read_le_32bit_value(); + val = read_32bit_value(); if (val != (uint32_t)-1) { /* There are counters present in the file. Merge them. */ -- 2.7.4