diff options
author | Mircea Trofin <mtrofin@google.com> | 2025-10-01 09:54:30 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-10-01 09:54:30 -0700 |
commit | 240b73e10f5c6549776cfd3847db2be14dc42776 (patch) | |
tree | 73e39e4a32f5a91907ec85c8d33e6cbec84885cc /llvm/lib/Transforms/IPO/SampleProfile.cpp | |
parent | 8907b6d39371d439461cdd3475d5590f87821377 (diff) | |
download | llvm-240b73e10f5c6549776cfd3847db2be14dc42776.zip llvm-240b73e10f5c6549776cfd3847db2be14dc42776.tar.gz llvm-240b73e10f5c6549776cfd3847db2be14dc42776.tar.bz2 |
[SimplifyCFG][PGO] Reuse existing `setBranchWeights` (#160629)
The main difference between SimplifyCFG's `setBranchWeights` and the ProfDataUtils' is that the former doesn't propagate all-zero weights. That seems like a sensible thing to do, so updated the latter accordingly, and added a flag to control the behavior.
Also moved to ProfDataUtils the logic fitting 64-bit weights to 32-bit.
As side-effect, this fixes some profcheck failures.
Diffstat (limited to 'llvm/lib/Transforms/IPO/SampleProfile.cpp')
-rw-r--r-- | llvm/lib/Transforms/IPO/SampleProfile.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/IPO/SampleProfile.cpp b/llvm/lib/Transforms/IPO/SampleProfile.cpp index 5bc7e34..99b8b88 100644 --- a/llvm/lib/Transforms/IPO/SampleProfile.cpp +++ b/llvm/lib/Transforms/IPO/SampleProfile.cpp @@ -1664,8 +1664,9 @@ void SampleProfileLoader::generateMDProfMetadata(Function &F) { else if (OverwriteExistingWeights) I.setMetadata(LLVMContext::MD_prof, nullptr); } else if (!isa<IntrinsicInst>(&I)) { - setBranchWeights(I, {static_cast<uint32_t>(BlockWeights[BB])}, - /*IsExpected=*/false); + setBranchWeights( + I, ArrayRef<uint32_t>{static_cast<uint32_t>(BlockWeights[BB])}, + /*IsExpected=*/false); } } } else if (OverwriteExistingWeights || ProfileSampleBlockAccurate) { @@ -1676,7 +1677,8 @@ void SampleProfileLoader::generateMDProfMetadata(Function &F) { if (cast<CallBase>(I).isIndirectCall()) { I.setMetadata(LLVMContext::MD_prof, nullptr); } else { - setBranchWeights(I, {uint32_t(0)}, /*IsExpected=*/false); + setBranchWeights(I, ArrayRef<uint32_t>{uint32_t(0)}, + /*IsExpected=*/false); } } } |