[llvm-branch-commits] [llvm][IR] Extend BranchWeightMetadata to track provenance of weights (PR #86609)
Matthias Braun via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Apr 8 18:28:41 PDT 2024
================
@@ -1210,12 +1210,22 @@ Instruction *Instruction::cloneImpl() const {
void Instruction::swapProfMetadata() {
MDNode *ProfileData = getBranchWeightMDNode(*this);
- if (!ProfileData || ProfileData->getNumOperands() != 3)
+ if (!isBranchWeightMD(ProfileData))
return;
- // The first operand is the name. Fetch them backwards and build a new one.
- Metadata *Ops[] = {ProfileData->getOperand(0), ProfileData->getOperand(2),
- ProfileData->getOperand(1)};
+ SmallVector<Metadata *, 4> Ops;
+ unsigned int FirstIdx = getBranchWeightOffset(ProfileData);
----------------
MatzeB wrote:
Not a strong opinion, but I think most people just write `unsigned` in LLVM codebase...
```suggestion
unsigned FirstIdx = getBranchWeightOffset(ProfileData);
```
https://github.com/llvm/llvm-project/pull/86609
More information about the llvm-branch-commits
mailing list