Skip to content

Commit cba5872

Browse files
committed
[CFGMST] Remove special case for entry block with no successors
This breaks in the case where there are unreachable blocks after an entry block with no successors, which don't get visited in CFGMST, causing crashes. Fixes #135828.
1 parent 11db128 commit cba5872

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

llvm/include/llvm/Transforms/Instrumentation/CFGMST.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,6 @@ template <class Edge, class BBInfo> class CFGMST {
133133
LLVM_DEBUG(dbgs() << " Edge: from fake node to " << Entry->getName()
134134
<< " w = " << EntryWeight << "\n");
135135

136-
// Special handling for single BB functions.
137-
if (succ_empty(Entry)) {
138-
addEdge(Entry, nullptr, EntryWeight);
139-
return;
140-
}
141-
142136
static const uint32_t CriticalEdgeMultiplier = 1000;
143137

144138
for (BasicBlock &BB : F) {
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# IR level Instrumentation Flag
2+
:ir
3+
foo
4+
# Func Hash:
5+
742261418966908927
6+
# Num Counters:
7+
1
8+
# Counter Values:
9+
1
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
; RUN: llvm-profdata merge %S/Inputs/unreachable-block.proftext -o %t.profdata
2+
; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.profdata -S
3+
4+
declare ptr @bar()
5+
6+
define ptr @foo() {
7+
entry:
8+
ret ptr null
9+
10+
2:
11+
ret ptr null
12+
}

0 commit comments

Comments
 (0)