Skip to content

Commit ecca144

Browse files
Merge pull request #70773 from nate-chandler/rdar120656227
[SIL] Builtins that read or write memory may access pointers.
2 parents b46adbb + a00bb27 commit ecca144

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

lib/SIL/Utils/MemAccessUtils.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,10 @@ bool swift::isLetAddress(SILValue address) {
439439
bool swift::mayAccessPointer(SILInstruction *instruction) {
440440
if (!instruction->mayReadOrWriteMemory())
441441
return false;
442+
if (isa<BuiltinInst>(instruction)) {
443+
// Consider all builtins that read/write memory to access pointers.
444+
return true;
445+
}
442446
bool retval = false;
443447
visitAccessedAddress(instruction, [&retval](Operand *operand) {
444448
auto accessStorage = AccessStorage::compute(operand->get());

test/SILOptimizer/deinit_barrier.sil

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,18 @@ entry:
139139
%retval = tuple ()
140140
return %retval : $()
141141
}
142+
143+
// CHECK-LABEL: begin running test {{.*}} on rdar120656227: is-deinit-barrier
144+
// CHECK: builtin "int_memmove_RawPointer_RawPointer_Int64"
145+
// CHECK: true
146+
// CHECK-LABEL: end running test {{.*}} on rdar120656227: is-deinit-barrier
147+
sil [ossa] @rdar120656227 : $@convention(thin) (Builtin.RawPointer, Builtin.RawPointer) -> () {
148+
bb0(%42 : $Builtin.RawPointer, %9 : $Builtin.RawPointer):
149+
%14 = integer_literal $Builtin.Int64, 27
150+
%28 = integer_literal $Builtin.Int1, 1
151+
specify_test "is-deinit-barrier @instruction"
152+
%43 = builtin "int_memmove_RawPointer_RawPointer_Int64"(%42 : $Builtin.RawPointer, %9 : $Builtin.RawPointer, %14 : $Builtin.Int64, %28 : $Builtin.Int1) : $()
153+
%68 = tuple ()
154+
return %68 : $()
155+
}
156+

0 commit comments

Comments
 (0)