1. [BPI] Improve static heuristics for "cold" paths. (details)
Commit 9fb074e7bb12ba20ca5ca628a11d4cb30e7c87cc by ybrevnov
[BPI] Improve static heuristics for "cold" paths.

Current approach doesn't work well in cases when multiple paths are predicted to be "cold". By "cold" paths I mean those containing "unreachable" instruction, call marked with 'cold' attribute and 'unwind' handler of 'invoke' instruction. The issue is that heuristics are applied one by one until the first match and essentially ignores relative hotness/coldness
of other paths.

New approach unifies processing of "cold" paths by assigning predefined absolute weight to each block estimated to be "cold". Then we propagate these weights up/down IR similarly to existing approach. And finally set up edge probabilities based on estimated block weights.

One important difference is how we propagate weight up. Existing approach propagates the same weight to all blocks that are post-dominated by a block with some "known" weight. This is useless at least because it always gives 50\50 distribution which is assumed by default anyway. Worse, it causes the algorithm to skip further heuristics and can miss setting more accurate probability. New algorithm propagates the weight up only to the blocks that dominates and post-dominated by a block with some "known" weight. In other words, those blocks that are either always executed or not executed together.

In addition new approach processes loops in an uniform way as well. Essentially loop exit edges are estimated as "cold" paths relative to back edges and should be considered uniformly with other coldness/hotness markers.

Reviewed By: yrouban

Differential Revision:
The file was modifiedllvm/test/CodeGen/PowerPC/sms-cpy-1.ll
The file was modifiedllvm/test/Analysis/BlockFrequencyInfo/redundant_edges.ll
The file was modifiedllvm/test/CodeGen/ARM/v8m.base-jumptable_alignment.ll
The file was modifiedllvm/test/Analysis/BranchProbabilityInfo/basic.ll
The file was modifiedllvm/lib/Transforms/Scalar/LoopPredication.cpp
The file was modifiedllvm/lib/Analysis/OptimizationRemarkEmitter.cpp
The file was addedllvm/test/Analysis/BranchProbabilityInfo/deopt-invoke.ll
The file was modifiedllvm/include/llvm/Analysis/LazyBranchProbabilityInfo.h
The file was modifiedllvm/test/CodeGen/ARM/sub-cmp-peephole.ll
The file was modifiedllvm/test/Analysis/BranchProbabilityInfo/noreturn.ll
The file was modifiedllvm/test/CodeGen/ARM/ifcvt-branch-weight-bug.ll
The file was modifiedllvm/test/CodeGen/SPARC/missinglabel.ll
The file was modifiedllvm/test/CodeGen/X86/misched_phys_reg_assign_order.ll
The file was modifiedllvm/test/CodeGen/WebAssembly/switch-unreachable-default.ll
The file was modifiedllvm/test/CodeGen/X86/2008-04-17-CoalescerBug.ll
The file was modifiedllvm/test/CodeGen/AArch64/GlobalISel/irtranslator-invoke-probabilities.ll
The file was modifiedllvm/test/CodeGen/X86/ragreedy-hoist-spill.ll
The file was modifiedllvm/test/CodeGen/AMDGPU/transform-block-with-return-to-epilog.ll
The file was modifiedllvm/lib/Analysis/BranchProbabilityInfo.cpp
The file was modifiedllvm/test/CodeGen/SystemZ/debuginstr-cgp.mir
The file was modifiedllvm/test/Analysis/BranchProbabilityInfo/loop.ll
The file was modifiedllvm/include/llvm/Analysis/BranchProbabilityInfo.h
The file was modifiedllvm/test/CodeGen/X86/block-placement.ll
The file was modifiedllvm/test/CodeGen/X86/pr27501.ll
The file was modifiedllvm/test/CodeGen/X86/pr37916.ll
The file was addedllvm/test/Analysis/BranchProbabilityInfo/unreachable.ll
The file was modifiedllvm/test/Transforms/JumpThreading/thread-prob-3.ll
The file was modifiedllvm/test/CodeGen/PowerPC/pr36292.ll
The file was modifiedllvm/test/Analysis/BranchProbabilityInfo/deopt-intrinsic.ll
The file was modifiedllvm/test/CodeGen/PowerPC/p10-spill-crgt.ll