<div dir="ltr">Sure - sounds plausible to me.</div><br><div class="gmail_quote"><div dir="ltr">On Thu, Mar 30, 2017 at 5:32 PM Dean Michael Berris via Phabricator <<a href="mailto:reviews@reviews.llvm.org">reviews@reviews.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">dberris created this revision.<br class="gmail_msg">
<br class="gmail_msg">
Assertions assuming that function calls may not have zero durations do<br class="gmail_msg">
not seem to hold in the wild. There are valid cases where the conversion<br class="gmail_msg">
of the tsc counters end up becoming zero-length durations. These<br class="gmail_msg">
assertions don't really hold and the algorithms don't need those to be<br class="gmail_msg">
true for them to work.<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
<a href="https://reviews.llvm.org/D31519" rel="noreferrer" class="gmail_msg" target="_blank">https://reviews.llvm.org/D31519</a><br class="gmail_msg">
<br class="gmail_msg">
Files:<br class="gmail_msg">
test/tools/llvm-xray/X86/graph-zero-latency-calls.yaml<br class="gmail_msg">
tools/llvm-xray/xray-graph.cc<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
Index: tools/llvm-xray/xray-graph.cc<br class="gmail_msg">
===================================================================<br class="gmail_msg">
--- tools/llvm-xray/xray-graph.cc<br class="gmail_msg">
+++ tools/llvm-xray/xray-graph.cc<br class="gmail_msg">
@@ -259,7 +259,7 @@<br class="gmail_msg">
<br class="gmail_msg">
template <typename U><br class="gmail_msg">
void GraphRenderer::getStats(U begin, U end, GraphRenderer::TimeStat &S) {<br class="gmail_msg">
- assert(begin != end);<br class="gmail_msg">
+ if (begin == end) return;<br class="gmail_msg">
std::ptrdiff_t MedianOff = S.Count / 2;<br class="gmail_msg">
std::nth_element(begin, begin + MedianOff, end);<br class="gmail_msg">
S.Median = *(begin + MedianOff);<br class="gmail_msg">
@@ -287,25 +287,20 @@<br class="gmail_msg">
for (auto &E : G.edges()) {<br class="gmail_msg">
auto &A = E.second;<br class="gmail_msg">
assert(!A.Timings.empty());<br class="gmail_msg">
- assert((A.Timings[0] > 0));<br class="gmail_msg">
getStats(A.Timings.begin(), A.Timings.end(), A.S);<br class="gmail_msg">
- assert(A.S.Sum > 0);<br class="gmail_msg">
updateMaxStats(A.S, G.GraphEdgeMax);<br class="gmail_msg">
}<br class="gmail_msg">
}<br class="gmail_msg">
<br class="gmail_msg">
void GraphRenderer::calculateVertexStatistics() {<br class="gmail_msg">
std::vector<uint64_t> TempTimings;<br class="gmail_msg">
for (auto &V : G.vertices()) {<br class="gmail_msg">
- assert((V.first == 0 || G[V.first].S.Sum != 0) &&<br class="gmail_msg">
- "Every non-root vertex should have at least one call");<br class="gmail_msg">
if (V.first != 0) {<br class="gmail_msg">
for (auto &E : G.inEdges(V.first)) {<br class="gmail_msg">
auto &A = E.second;<br class="gmail_msg">
TempTimings.insert(TempTimings.end(), A.Timings.begin(),<br class="gmail_msg">
A.Timings.end());<br class="gmail_msg">
}<br class="gmail_msg">
- assert(!TempTimings.empty() && TempTimings[0] > 0);<br class="gmail_msg">
getStats(TempTimings.begin(), TempTimings.end(), G[V.first].S);<br class="gmail_msg">
updateMaxStats(G[V.first].S, G.GraphVertexMax);<br class="gmail_msg">
TempTimings.clear();<br class="gmail_msg">
Index: test/tools/llvm-xray/X86/graph-zero-latency-calls.yaml<br class="gmail_msg">
===================================================================<br class="gmail_msg">
--- /dev/null<br class="gmail_msg">
+++ test/tools/llvm-xray/X86/graph-zero-latency-calls.yaml<br class="gmail_msg">
@@ -0,0 +1,20 @@<br class="gmail_msg">
+#RUN: llvm-xray graph %s -o - -m %S/Inputs/simple-instrmap.yaml | FileCheck %s<br class="gmail_msg">
+<br class="gmail_msg">
+---<br class="gmail_msg">
+header:<br class="gmail_msg">
+ version: 1<br class="gmail_msg">
+ type: 0<br class="gmail_msg">
+ constant-tsc: true<br class="gmail_msg">
+ nonstop-tsc: true<br class="gmail_msg">
+ cycle-frequency: 2601000000<br class="gmail_msg">
+records:<br class="gmail_msg">
+ - { type: 0, func-id: 1, cpu: 1, thread: 111, kind: function-enter, tsc: 10001 }<br class="gmail_msg">
+ - { type: 0, func-id: 2, cpu: 1, thread: 111, kind: function-enter, tsc: 10002 }<br class="gmail_msg">
+ - { type: 0, func-id: 2, cpu: 1, thread: 111, kind: function-exit, tsc: 10002 }<br class="gmail_msg">
+ - { type: 0, func-id: 1, cpu: 1, thread: 111, kind: function-exit, tsc: 10100 }<br class="gmail_msg">
+...<br class="gmail_msg">
+<br class="gmail_msg">
+#CHECK: digraph xray {<br class="gmail_msg">
+#CHECK-DAG: F0 -> F1 [{{.*}}];<br class="gmail_msg">
+#CHECK-DAG: F1 -> F2 [{{.*}}];<br class="gmail_msg">
+#CHECK-DAG: }<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
</blockquote></div>