<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Dec 8, 2017, at 15:38, Jonathan Roelofs <<a href="mailto:jonathan@codesourcery.com" class="">jonathan@codesourcery.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><br style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">On 12/8/17 3:42 PM, Duncan P. N. Exon Smith via llvm-commits wrote:</span><br style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">Author: dexonsmith<br class="">Date: Fri Dec  8 14:42:43 2017<br class="">New Revision: 320208<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project?rev=320208&view=rev" class="">http://llvm.org/viewvc/llvm-project?rev=320208&view=rev</a><br class="">Log:<br class="">Revert part of "Cleanup some GraphTraits iteration code"<br class="">This reverts part of r300656, which caused a regression in<br class="">propagateMassToSuccessors by counting edges n^2 times, where n is the<br class="">number of edges from the source basic block to the same successor basic<br class="">block. The result was both incorrect and very slow to compute for large<br class="">values of n (e.g. switches with multiple cases that go to the same basic<br class="">block).<br class="">Patch by Andrew Scheidecker!<br class="">Added:<br class="">    llvm/trunk/test/Analysis/BlockFrequencyInfo/redundant_edges.ll<br class="">Modified:<br class="">    llvm/trunk/include/llvm/Analysis/BlockFrequencyInfoImpl.h<br class="">Modified: llvm/trunk/include/llvm/Analysis/BlockFrequencyInfoImpl.h<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/BlockFrequencyInfoImpl.h?rev=320208&r1=320207&r2=320208&view=diff" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/BlockFrequencyInfoImpl.h?rev=320208&r1=320207&r2=320208&view=diff</a><br class="">==============================================================================<br class="">--- llvm/trunk/include/llvm/Analysis/BlockFrequencyInfoImpl.h (original)<br class="">+++ llvm/trunk/include/llvm/Analysis/BlockFrequencyInfoImpl.h Fri Dec  8 14:42:43 2017<br class="">@@ -1314,9 +1314,12 @@ BlockFrequencyInfoImpl<BT>::propagateMas<br class="">       return false;<br class="">   } else {<br class="">     const BlockT *BB = getBlock(Node);<br class="">-    for (const auto Succ : children<const BlockT *>(BB))<br class="">-      if (!addToDist(Dist, OuterLoop, Node, getNode(Succ),<br class="">-                     getWeightFromBranchProb(BPI->getEdgeProbability(BB, Succ))))<br class="">+    for (auto SI = GraphTraits<const BlockT *>::child_begin(BB),<br class="">+              SE = GraphTraits<const BlockT *>::child_end(BB);<br class="">+         SI != SE; ++SI)<br class="">+      if (!addToDist(<br class="">+              Dist, OuterLoop, Node, getNode(*SI),<br class="">+              getWeightFromBranchProb(BPI->getEdgeProbability(BB, SI))))<br class=""></blockquote><br style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Where was the bug here, does children() recompute more or something?</span><br style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""></div></blockquote><div><br class=""></div><div>It would have helped if I'd linked to the review in the commit message:</div><div><a href="https://reviews.llvm.org/D40891" class="">https://reviews.llvm.org/D40891</a></div><div><br class=""></div><div>- `getEdgeProbability(BasicBlock&, edge_iterator)` returns the probability of a single edge.</div><div>- `getEdgeProbability(BasicBlock&, BasicBlock&)` returns the sum of the edges between blocks.</div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><br style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Jon</span><br style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">         // Irreducible backedge.<br class="">         return false;<br class="">   }<br class="">Added: llvm/trunk/test/Analysis/BlockFrequencyInfo/redundant_edges.ll<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/BlockFrequencyInfo/redundant_edges.ll?rev=320208&view=auto" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/BlockFrequencyInfo/redundant_edges.ll?rev=320208&view=auto</a><br class="">==============================================================================<br class="">--- llvm/trunk/test/Analysis/BlockFrequencyInfo/redundant_edges.ll (added)<br class="">+++ llvm/trunk/test/Analysis/BlockFrequencyInfo/redundant_edges.ll Fri Dec  8 14:42:43 2017<br class="">@@ -0,0 +1,22 @@<br class="">+; RUN: opt < %s -analyze -block-freq | FileCheck %s<br class="">+; RUN: opt < %s -analyze -lazy-block-freq | FileCheck %s<br class="">+; RUN: opt < %s -passes='print<block-freq>' -disable-output 2>&1 | FileCheck %s<br class="">+<br class="">+define void @test1() {<br class="">+; CHECK-LABEL: Printing analysis {{.*}} for function 'test1':<br class="">+; CHECK-NEXT: block-frequency-info: test1<br class="">+; CHECK-NEXT: entry: float = 1.0, int = [[ENTRY:[0-9]+]]<br class="">+entry:<br class="">+  br label %loop<br class="">+<br class="">+; CHECK-NEXT: loop: float = 32.0<br class="">+loop:<br class="">+  switch i32 undef, label %loop [<br class="">+    i32 0, label %return<br class="">+    i32 1, label %return<br class="">+  ]<br class="">+<br class="">+; CHECK-NEXT: return: float = 1.0<br class="">+return:<br class="">+  ret void<br class="">+}<br class="">_______________________________________________<br class="">llvm-commits mailing list<br class=""><a href="mailto:llvm-commits@lists.llvm.org" class="">llvm-commits@lists.llvm.org</a><br class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits<br class=""></blockquote><br style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">--<span class="Apple-converted-space"> </span></span><br style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Jon Roelofs</span><br style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="mailto:jonathan@codesourcery.com" style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">jonathan@codesourcery.com</a><br style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">CodeSourcery / Mentor Embedded / Siemens</span></div></blockquote></div><br class=""></body></html>