diff options
author | Matthias Braun <matze@braunis.de> | 2023-11-16 10:55:19 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-16 10:55:19 -0800 |
commit | cb4627d15027e1ed0051f5e5af447602f0f60971 (patch) | |
tree | 69332c616744f6b976fdbcf38efc2384d0b7c827 /llvm/lib/Transforms/Utils/LoopRotationUtils.cpp | |
parent | 186db1bcb0096a6af348d7e17866c68fa2004068 (diff) | |
download | llvm-cb4627d15027e1ed0051f5e5af447602f0f60971.zip llvm-cb4627d15027e1ed0051f5e5af447602f0f60971.tar.gz llvm-cb4627d15027e1ed0051f5e5af447602f0f60971.tar.bz2 |
Add setBranchWeigths convenience function. NFC (#72446)
Add `setBranchWeights` convenience function to ProfDataUtils.h and use
it where appropriate.
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopRotationUtils.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/LoopRotationUtils.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp b/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp index 012aa5dbb..ae155ac 100644 --- a/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp +++ b/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp @@ -352,16 +352,17 @@ static void updateBranchWeights(BranchInst &PreHeaderBI, BranchInst &LoopBI, LoopBackWeight = 0; } - MDBuilder MDB(LoopBI.getContext()); - MDNode *LoopWeightMD = - MDB.createBranchWeights(SuccsSwapped ? LoopBackWeight : ExitWeight1, - SuccsSwapped ? ExitWeight1 : LoopBackWeight); - LoopBI.setMetadata(LLVMContext::MD_prof, LoopWeightMD); + const uint32_t LoopBIWeights[] = { + SuccsSwapped ? LoopBackWeight : ExitWeight1, + SuccsSwapped ? ExitWeight1 : LoopBackWeight, + }; + setBranchWeights(LoopBI, LoopBIWeights); if (HasConditionalPreHeader) { - MDNode *PreHeaderWeightMD = - MDB.createBranchWeights(SuccsSwapped ? EnterWeight : ExitWeight0, - SuccsSwapped ? ExitWeight0 : EnterWeight); - PreHeaderBI.setMetadata(LLVMContext::MD_prof, PreHeaderWeightMD); + const uint32_t PreHeaderBIWeights[] = { + SuccsSwapped ? EnterWeight : ExitWeight0, + SuccsSwapped ? ExitWeight0 : EnterWeight, + }; + setBranchWeights(PreHeaderBI, PreHeaderBIWeights); } } |