================ @@ -241,9 +264,11 @@ void scaleProfData(Instruction &I, uint64_t S, uint64_t T) { if (ProfDataName->getString() == "branch_weights" && ProfileData->getNumOperands() > 0) { // Using APInt::div may be expensive, but most cases should fit 64 bits. - APInt Val(128, mdconst::dyn_extract<ConstantInt>(ProfileData->getOperand(1)) - ->getValue() - .getZExtValue()); + APInt Val(128, + mdconst::dyn_extract<ConstantInt>( + ProfileData->getOperand(getBranchWeightOffset(ProfileData))) + ->getValue() + .getZExtValue()); ---------------- ilovepi wrote:
I think between the existing ‘getBranchWeights’ and the ‘getNumBranches’ in https://github.com/llvm/llvm-project/pull/90146 we should be able to avoid most issues. Ideally, the only place that should be setting the operand directly would be things in this file. Let me take a pass over the existing users outside of this file to see if there is a way to do that. https://github.com/llvm/llvm-project/pull/95281 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits