[PATCH] D11442: Provide an interface normalizeSuccWeights in MachineBasicBlock to normalize its successors' weights and use it in other places.

Cong Hou via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 11 16:59:54 PDT 2015


Hi Duncan

I committed this patch in the past after your approval, but it broke some
others tests (see PR24377) that are not in the tree and I then reverted it.
Later I investigated the bug and found the problem is that we could get
zero edge weights from BPI (usually the zero weight is from test cases).
When those zero weights come to MBPI, they will be turned into 16, which
will lead to overflow when summing up weights. For example, if we have two
edge weights 0 and UINT32_MAX, in the weight normalization function they
are OK as the sum of them is not greater than UINT32_MAX. But when summing
them up in MBPI we are adding 16 + UINT32_MAX instead of 0 + UINT32_MAX.
This will lead to assertion failures.

As when BFI meets zero weights it will turn them into ones, I did the same
trick in BPI by turning zero edge weights into ones. Now those test
failures have disappeared.

Could you please take a look again at this patch? The additional update is
in lib/Analysis/BranchProbabilityInfo.cpp and some test cases. Thank you
very much!


thanks,
Cong

On Tue, Aug 11, 2015 at 4:43 PM, Cong Hou <congh at google.com> wrote:

> congh removed rL LLVM as the repository for this revision.
> congh updated this revision to Diff 31882.
> congh added a comment.
>
> Update the patch by turning zero edge weights into one in BPI so that we
> won't get zero weights in BPI anymore.
>
>
> http://reviews.llvm.org/D11442
>
> Files:
>   include/llvm/CodeGen/MachineBasicBlock.h
>   include/llvm/CodeGen/MachineBranchProbabilityInfo.h
>   lib/Analysis/BranchProbabilityInfo.cpp
>   lib/CodeGen/IfConversion.cpp
>   lib/CodeGen/MachineBasicBlock.cpp
>   lib/CodeGen/MachineBlockPlacement.cpp
>   lib/CodeGen/MachineBranchProbabilityInfo.cpp
>   test/CodeGen/X86/pr24377.ll
>   test/Transforms/SampleProfile/branch.ll
>   test/Transforms/SampleProfile/calls.ll
>   test/Transforms/SampleProfile/propagate.ll
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150811/8f0ede55/attachment.html>


More information about the llvm-commits mailing list