Skip to content

Commit 8934ca7

Browse files
committed
Revert "Update ConditionForwarding for @guaranteed forwarding phi support"
This reverts commit 4acfd4d.
1 parent e549392 commit 8934ca7

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

lib/SILOptimizer/Transforms/ConditionForwarding.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -202,14 +202,6 @@ bool ConditionForwarding::tryOptimize(SwitchEnumInst *SEI) {
202202
if (!EI)
203203
return false;
204204

205-
if (getFunction()->hasOwnership() && EI->hasOperand()) {
206-
auto some = EI->getOperand();
207-
if (some->getOwnershipKind() == OwnershipKind::Guaranteed &&
208-
isa<SILFunctionArgument>(some)) {
209-
return false;
210-
}
211-
}
212-
213205
if (CommonBranchBlock && PredPred != CommonBranchBlock)
214206
return false;
215207
CommonBranchBlock = PredPred;

test/SILOptimizer/conditionforwarding_nontrivial_ossa.sil

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ bb6:
7171
return %r : $()
7272
}
7373

74-
// Currently, this is not optimized away because enum has @guaranteed function
75-
// argument, which will need a borrow scope before being forwarded.
74+
// Currently, this is not optimized away because memory behavior of begin_borrow is conservative
7675
// CHECK-LABEL: sil [ossa] @simple_forwarding2 :
7776
// CHECK: switch_enum
7877
// CHECK-LABEL: } // end sil function 'simple_forwarding2'
@@ -82,11 +81,13 @@ bb0(%0 : $Builtin.Int1, %1 : @guaranteed $Klass):
8281

8382
bb1:
8483
%2 = enum $E, #E.A!enumelt, %1 : $Klass
85-
br bb3(%2 : $E)
84+
%borrow2 = begin_borrow %2 : $E
85+
br bb3(%borrow2 : $E)
8686

8787
bb2:
8888
%3 = enum $E, #E.B!enumelt, %1 : $Klass
89-
br bb3(%3 : $E)
89+
%borrow3 = begin_borrow %3 : $E
90+
br bb3(%borrow3 : $E)
9091

9192
bb3(%14 : @guaranteed $E):
9293
%15 = function_ref @callee : $@convention(thin) () -> ()
@@ -100,6 +101,7 @@ bb5(%18 : @guaranteed $Klass):
100101
br bb6
101102

102103
bb6:
104+
end_borrow %14 : $E
103105
%r = tuple ()
104106
return %r : $()
105107
}
@@ -185,19 +187,22 @@ bb6:
185187

186188
// CHECK-LABEL: sil [ossa] @simple_switch_enum_forwarding2 :
187189
// CHECK: switch_enum
190+
// CHECK: switch_enum
188191
// CHECK-LABEL: } // end sil function 'simple_switch_enum_forwarding2'
189192
sil [ossa] @simple_switch_enum_forwarding2 : $@convention(thin) (@guaranteed E3) -> () {
190193
bb0(%0 : @guaranteed $E3):
191194
switch_enum %0 : $E3, case #E3.A!enumelt: bb1, default bb2
192195

193196
bb1(%1 : @guaranteed $Klass):
194197
%2 = enum $E, #E.A!enumelt, %1 : $Klass
195-
br bb3(%2 : $E)
198+
%borrow2 = begin_borrow %2 : $E
199+
br bb3(%borrow2 : $E)
196200

197201
bb2(%defaultenum : @guaranteed $E3):
198202
%defaultklass = unchecked_enum_data %defaultenum : $E3, #E3.B!enumelt
199203
%3 = enum $E, #E.B!enumelt, %defaultklass : $Klass
200-
br bb3(%3 : $E)
204+
%borrow3 = begin_borrow %3 : $E
205+
br bb3(%borrow3 : $E)
201206

202207
bb3(%14 : @guaranteed $E):
203208
%15 = function_ref @callee : $@convention(thin) () -> ()
@@ -211,6 +216,7 @@ bb5(%5 : @guaranteed $Klass):
211216
br bb6
212217

213218
bb6:
219+
end_borrow %14 : $E
214220
%r = tuple ()
215221
return %r : $()
216222
}

0 commit comments

Comments
 (0)