Skip to content

Commit 447d9ee

Browse files
authored
Merge pull request #61957 from eeckstein/fix-arc-analysis
ARCAnalysis: fix `canApplyOfBuiltinUseNonTrivialValues`
2 parents fdababa + 02b8c4a commit 447d9ee

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

lib/SILOptimizer/Analysis/ARCAnalysis.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ static bool canApplyOfBuiltinUseNonTrivialValues(BuiltinInst *BInst) {
110110
return true;
111111
}
112112
}
113+
return false;
113114
}
114-
115-
return false;
115+
return true;
116116
}
117117

118118
auto &BI = BInst->getBuiltinInfo();

test/SILOptimizer/retain_release_code_motion.sil

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,28 @@ bb0(%0 : $_ContiguousArrayBuffer<AnyObject>, %1 : $Builtin.Word, %2 : $Builtin.W
820820
return %newptr : $Builtin.RawPointer
821821
}
822822

823+
// CHECK-RELEASE-HOISTING-LABEL: sil @testMemcpy
824+
// CHECK-RELEASE-HOISTING: bb0(%0 : $_ContiguousArrayBuffer<UInt64>, %1 : $Builtin.Word):
825+
// CHECK-RELEASE-HOISTING: builtin "int_memcpy_RawPointer_RawPointer_Word"
826+
// CHECK-RELEASE-HOISTING: release_value %0 : $_ContiguousArrayBuffer<UInt64>
827+
// CHECK-RELEASE-HOISTING: } // end sil function 'testMemcpy'
828+
sil @testMemcpy : $@convention(thin) (_ContiguousArrayBuffer<UInt64>, Builtin.Word) -> Builtin.RawPointer {
829+
bb0(%0 : $_ContiguousArrayBuffer<UInt64>, %1 : $Builtin.Word):
830+
%newptr = builtin "allocRaw"(%1 : $Builtin.Word, %1 : $Builtin.Word) : $Builtin.RawPointer
831+
%token = bind_memory %newptr : $Builtin.RawPointer, %1 : $Builtin.Word to $*UInt64
832+
%storage = struct_extract %0 : $_ContiguousArrayBuffer<UInt64>, #_ContiguousArrayBuffer._storage
833+
%elements = ref_tail_addr %storage : $__ContiguousArrayStorageBase, $UInt64
834+
%eltptr = address_to_pointer %elements : $*UInt64 to $Builtin.RawPointer
835+
%objptr = struct $UnsafePointer<UInt64> (%eltptr : $Builtin.RawPointer)
836+
%ptrdep = mark_dependence %objptr : $UnsafePointer<UInt64> on %storage : $__ContiguousArrayStorageBase
837+
%rawptr = struct_extract %ptrdep : $UnsafePointer<UInt64>, #UnsafePointer._rawValue
838+
%f = integer_literal $Builtin.Int1, 0
839+
%move = builtin "int_memcpy_RawPointer_RawPointer_Word"(%newptr : $Builtin.RawPointer, %rawptr : $Builtin.RawPointer, %1 : $Builtin.Word, %f : $Builtin.Int1) : $()
840+
release_value %0 : $_ContiguousArrayBuffer<UInt64>
841+
return %newptr : $Builtin.RawPointer
842+
}
843+
844+
823845
// CHECK-LABEL: sil @dontMoveOverExistentialToClassCast : $@convention(thin) (@guaranteed AnyObject) -> Optional<fuzz>
824846
// CHECK: strong_retain %0
825847
// CHECK: checked_cast_br %0

0 commit comments

Comments
 (0)