diff options
| author | Rong Xu <xur@google.com> | 2016-12-13 06:41:14 +0000 |
|---|---|---|
| committer | Rong Xu <xur@google.com> | 2016-12-13 06:41:14 +0000 |
| commit | 51a1e3c4309002056181409f166ef8fd147a9644 (patch) | |
| tree | c253b681d1fe32ba982c78f0fe62c4b8105d02dd /llvm/lib/Transforms | |
| parent | 6546b9a209603f1b598f41d4db8264921d78b576 (diff) | |
| download | bcm5719-llvm-51a1e3c4309002056181409f166ef8fd147a9644.tar.gz bcm5719-llvm-51a1e3c4309002056181409f166ef8fd147a9644.zip | |
[PGO] Fix insane counts due to nonreturn calls
Summary:
Since we don't break BBs for function calls. We might get some insane counts
(wrap of unsigned) in the presence of noreturn calls.
This patch sets these counts to zero instead of the wrapped number.
Reviewers: davidxl
Subscribers: xur, eraman, llvm-commits
Differential Revision: https://reviews.llvm.org/D27602
llvm-svn: 289521
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp index d802295d553..28f4f7ea145 100644 --- a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp +++ b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp @@ -884,12 +884,21 @@ void PGOUseFunc::populateCounters() { } if (Count->CountValid) { if (Count->UnknownCountOutEdge == 1) { - uint64_t Total = Count->CountValue - sumEdgeCount(Count->OutEdges); + uint64_t Total = 0; + uint64_t OutSum = sumEdgeCount(Count->OutEdges); + // If the one of the successor block can early terminate (no-return), + // we can end up with situation where out edge sum count is larger as + // the source BB's count is collected by a post-dominated block. + if (Count->CountValue > OutSum) + Total = Count->CountValue - OutSum; setEdgeCount(Count->OutEdges, Total); Changes = true; } if (Count->UnknownCountInEdge == 1) { - uint64_t Total = Count->CountValue - sumEdgeCount(Count->InEdges); + uint64_t Total = 0; + uint64_t InSum = sumEdgeCount(Count->InEdges); + if (Count->CountValue > InSum) + Total = Count->CountValue - InSum; setEdgeCount(Count->InEdges, Total); Changes = true; } |

