Skip to content

Commit f2de002

Browse files
authored
Merge pull request #14037 from eeckstein/fix-ea-4.1
[4.1] EscapeAnalysis: update use-points for nodes which are created on dema…
2 parents aad14e3 + b06eb31 commit f2de002

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

lib/SILOptimizer/Analysis/EscapeAnalysis.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,8 @@ updatePointsTo(CGNode *InitialNode, CGNode *pointsTo) {
295295
} else {
296296
Node->pointsTo = pointsTo;
297297
}
298+
// Update use-points if the use-point information is already calculated.
299+
pointsTo->mergeUsePoints(Node);
298300
}
299301

300302
// Add all adjacent nodes to the WorkList.

test/SILOptimizer/licm.sil

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,3 +268,51 @@ bb2:
268268
%52 = tuple ()
269269
return %52 : $()
270270
}
271+
272+
273+
sil @get_unknown_value : $@convention(thin) () -> Builtin.Int32
274+
sil @get_unknown_value2 : $@convention(thin) () -> Builtin.Int32
275+
276+
sil @callee : $@convention(thin) (@inout Builtin.Int32) -> () {
277+
bb0(%0 : $*Builtin.Int32):
278+
%1 = function_ref @get_unknown_value : $@convention(thin) () -> Builtin.Int32
279+
%2 = apply %1() : $@convention(thin) () -> Builtin.Int32
280+
store %2 to %0 : $*Builtin.Int32
281+
%9999 = tuple()
282+
return %9999 : $()
283+
}
284+
285+
sil @use_value : $@convention(thin) (Builtin.Int32) -> ()
286+
287+
// Check if escape analysis figures out that the alloc_stack escapes to callee.
288+
//
289+
// CHECK-LABEL: sil @dont_hoist_aliased_load
290+
// CHECK: bb2:
291+
// CHECK-NEXT: apply
292+
// CHECK-NEXT: load
293+
// CHECK-NEXT: apply
294+
sil @dont_hoist_aliased_load : $@convention(thin) () -> () {
295+
bb0:
296+
%0 = alloc_stack $Builtin.Int32
297+
%1 = integer_literal $Builtin.Int32, 0
298+
%3 = function_ref @callee : $@convention(thin) (@inout Builtin.Int32) -> ()
299+
%5 = function_ref @use_value : $@convention(thin) (Builtin.Int32) -> ()
300+
%unknown_value_fn = function_ref @get_unknown_value2 : $@convention(thin) () -> Builtin.Int32
301+
store %1 to %0 : $*Builtin.Int32
302+
br bb1(%0 : $*Builtin.Int32)
303+
304+
bb1(%phi1 : $*Builtin.Int32):
305+
br bb2
306+
307+
bb2:
308+
apply %3(%0) : $@convention(thin) (@inout Builtin.Int32) -> ()
309+
%4 = load %phi1 : $*Builtin.Int32
310+
%6 = apply %unknown_value_fn() : $@convention(thin) () -> Builtin.Int32
311+
%33 = builtin "cmp_eq_Int32"(%4 : $Builtin.Int32, %6 : $Builtin.Int32) : $Builtin.Int1
312+
cond_br %33, bb2, bb3
313+
314+
bb3:
315+
%9999 = tuple()
316+
dealloc_stack %0 : $*Builtin.Int32
317+
return %9999 : $()
318+
}

0 commit comments

Comments
 (0)