From: Teresa Johnson Date: Wed, 22 Sep 2021 23:25:33 +0000 (-0700) Subject: [ThinLTO] Don't emit original GUID for locals to distributed indexes X-Git-Tag: upstream/15.0.7~30664 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2c1defeee40cf643ea6f0fa5e01164c9a4c48c30;p=platform%2Fupstream%2Fllvm.git [ThinLTO] Don't emit original GUID for locals to distributed indexes In ThinLTO for locals we normally compute the GUID from the name after prepending the source path to get a unique global id. SamplePGO indirect call profiles contain the target GUID without this uniquification, however (unless compiling with -funique-internal-linkage-names). Therefore, the index contains the original GUID of the local symbols (without module path prepended to uniquify), in order to correctly handle the call edges added for these indirect call profile targets with SamplePGO. We were emitting these to the combined index when writing it out as bitcode, which is unnecessary and causes overhead when writing out the indexes for distributed backends. The only use of the original GUID name is in the thin link. Suppress it in that case. This reduced the thin link time for a large distributed build by about 7%, and the aggregate size of the serialized indexes by over 2%. Continue to print it when writing out the full index, since that is just used for debugging and testing. Update a distributed thinlto index test to contain a local and ensure that we don't get a COMBINED_ORIGINAL_NAME record. Differential Revision: https://reviews.llvm.org/D110296 --- diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp index 24b6e16..402840e 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -4148,7 +4148,14 @@ void IndexBitcodeWriter::writeCombinedGlobalValueSummary() { // For local linkage, we also emit the original name separately // immediately after the record. auto MaybeEmitOriginalName = [&](GlobalValueSummary &S) { - if (!GlobalValue::isLocalLinkage(S.linkage())) + // We don't need to emit the original name if we are writing the index for + // distributed backends (in which case ModuleToSummariesForIndex is + // non-null). The original name is only needed during the thin link, since + // for SamplePGO the indirect call targets for local functions have + // have the original name annotated in profile. + // Continue to emit it when writing out the entire combined index, which is + // used in testing the thin link via llvm-lto. + if (ModuleToSummariesForIndex || !GlobalValue::isLocalLinkage(S.linkage())) return; NameVals.push_back(S.getOriginalName()); Stream.EmitRecord(bitc::FS_COMBINED_ORIGINAL_NAME, NameVals); diff --git a/llvm/test/ThinLTO/X86/distributed_indexes.ll b/llvm/test/ThinLTO/X86/distributed_indexes.ll index 65f14a2..245ece4 100644 --- a/llvm/test/ThinLTO/X86/distributed_indexes.ll +++ b/llvm/test/ThinLTO/X86/distributed_indexes.ll @@ -20,10 +20,12 @@ ; BACKEND1-DAG: +; BACKEND1-DAG: ; BACKEND1-NEXT: +; BACKEND2-NEXT: ; BACKEND2-NEXT: