OSDN Git Service

[BPI] Use a safer constructor to calculate branch probabilities
authorVedant Kumar <vsk@apple.com>
Sat, 17 Dec 2016 00:09:51 +0000 (00:09 +0000)
committerVedant Kumar <vsk@apple.com>
Sat, 17 Dec 2016 00:09:51 +0000 (00:09 +0000)
commit9d419abb73daee4647e6509dc7148a65c2929b10
tree916f025e9ffbb4394f547d759522ce39f0ba9623
parent67f0925dfd221ca42fbaa8b8505658c71997e9e8
[BPI] Use a safer constructor to calculate branch probabilities

BPI may trigger signed overflow UB while computing branch probabilities
for cold calls or to unreachables. For example, with our current choice
of weights, we'll crash if there are >= 2^12 branches to an unreachable.

Use a safer BranchProbability constructor which is better at handling
fractions with large denominators.

rdar://problem/29368161

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@290016 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Analysis/BranchProbabilityInfo.cpp
unittests/Analysis/BranchProbabilityInfoTest.cpp [new file with mode: 0644]
unittests/Analysis/CMakeLists.txt