summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2017-12-08 22:42:43 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2017-12-08 22:42:43 +0000
commit9b8caf5bd796b25a8a6e457e7b0d73da8163633d (patch)
treea24cd137e5bec562dbe599894b0ce8f50b8a8f72 /llvm
parentcb96ac64b0c42081b7a9d40e95032c9dc2487d3e (diff)
downloadbcm5719-llvm-9b8caf5bd796b25a8a6e457e7b0d73da8163633d.tar.gz
bcm5719-llvm-9b8caf5bd796b25a8a6e457e7b0d73da8163633d.zip
Revert part of "Cleanup some GraphTraits iteration code"
This reverts part of r300656, which caused a regression in propagateMassToSuccessors by counting edges n^2 times, where n is the number of edges from the source basic block to the same successor basic block. The result was both incorrect and very slow to compute for large values of n (e.g. switches with multiple cases that go to the same basic block). Patch by Andrew Scheidecker! llvm-svn: 320208
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h9
-rw-r--r--llvm/test/Analysis/BlockFrequencyInfo/redundant_edges.ll22
2 files changed, 28 insertions, 3 deletions
diff --git a/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h b/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h
index 228934cb301..24295a2569f 100644
--- a/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h
+++ b/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h
@@ -1314,9 +1314,12 @@ BlockFrequencyInfoImpl<BT>::propagateMassToSuccessors(LoopData *OuterLoop,
return false;
} else {
const BlockT *BB = getBlock(Node);
- for (const auto Succ : children<const BlockT *>(BB))
- if (!addToDist(Dist, OuterLoop, Node, getNode(Succ),
- getWeightFromBranchProb(BPI->getEdgeProbability(BB, Succ))))
+ for (auto SI = GraphTraits<const BlockT *>::child_begin(BB),
+ SE = GraphTraits<const BlockT *>::child_end(BB);
+ SI != SE; ++SI)
+ if (!addToDist(
+ Dist, OuterLoop, Node, getNode(*SI),
+ getWeightFromBranchProb(BPI->getEdgeProbability(BB, SI))))
// Irreducible backedge.
return false;
}
diff --git a/llvm/test/Analysis/BlockFrequencyInfo/redundant_edges.ll b/llvm/test/Analysis/BlockFrequencyInfo/redundant_edges.ll
new file mode 100644
index 00000000000..20ed1406c5a
--- /dev/null
+++ b/llvm/test/Analysis/BlockFrequencyInfo/redundant_edges.ll
@@ -0,0 +1,22 @@
+; RUN: opt < %s -analyze -block-freq | FileCheck %s
+; RUN: opt < %s -analyze -lazy-block-freq | FileCheck %s
+; RUN: opt < %s -passes='print<block-freq>' -disable-output 2>&1 | FileCheck %s
+
+define void @test1() {
+; CHECK-LABEL: Printing analysis {{.*}} for function 'test1':
+; CHECK-NEXT: block-frequency-info: test1
+; CHECK-NEXT: entry: float = 1.0, int = [[ENTRY:[0-9]+]]
+entry:
+ br label %loop
+
+; CHECK-NEXT: loop: float = 32.0
+loop:
+ switch i32 undef, label %loop [
+ i32 0, label %return
+ i32 1, label %return
+ ]
+
+; CHECK-NEXT: return: float = 1.0
+return:
+ ret void
+}
OpenPOWER on IntegriCloud