MaskRay wrote:

Trying to summarize the issue.

`__llvm_prf_nm` contains an entry `getIRPGONameForGlobalObject() == 
"lib.cc;_ZL7callee0v"`. The hash in the "VP" metadata uses 
`md5("lib.cc;_ZL7callee0v")`: `!31 = !{!"VP", i32 0, i64 1, i64 
8947761083887884635, i64 1}`

Without this patch, when invoking `opt -passes=pgo-instr-use 
-pgo-test-profile-file=%t.profdata -module-summary %tdir/lib.ll -o %t2.bc`,
in `llvm/lib/Analysis/ModuleSummaryAnalysis.cpp:computeFunctionSummary`,
the local linkage `_ZL7callee0v`'s GUID is incorrectly computed as 
`md5("lib.cc:_ZL7callee0v")` and therefore is not associated with the global 
variable summary `_Z7callee1v`
(displayed as a stray `^2 = gv: (guid: 8947761083887884635)`).

This patch fixes `_ZL7callee0v`'s GUID to be `md5("lib.cc;_ZL7callee0v")`, 
correctly associating it with the global variable summary `_Z7callee1v`.

---

Mach-O (and 32-bit Windows) mangle global symbols with a leading `_`.
`llvm/lib/Analysis/ModuleSummaryAnalysis.cpp:computeFunctionSummary` uses 
`getGlobalIdentifier`, which does not have `GlobalObject` information for the 
mangling scheme.
The identifier can be different from the producer, causing missed import of 
functions for indirect-call-promotion (#74565).


https://github.com/llvm/llvm-project/pull/74008
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to