[clang] [llvm] [PGO][GlobalValue][LTO]In GlobalValues::getGlobalIdentifier, use semicolon as delimiter for local-linkage varibles. (PR #74008)

Mingming Liu via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 5 13:35:11 PST 2023


================
@@ -300,12 +316,8 @@ getIRPGONameForGlobalObject(const GlobalObject &GO,
                             GlobalValue::LinkageTypes Linkage,
                             StringRef FileName) {
   SmallString<64> Name;
-  if (llvm::GlobalValue::isLocalLinkage(Linkage)) {
-    Name.append(FileName.empty() ? "<unknown>" : FileName);
-    Name.append(";");
-  }
   Mangler().getNameWithPrefix(Name, &GO, /*CannotUsePrivateLabel=*/true);
----------------
minglotus-6 wrote:

>  I think it makes more sense to use linkage-names for IRPGO, -order_file, and ThinLTO. -order_file is used in the linker when it only knows linkage-names, so I don't think it makes sense to feed it mangled names.

Thanks for the input.  (not to bikeshed but) I think for the purpose of computing global identifier, unique names should suffice. Clang-FE mangled names are unique so sounds fine.

Using linkage-name would be a non-trivial change, given the static `getGlobalIdentifier` takes a stringified name currently, and using linkage-name means requiring compatible change in each callsite (e.g., if the caller context doesn't have `GlobalValue` but just stringified names in the bitcode, make sure linkage-name exists in the bitcode, [this](https://github.com/llvm/llvm-project/blob/d6fbd96e5eaf3e8acbf1b43dce7a311352907567/llvm/lib/Bitcode/Reader/BitcodeReader.cpp#L6763) seems one example). An alternative fixup is to store the MD5 of `[filename;]linkage-name` (this is what's currently stored in this [field](https://github.com/llvm/llvm-project/blob/0f45e45847a5f2969b8021c787a566531fc96473/compiler-rt/include/profile/InstrProfData.inc#L72-L74)) and the MD5 of `[filename:]mangled-name` (the original hash before D156569) in the raw profiles, so `llvm-profdata` could choose properly (former for ordering and latter for ICP)

Would you mind if I create a Github issue to track how to fix other potential cases and assign it to you ? This PR would solve the colon and semicolon difference.

https://github.com/llvm/llvm-project/pull/74008


More information about the cfe-commits mailing list