diff options
author | Andrew Trick <atrick@apple.com> | 2012-08-29 21:46:38 +0000 |
---|---|---|
committer | Andrew Trick <atrick@apple.com> | 2012-08-29 21:46:38 +0000 |
commit | 3051aa1cb86c7345ece211a6d64186a9163f9932 (patch) | |
tree | 145e268d89c3f19f2ca6125e4725bbd7e81b1d2b /llvm/lib/Support/StringMap.cpp | |
parent | f3cf1932b31cd58bcff872c4a23726f84df38992 (diff) | |
download | llvm-3051aa1cb86c7345ece211a6d64186a9163f9932.zip llvm-3051aa1cb86c7345ece211a6d64186a9163f9932.tar.gz llvm-3051aa1cb86c7345ece211a6d64186a9163f9932.tar.bz2 |
Preserve branch profile metadata during switch formation.
Patch by Michael Ilseman!
This fixes SimplifyCFGOpt::FoldValueComparisonIntoPredecessors to preserve metata when folding conditional branches into switches.
void foo(int x) {
if (x == 0)
bar(1);
else if (__builtin_expect(x == 10, 1))
bar(2);
else if (x == 20)
bar(3);
}
CFG:
B0
| \
| X0
B10
| \
| X10
B20
| \
E X20
Merge B0-B10:
w(B0-X0) = w(B0-X0)*sum-weights(B10) = w(B0-X0) * (w(B10-X10) + w(B10-B20))
w(B0-X10) = w(B0-B10) * w(B10-X10)
w(B0-B20) = w(B0-B10) * w(B10-B20)
B0 __
| \ \
| X10 X0
B20
| \
E X20
Merge B0-B20:
w(B0-X0) = w(B0-X0) * sum-weights(B20) = w(B0-X0) * (w(B20-E) + w(B20-X20))
w(B0-X10) = w(B0-X10) * sum-weights(B20) = ...
w(B0-X20) = w(B0-B20) * w(B20-X20)
w(B0-E) = w(B0-B20) * w(B20-E)
llvm-svn: 162868
Diffstat (limited to 'llvm/lib/Support/StringMap.cpp')
0 files changed, 0 insertions, 0 deletions