[PGO/SamplePGO][NFC] Move the function updateProfWeight from Instruction
authorWei Mi <wmi@google.com>
Mon, 22 Apr 2019 17:04:51 +0000 (17:04 +0000)
committerWei Mi <wmi@google.com>
Mon, 22 Apr 2019 17:04:51 +0000 (17:04 +0000)
commit01f8d556aa7274336f94afe6581bded378f3b4f4
tree9600b79e316f6aa46746381943a760a06c25b4f2
parent7cdec273ddac51fa002fb9eaaf36e274d311a856
[PGO/SamplePGO][NFC] Move the function updateProfWeight from Instruction
to CallInst.

The issue was raised here: https://reviews.llvm.org/D60903#1472783

The function Instruction::updateProfWeight is only used for CallInst in
profile update. From the current interface, it is very easy to think that
the function can also be used for branch instruction. However, Branch
instruction does't need the scaling the function provides for
branch_weights and VP (value profile), in addition, scaling may introduce
inaccuracy for branch probablity.

The patch moves the function updateProfWeight from Instruction class to
CallInst to remove the confusion. The patch also changes the scaling of
branch_weights from a loop to a block because we know that ProfileData
for branch_weights of CallInst will only have two operands at most.

Differential Revision: https://reviews.llvm.org/D60911

llvm-svn: 358900
llvm/include/llvm/IR/Instruction.h
llvm/include/llvm/IR/Instructions.h
llvm/lib/IR/Instruction.cpp
llvm/lib/IR/Instructions.cpp