[gcov] Fix gcov profiling on big-endian machines
authorUlrich Weigand <ulrich.weigand@de.ibm.com>
Tue, 10 Jul 2018 16:08:27 +0000 (16:08 +0000)
committerUlrich Weigand <ulrich.weigand@de.ibm.com>
Tue, 10 Jul 2018 16:08:27 +0000 (16:08 +0000)
commite508cd2a04ffc26cdd3bf78ca9a5701f0a4921f3
tree1cfd0db6b0a5bb03cba822a60f526727f18219ed
parentb961fdc509c45a24aec122ff1a05e0e5076c0987
[gcov] Fix gcov profiling on big-endian machines

Two fixes required to handle big-endian systems:

- 64-bit counter values are stored in a mixed-endian format in the
gcov files: a 32-bit low-part followed by a 32-bit high part. Note that
this is already implemented correctly on the LLVM side, see
GCOVBuffer::readInt64.

- The tag values (e.g. arcs tag, object summary tag, ...) are aways
written as the same sequence of bytes independent of byte order. But
when *reading* them back in, the code reads them as 32-bit values in
host byte order. For the comparisons to work correctly, this should
instead always read them as little-endian values.

Fixes PR 38121.

Reviewed By: marco-c

Differential Revision: https://reviews.llvm.org/D49132

llvm-svn: 336693
compiler-rt/lib/profile/GCDAProfiling.c