Remove the function Instruction::setProfWeight() and make use of Instruction::copyMetadata(.., {LLVMContext::MD_prof}).
This is correct for all use cases of setProfWeight() as it is applied to CallBase instructions only.
This change results in prof metadata copied intact even if the source has "VP". The old pair of calls extractProfTotalWeight() + setProfWeight() resulted in setting branch_weights if the source had "VP" data.
This is a split part of D80618.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/test/Transforms/InstCombine/cast-call-combine-prof.ll | ||
---|---|---|
35 | where does 'branch_weights' profdata go? |
llvm/test/Transforms/InstCombine/cast-call-combine-prof.ll | ||
---|---|---|
35 | "VP" is preserved as pointed out in the summary. |
llvm/test/Transforms/InstCombine/cast-call-combine-prof.ll | ||
---|---|---|
35 | If the invoke is still there, the branch weights should also be copied over, right? |
llvm/test/Transforms/InstCombine/cast-call-combine-prof.ll | ||
---|---|---|
35 | In cast-call-combine-prof.ll there is no branch_weights metadata. |
lgtm (after fixing the comment mentioned by Hiroshi)
llvm/test/Transforms/InstCombine/cast-call-combine-prof.ll | ||
---|---|---|
35 | ah thanks. The old diff does not have context so I read it wrong |
This refers to SamplePGO preserving the call count in the metadata (which originates in D31344), but it seems more general as it could also apply to calls under PGO (eg the VP metadata).