Skip to content

Commit cedaed1

Browse files
committed
Fix an assertion in DiagnostStaticExclusivity and add a .sil test.
This is a same-day fix for a typo introduced here: commit c2c55ee Author: Andrew Trick <[email protected]> Date: Wed Jun 21 16:08:06 2017 AccessSummaryAnalysis: handle @convention(block) in nested nonescape closures.
1 parent 6c8d210 commit cedaed1

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

lib/SILOptimizer/Analysis/AccessSummaryAnalysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ static bool hasExpectedUsesOfNoEscapePartialApply(SILInstruction *closure) {
145145
return hasExpectedUsesOfNoEscapePartialApply(user);
146146

147147
case ValueKind::PartialApplyInst:
148-
return closure != cast<PartialApplyInst>(closure)->getCallee();
148+
return closure != cast<PartialApplyInst>(user)->getCallee();
149149

150150
case ValueKind::StoreInst:
151151
case ValueKind::DestroyValueInst:

test/SILOptimizer/access_summary_analysis.sil

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,31 @@ bb0(%0 : $*Int):
228228
return %8 : $()
229229
}
230230

231+
// CHECK-LABEL: @reads
232+
// CHECK-NEXT: (read)
233+
sil private @reads : $@convention(thin) (@inout_aliasable Int) -> Int {
234+
bb0(%0 : $*Int):
235+
%3 = begin_access [read] [unknown] %0 : $*Int
236+
%4 = load %3 : $*Int
237+
end_access %3 : $*Int
238+
return %4 : $Int
239+
}
240+
241+
// CHECK-LABEL: @convertPartialApplyAndPassToPartialApply
242+
// CHECK-NEXT: (read)
243+
sil hidden @convertPartialApplyAndPassToPartialApply : $@convention(thin) (@inout_aliasable Int) -> () {
244+
bb0(%0 : $*Int):
245+
%2 = function_ref @takesAutoClosureReturningGeneric : $@convention(thin) <τ_0_0 where τ_0_0 : Equatable> (@owned @callee_owned () -> (@out τ_0_0, @error Error)) -> ()
246+
%3 = function_ref @reads : $@convention(thin) (@inout_aliasable Int) -> Int
247+
%4 = partial_apply %3(%0) : $@convention(thin) (@inout_aliasable Int) -> Int
248+
%5 = convert_function %4 : $@callee_owned () -> Int to $@callee_owned () -> (Int, @error Error)
249+
%6 = function_ref @thunkForAutoClosure : $@convention(thin) (@owned @callee_owned () -> (Int, @error Error)) -> (@out Int, @error Error)
250+
%7 = partial_apply %6(%5) : $@convention(thin) (@owned @callee_owned () -> (Int, @error Error)) -> (@out Int, @error Error)
251+
%8 = apply %2<Int>(%7) : $@convention(thin) <τ_0_0 where τ_0_0 : Equatable> (@owned @callee_owned () -> (@out τ_0_0, @error Error)) -> ()
252+
%9 = tuple ()
253+
return %9 : $()
254+
}
255+
231256
// CHECK-LABEL: @selfRecursion
232257
// CHECK-NEXT: (modify, none)
233258
sil private @selfRecursion : $@convention(thin) (@inout_aliasable Int, Int) -> () {

0 commit comments

Comments
 (0)