Skip to content

Commit e684d43

Browse files
authored
Merge pull request #34496 from atrick/silopt-critedge-flag
2 parents b03d246 + c0cad96 commit e684d43

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

lib/SIL/Verifier/SILVerifier.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ static llvm::cl::opt<bool> VerifyDIHoles(
6565
static llvm::cl::opt<bool> SkipConvertEscapeToNoescapeAttributes(
6666
"verify-skip-convert-escape-to-noescape-attributes", llvm::cl::init(false));
6767

68+
// Allow unit tests to gradually migrate toward -allow-critical-edges=false.
69+
static llvm::cl::opt<bool> AllowCriticalEdges("allow-critical-edges",
70+
llvm::cl::init(true));
71+
6872
// The verifier is basically all assertions, so don't compile it with NDEBUG to
6973
// prevent release builds from triggering spurious unused variable warnings.
7074

@@ -5147,7 +5151,7 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
51475151
}
51485152

51495153
void verifyBranches(const SILFunction *F) {
5150-
// Verify that there is no non_condbr critical edge.
5154+
// Verify no critical edge.
51515155
auto isCriticalEdgePred = [](const TermInst *T, unsigned EdgeIdx) {
51525156
assert(T->getSuccessors().size() > EdgeIdx && "Not enough successors");
51535157

@@ -5170,10 +5174,11 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
51705174
const TermInst *TI = BB.getTerminator();
51715175
CurInstruction = TI;
51725176

5173-
// Check for non-cond_br critical edges.
5174-
if (isa<CondBranchInst>(TI)) {
5177+
// FIXME: In OSSA, critical edges will never be allowed.
5178+
// In Lowered SIL, they are allowed on unconditional branches only.
5179+
// if (!(isSILOwnershipEnabled() && F->hasOwnership()))
5180+
if (AllowCriticalEdges && isa<CondBranchInst>(TI))
51755181
continue;
5176-
}
51775182

51785183
for (unsigned Idx = 0, e = BB.getSuccessors().size(); Idx != e; ++Idx) {
51795184
require(!isCriticalEdgePred(TI, Idx),

test/SILOptimizer/copyforward_ossa.sil

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-sil-opt -enable-sil-verify-all %s -copy-forwarding -enable-copyforwarding -enable-destroyhoisting | %FileCheck %s
1+
// RUN: %target-sil-opt -enable-sil-verify-all %s -copy-forwarding -enable-copyforwarding -enable-destroyhoisting -allow-critical-edges=false | %FileCheck %s
22

33
// This is the ossa version of CopyForwarding tests
44
sil_stage raw
@@ -209,9 +209,12 @@ bb1: // Preds: bb0
209209
copy_addr %0 to [initialization] %5 : $*T // id: %6
210210
%7 = apply %4<T>(%5) : $@convention(thin) <τ_0_0> (@in τ_0_0) -> ()
211211
dealloc_stack %5 : $*T // id: %8
212-
br bb2 // id: %9
212+
br bb3 // id: %9
213213

214-
bb2: // Preds: bb0 bb1
214+
bb2:
215+
br bb3
216+
217+
bb3: // Preds: bb0 bb1
215218
destroy_addr %0 : $*T // id: %10
216219
%11 = tuple () // user: %12
217220
return %11 : $() // id: %12

0 commit comments

Comments
 (0)