[llvm] r299150 - [XRay][tools] Remove some assertions in llvm-xray graph

Dean Michael Berris via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 30 18:56:45 PDT 2017


Author: dberris
Date: Thu Mar 30 20:56:45 2017
New Revision: 299150

URL: http://llvm.org/viewvc/llvm-project?rev=299150&view=rev
Log:
[XRay][tools] Remove some assertions in llvm-xray graph

Summary:
Assertions assuming that function calls may not have zero durations do
not seem to hold in the wild. There are valid cases where the conversion
of the tsc counters end up becoming zero-length durations. These
assertions don't really hold and the algorithms don't need those to be
true for them to work.

Reviewers: dblaikie, echristo

Subscribers: llvm-commits

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

Added:
    llvm/trunk/test/tools/llvm-xray/X86/graph-zero-latency-calls.yaml
Modified:
    llvm/trunk/tools/llvm-xray/xray-graph.cc

Added: llvm/trunk/test/tools/llvm-xray/X86/graph-zero-latency-calls.yaml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-xray/X86/graph-zero-latency-calls.yaml?rev=299150&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-xray/X86/graph-zero-latency-calls.yaml (added)
+++ llvm/trunk/test/tools/llvm-xray/X86/graph-zero-latency-calls.yaml Thu Mar 30 20:56:45 2017
@@ -0,0 +1,20 @@
+#RUN: llvm-xray graph %s -o - -m %S/Inputs/simple-instrmap.yaml | FileCheck %s
+
+---
+header:
+  version: 1
+  type: 0
+  constant-tsc: true
+  nonstop-tsc: true
+  cycle-frequency: 2601000000
+records:
+  - { type: 0, func-id: 1, cpu: 1, thread: 111, kind: function-enter, tsc: 10001 }
+  - { type: 0, func-id: 2, cpu: 1, thread: 111, kind: function-enter, tsc: 10002 }
+  - { type: 0, func-id: 2, cpu: 1, thread: 111, kind: function-exit, tsc: 10002 }
+  - { type: 0, func-id: 1, cpu: 1, thread: 111, kind: function-exit, tsc: 10100 }
+...
+
+#CHECK:     digraph xray {
+#CHECK-DAG:   F0 -> F1 [{{.*}}];
+#CHECK-DAG:   F1 -> F2 [{{.*}}];
+#CHECK-DAG: }

Modified: llvm/trunk/tools/llvm-xray/xray-graph.cc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-xray/xray-graph.cc?rev=299150&r1=299149&r2=299150&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-xray/xray-graph.cc (original)
+++ llvm/trunk/tools/llvm-xray/xray-graph.cc Thu Mar 30 20:56:45 2017
@@ -259,7 +259,7 @@ Error GraphRenderer::accountRecord(const
 
 template <typename U>
 void GraphRenderer::getStats(U begin, U end, GraphRenderer::TimeStat &S) {
-  assert(begin != end);
+  if (begin == end) return;
   std::ptrdiff_t MedianOff = S.Count / 2;
   std::nth_element(begin, begin + MedianOff, end);
   S.Median = *(begin + MedianOff);
@@ -287,9 +287,7 @@ void GraphRenderer::calculateEdgeStatist
   for (auto &E : G.edges()) {
     auto &A = E.second;
     assert(!A.Timings.empty());
-    assert((A.Timings[0] > 0));
     getStats(A.Timings.begin(), A.Timings.end(), A.S);
-    assert(A.S.Sum > 0);
     updateMaxStats(A.S, G.GraphEdgeMax);
   }
 }
@@ -297,15 +295,12 @@ void GraphRenderer::calculateEdgeStatist
 void GraphRenderer::calculateVertexStatistics() {
   std::vector<uint64_t> TempTimings;
   for (auto &V : G.vertices()) {
-    assert((V.first == 0 || G[V.first].S.Sum != 0) &&
-           "Every non-root vertex should have at least one call");
     if (V.first != 0) {
       for (auto &E : G.inEdges(V.first)) {
         auto &A = E.second;
         TempTimings.insert(TempTimings.end(), A.Timings.begin(),
                            A.Timings.end());
       }
-      assert(!TempTimings.empty() && TempTimings[0] > 0);
       getStats(TempTimings.begin(), TempTimings.end(), G[V.first].S);
       updateMaxStats(G[V.first].S, G.GraphVertexMax);
       TempTimings.clear();




More information about the llvm-commits mailing list