diff options
author | Mingming Liu <mingmingl@google.com> | 2023-12-19 12:25:56 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-19 12:25:56 -0800 |
commit | 78a195e1002dbfdfaeb7b36d5699e58b47238cbb (patch) | |
tree | 63dcaacbdd0f87d33de7dd9e58acc247616214ca /llvm/unittests/ProfileData/InstrProfTest.cpp | |
parent | 99045b60b57571079f9cb4aea57870692523fbe8 (diff) | |
download | llvm-78a195e1002dbfdfaeb7b36d5699e58b47238cbb.zip llvm-78a195e1002dbfdfaeb7b36d5699e58b47238cbb.tar.gz llvm-78a195e1002dbfdfaeb7b36d5699e58b47238cbb.tar.bz2 |
Reland the reland "[PGO][GlobalValue][LTO]In GlobalValues::getGlobalIdentifier, use semicolon as delimiter for local-linkage varibles. " (#75954)
Simplify the compiler-rt test to make it more general for different
platforms, and use `*DAG` matchers for lines that may be emitted
out-of-order.
- The compiler-rt test passed on a Windows machine. Previously name
matchers don't work for MSVC mangling
(https://lab.llvm.org/buildbot/#/builders/127/builds/59907)
- `*DAG` matchers fixed the error in
https://lab.llvm.org/buildbot/#/builders/94/builds/17924
This is the second reland and fixed errors caught in first reland
(https://github.com/llvm/llvm-project/pull/75860)
**Original commit message**
Commit fe05193 (phab D156569), IRPGO names uses format
`[<filepath>;]<linkage-name>` while prior format is
`[<filepath>:<mangled-name>`. The format change would break the use case
demonstrated in (updated)
`llvm/test/Transforms/PGOProfile/thinlto_indirect_call_promotion.ll` and
`compiler-rt/test/profile/instrprof-thinlto-indirect-call-promotion.cpp`
This patch changes `GlobalValues::getGlobalIdentifer` to use the
semicolon.
To elaborate on the scenario how things break without this PR
1. IRPGO raw profiles stores (compressed) IRPGO names of functions in
one section, and per-function profile data in another section. The
[NameRef](https://github.com/llvm/llvm-project/blob/fc715e4cd942612a091097339841733757b53824/compiler-rt/include/profile/InstrProfData.inc#L72)
field in per-function profile data is the MD5 hash of IRPGO names.
2. When raw profiles are converted to indexed format profiles, the
profiled address is
[mapped](https://github.com/llvm/llvm-project/blob/fc715e4cd942612a091097339841733757b53824/llvm/lib/ProfileData/InstrProf.cpp#L876-L885)
to the MD5 hash of the callee.
3. In `pgo-instr-use` thin-lto prelink pipeline, MD5 hash of IRPGO names
will be
[annotated](https://github.com/llvm/llvm-project/blob/fc715e4cd942612a091097339841733757b53824/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp#L1707)
as value profiles, and used to import indirect-call-prom candidates. If
the annotated MD5 hash is computed from the new format while import uses
the prior format, the callee cannot be imported.
*
`compiler-rt/test/profile/instrprof-thinlto-indirect-call-promotion.cpp`
is added to have an end-to-end test.
* `llvm/test/Transforms/PGOProfile/thinlto_indirect_call_promotion.ll`
is updated to have better test coverage from another aspect (as runtime
tests are more sensitive to the environment and may be skipped by some
contributors)
Diffstat (limited to 'llvm/unittests/ProfileData/InstrProfTest.cpp')
-rw-r--r-- | llvm/unittests/ProfileData/InstrProfTest.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/unittests/ProfileData/InstrProfTest.cpp b/llvm/unittests/ProfileData/InstrProfTest.cpp index e6613a90..6a71a97 100644 --- a/llvm/unittests/ProfileData/InstrProfTest.cpp +++ b/llvm/unittests/ProfileData/InstrProfTest.cpp @@ -1379,7 +1379,7 @@ TEST(SymtabTest, instr_prof_symtab_compression_test) { TEST_P(MaybeSparseInstrProfTest, remapping_test) { Writer.addRecord({"_Z3fooi", 0x1234, {1, 2, 3, 4}}, Err); - Writer.addRecord({"file:_Z3barf", 0x567, {5, 6, 7}}, Err); + Writer.addRecord({"file;_Z3barf", 0x567, {5, 6, 7}}, Err); auto Profile = Writer.writeBuffer(); readProfile(std::move(Profile), llvm::MemoryBuffer::getMemBuffer(R"( type i l @@ -1397,7 +1397,7 @@ TEST_P(MaybeSparseInstrProfTest, remapping_test) { EXPECT_EQ(4u, Counts[3]); } - for (StringRef BarName : {"file:_Z3barf", "file:_Z4quuxf"}) { + for (StringRef BarName : {"file;_Z3barf", "file;_Z4quuxf"}) { EXPECT_THAT_ERROR(Reader->getFunctionCounts(BarName, 0x567, Counts), Succeeded()); ASSERT_EQ(3u, Counts.size()); |