[llvm] [clang] [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
Fri Dec 1 16:52:01 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 we can only generate the linkage name at compile time because we need to know the linkage, which llvm-profdata doesn't have.

Yep, but my original question is more about why using linkage-name in IRPGOFuncName (early in the pipeline) rather than storing it at a later phase of the pipeline. I read the code and [rfc](https://discourse.llvm.org/t/rfc-temporal-profiling-extension-for-irpgo/68068) again to make sense of why 'linkage-name' is needed in IRPGOFunc names.

> Was PGO broken in general before D156569? Or is this specific to -symbol-ordering-file and -order_file?
> It wasn't broken in general, but it's needed to get -order_file working correctly.

My understanding is that the specific data flow requires linkage-name to be stored in raw profiles. `llvm-profdata order` takes a profile and generates an order file (https://llvm.org/docs/CommandGuide/llvm-profdata.html#order); this file is used by `-symbol-ordering-file` directly.  Correct me if I miss anything.

A similar ELF option to `symbol-ordering-file` is [call-graph-ordering](https://github.com/llvm/llvm-project/blob/005c83380a907becbf5a6b4522fc43652c9536cd/lld/ELF/Driver.cpp#L1675-L1676), but with a different data flow. At a very high level, the edge (<caller, callee, weight> is passed in ELF sections, where linkage-name is already used.

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


More information about the cfe-commits mailing list