Skip to content

Commit eba2b78

Browse files
[RawProfReader]When constructing symbol table, read the MD5 of function name in the proper byte order (#76312)
Before this patch, when the field `NameRef` is generated in little-endian systems and read back in big-endian systems, the information gets dropped. - The bug gets caught by a buildbot https://lab.llvm.org/buildbot/#/builders/94/builds/17931. In the error message (pasted below), two indirect call targets are not imported. ``` ; IMPORTS-DAG: Import _Z7callee1v ^ <stdin>:1:1: note: scanning from here main.ll: Import _Z11global_funcv from lib.cc ^ <stdin>:1:10: note: possible intended match here main.ll: Import _Z11global_funcv from lib.cc ^ Input file: <stdin> Check file: /home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/llvm/test/Transforms/PGOProfile/thinlto_indirect_call_promotion.ll -dump-input=help explains the following input dump. Input was: <<<<<< 1: main.ll: Import _Z11global_funcv from lib.cc dag:34'0 X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found dag:34'1 ? possible intended match ``` [This commit](b399924#diff-b196b796c5a396c7cdf93b347fe47e2b29b72d0b7dd0e2b88abb964d376ee50e) gates the fix by flag and provide test data by creating big-endian profiles (rather than reading the little-endian data on a big-endian system that might require a VM). - [This](b399924#diff-643176077ddbe537bd0a05d2a8a53bdff6339420a30e8511710bf232afdda8b9) is a hexdump of little-endian profile data, and [this](b399924#diff-1736a3ee25dde02bba55d670df78988fdb227e5a85b94b8707cf182cf70b28f0) is the big-endian version of it. - The [README.md](b399924#diff-6717b6a385de3ae60ab3aec9638af2a43b55adaf6784b6f0393ebe1a6639438b) shows the result of `llvm-profdata show -ic-targets` before and after the fix when the profile is in big-endian.
1 parent e512df3 commit eba2b78

File tree

2 files changed

+1
-4
lines changed

2 files changed

+1
-4
lines changed

llvm/lib/ProfileData/InstrProfReader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ Error RawInstrProfReader<IntPtrT>::createSymtab(InstrProfSymtab &Symtab) {
539539
const IntPtrT FPtr = swap(I->FunctionPointer);
540540
if (!FPtr)
541541
continue;
542-
Symtab.mapAddress(FPtr, I->NameRef);
542+
Symtab.mapAddress(FPtr, swap(I->NameRef));
543543
}
544544
return success();
545545
}

llvm/test/Transforms/PGOProfile/thinlto_indirect_call_promotion.ll

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
; The raw profiles storesd compressed function names, so profile reader should
1010
; be built with zlib support to decompress them.
1111
; REQUIRES: zlib
12-
; REQUIRES: host-byteorder-little-endian
13-
; Raw profiles are generate on 64-bit systems.
14-
; REQUIRES: llvm-64-bits
1512

1613
; RUN: rm -rf %t && split-file %s %t && cd %t
1714

0 commit comments

Comments
 (0)