diff options
author | Micah Weston <micahsweston@gmail.com> | 2024-01-05 21:59:51 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-05 21:59:51 -0500 |
commit | 2873060f3cfbd92dcff8d1037a08e9fb60f7882e (patch) | |
tree | 7b5b8794fadb96f716c3da92c9e43f054e1ac78e /llvm/lib/Object/ELF.cpp | |
parent | dbea538c4391caa8a369c0ccf720367f042185b1 (diff) | |
download | llvm-2873060f3cfbd92dcff8d1037a08e9fb60f7882e.zip llvm-2873060f3cfbd92dcff8d1037a08e9fb60f7882e.tar.gz llvm-2873060f3cfbd92dcff8d1037a08e9fb60f7882e.tar.bz2 |
[SHT_LLVM_BB_ADDR_MAP] Fixes two bugs in decoding of PGOAnalyses in BBAddrMap. (#77139)
We had specified that `readBBAddrMap` will always keep PGOAnalyses and
BBAddrMaps the same length on success.
https://github.com/llvm/llvm-project/blob/365fbbfbcfefb8766f7716109b9c3767b58e6058/llvm/include/llvm/Object/ELFObjectFile.h#L116-L117
It turns out that this is not currently the case when no analyses exist
in a function. No test had caught it.
We also should not append PGOBBEntries when there is no BBFreq or
BrProb.
This patch adds:
* tests that PGOAnalyses and BBAddrMaps are same length even when no
analyses are enabled
* fixes decode so that PGOAnalyses and BBAddrMaps are same length
* updates test to not emit unnecessary PGOBBEntries
* fixes decode to not emit PGOBBEntries when unnecessary
Diffstat (limited to 'llvm/lib/Object/ELF.cpp')
-rw-r--r-- | llvm/lib/Object/ELF.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/Object/ELF.cpp b/llvm/lib/Object/ELF.cpp index 300639f..f24395b 100644 --- a/llvm/lib/Object/ELF.cpp +++ b/llvm/lib/Object/ELF.cpp @@ -774,7 +774,7 @@ decodeBBAddrMapImpl(const ELFFile<ELFT> &EF, } FunctionEntries.emplace_back(Address, std::move(BBEntries)); - if (FeatEnable.FuncEntryCount || FeatEnable.BBFreq || FeatEnable.BrProb) { + if (PGOAnalyses || FeatEnable.anyEnabled()) { // Function entry count uint64_t FuncEntryCount = FeatEnable.FuncEntryCount @@ -782,8 +782,9 @@ decodeBBAddrMapImpl(const ELFFile<ELFT> &EF, : 0; std::vector<PGOAnalysisMap::PGOBBEntry> PGOBBEntries; - for (uint32_t BlockIndex = 0; !MetadataDecodeErr && !ULEBSizeErr && Cur && - (BlockIndex < NumBlocks); + for (uint32_t BlockIndex = 0; + (FeatEnable.BBFreq || FeatEnable.BrProb) && !MetadataDecodeErr && + !ULEBSizeErr && Cur && (BlockIndex < NumBlocks); ++BlockIndex) { // Block frequency uint64_t BBF = FeatEnable.BBFreq |