File tree Expand file tree Collapse file tree 4 files changed +46
-11
lines changed
lib/SILOptimizer/Analysis Expand file tree Collapse file tree 4 files changed +46
-11
lines changed Original file line number Diff line number Diff line change @@ -215,11 +215,7 @@ class MemoryBehaviorVisitor
215
215
SIMPLE_MEMBEHAVIOR_INST (CondFailInst, None)
216
216
#undef SIMPLE_MEMBEHAVIOR_INST
217
217
218
- // If we are asked to treat ref count increments as being inert, return None
219
- // for these.
220
- //
221
- // FIXME: Once we separate the notion of ref counts from reading/writing
222
- // memory this will be unnecessary.
218
+ // Incrementing reference counts doesn't have an observable memory effect.
223
219
#define REFCOUNTINC_MEMBEHAVIOR_INST (Name ) \
224
220
MemBehavior visit##Name(Name *I) { \
225
221
return MemBehavior::None; \
@@ -455,7 +451,7 @@ MemBehavior MemoryBehaviorVisitor::getApplyBehavior(FullApplySite AS) {
455
451
behavior = MemBehavior::MayRead;
456
452
457
453
// Ask escape analysis.
458
- if (!nonEscapingAddress && ! EA->canEscapeTo (V, AS))
454
+ if (!EA->canEscapeTo (V, AS))
459
455
behavior = MemBehavior::None;
460
456
}
461
457
LLVM_DEBUG (llvm::dbgs () << " Found apply, returning " << behavior << ' \n ' );
Original file line number Diff line number Diff line change @@ -222,11 +222,6 @@ FunctionSideEffects::getMemBehavior(RetainObserveKind ScanKind) const {
222
222
MemoryBehavior
223
223
FunctionSideEffects::getArgumentBehavior (FullApplySite applySite,
224
224
unsigned argIdx) {
225
- // Rule out trivial non-address argument types.
226
- SILType argType = applySite.getArgument (argIdx)->getType ();
227
- if (!argType.isAddress () && argType.isTrivial (*applySite.getFunction ()))
228
- return MemoryBehavior::None;
229
-
230
225
// The overall argument effect is the combination of the argument and the
231
226
// global effects.
232
227
MemoryBehavior behavior =
Original file line number Diff line number Diff line change @@ -469,6 +469,28 @@ bb3:
469
469
return %9999 : $()
470
470
}
471
471
472
+ sil @read_from_raw_pointer : $@convention(thin) (Builtin.RawPointer) -> UInt8 {
473
+ bb0(%0 : $Builtin.RawPointer):
474
+ %1 = pointer_to_address %0 : $Builtin.RawPointer to [strict] $*UInt8
475
+ %2 = load %1 : $*UInt8
476
+ return %2 : $UInt8
477
+ }
478
+
479
+ // CHECK-LABEL: sil @dont_remove_store_to_escaping_allocstack_to_known_function : $@convention(thin) (UInt8) -> UInt8
480
+ // CHECK: alloc_stack
481
+ // CHECK-NEXT: store
482
+ // CHECK: } // end sil function 'dont_remove_store_to_escaping_allocstack_to_known_function'
483
+ sil @dont_remove_store_to_escaping_allocstack_to_known_function : $@convention(thin) (UInt8) -> UInt8 {
484
+ bb0(%0 : $UInt8):
485
+ %1 = alloc_stack $UInt8
486
+ store %0 to %1 : $*UInt8
487
+ %3 = address_to_pointer %1 : $*UInt8 to $Builtin.RawPointer
488
+ %4 = function_ref @read_from_raw_pointer : $@convention(thin) (Builtin.RawPointer) -> UInt8
489
+ %5 = apply %4(%3) : $@convention(thin) (Builtin.RawPointer) -> UInt8
490
+ dealloc_stack %1 : $*UInt8
491
+ return %5 : $UInt8
492
+ }
493
+
472
494
sil @unknown : $@convention(thin) () -> ()
473
495
474
496
// CHECK-LABEL: sil @inout_is_not_aliasing : $@convention(thin) (@inout Builtin.Int32) -> () {
Original file line number Diff line number Diff line change @@ -35,6 +35,13 @@ bb0(%0 : $X):
35
35
return %r : $()
36
36
}
37
37
38
+ sil @read_from_raw_pointer : $@convention(thin) (Builtin.RawPointer) -> UInt8 {
39
+ bb0(%0 : $Builtin.RawPointer):
40
+ %1 = pointer_to_address %0 : $Builtin.RawPointer to [strict] $*UInt8
41
+ %2 = load %1 : $*UInt8
42
+ return %2 : $UInt8
43
+ }
44
+
38
45
// CHECK-LABEL: @call_unknown_func
39
46
// CHECK: PAIR #1.
40
47
// CHECK-NEXT: %4 = apply %3(%0, %1) : $@convention(thin) (Int32, @in Int32) -> ()
@@ -224,6 +231,21 @@ bb0(%0 : $*Int32):
224
231
return %5 : $Int32
225
232
}
226
233
234
+ // CHECK-LABEL: @escaping_allocstack_to_known_function
235
+ // CHECK: PAIR #1.
236
+ // CHECK-NEXT: %5 = apply %4(%3) : $@convention(thin) (Builtin.RawPointer) -> UInt8 // user: %7
237
+ // CHECK-NEXT: %1 = alloc_stack $UInt8 // users: %6, %3, %2
238
+ // CHECK-NEXT: r=1,w=0
239
+ sil @escaping_allocstack_to_known_function : $@convention(thin) (UInt8) -> UInt8 {
240
+ bb0(%0 : $UInt8):
241
+ %1 = alloc_stack $UInt8
242
+ store %0 to %1 : $*UInt8
243
+ %3 = address_to_pointer %1 : $*UInt8 to $Builtin.RawPointer
244
+ %4 = function_ref @read_from_raw_pointer : $@convention(thin) (Builtin.RawPointer) -> UInt8
245
+ %5 = apply %4(%3) : $@convention(thin) (Builtin.RawPointer) -> UInt8
246
+ dealloc_stack %1 : $*UInt8
247
+ return %5 : $UInt8
248
+ }
227
249
228
250
// CHECK-LABEL: @tryapply_allocstack_and_copyaddr
229
251
// CHECK: PAIR #0.
You can’t perform that action at this time.
0 commit comments