diff options
author | Kazu Hirata <kazu@google.com> | 2024-06-18 13:06:43 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-18 13:06:43 -0700 |
commit | 3d2bbea37002e38759c06d975b6656a91e908dc6 (patch) | |
tree | 3fed38c07d9a0d9a5e2b6f1fb9c99e083320e914 | |
parent | 4b57fe65fdc6b8d7163f36440386d1e707d89381 (diff) | |
download | llvm-3d2bbea37002e38759c06d975b6656a91e908dc6.zip llvm-3d2bbea37002e38759c06d975b6656a91e908dc6.tar.gz llvm-3d2bbea37002e38759c06d975b6656a91e908dc6.tar.bz2 |
[ProfileData] Clean up validateRecord (#95488)
validateRecord ensures that all the values are unique except for
IPVK_IndirectCallTarget and IPVK_VTableTarget. The problem is that we
exclude them in the innermost loop.
This patch pulls the loop invariant out of the loop. While I am at
it, this patch migrates a use of getValueForSite to
getValueArrayForSite.
-rw-r--r-- | llvm/lib/ProfileData/InstrProfWriter.cpp | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/llvm/lib/ProfileData/InstrProfWriter.cpp b/llvm/lib/ProfileData/InstrProfWriter.cpp index cf2416c..eac59ea 100644 --- a/llvm/lib/ProfileData/InstrProfWriter.cpp +++ b/llvm/lib/ProfileData/InstrProfWriter.cpp @@ -1034,16 +1034,13 @@ static const char *ValueProfKindStr[] = { Error InstrProfWriter::validateRecord(const InstrProfRecord &Func) { for (uint32_t VK = 0; VK <= IPVK_Last; VK++) { - uint32_t NS = Func.getNumValueSites(VK); - if (!NS) + if (VK == IPVK_IndirectCallTarget || VK == IPVK_VTableTarget) continue; + uint32_t NS = Func.getNumValueSites(VK); for (uint32_t S = 0; S < NS; S++) { - uint32_t ND = Func.getNumValueDataForSite(VK, S); - std::unique_ptr<InstrProfValueData[]> VD = Func.getValueForSite(VK, S); DenseSet<uint64_t> SeenValues; - for (uint32_t I = 0; I < ND; I++) - if ((VK != IPVK_IndirectCallTarget && VK != IPVK_VTableTarget) && - !SeenValues.insert(VD[I].Value).second) + for (const auto &V : Func.getValueArrayForSite(VK, S)) + if (!SeenValues.insert(V.Value).second) return make_error<InstrProfError>(instrprof_error::invalid_prof); } } |