Skip to content

Commit aee95e6

Browse files
authored
Merge pull request #34327 from gottesmm/release/5.3/rdar70356725
[temp-rvalue-opt] Disable handling of load [take] in temp-rvalue-elim.
2 parents 1ace546 + d0b0600 commit aee95e6

File tree

2 files changed

+17
-39
lines changed

2 files changed

+17
-39
lines changed

lib/SILOptimizer/Transforms/TempRValueElimination.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ bool TempRValueOptPass::tryOptimizeCopyIntoTemp(CopyAddrInst *copyInst) {
481481
// our base, we fail since those would be re-initializations.
482482
if (auto *li = dyn_cast<LoadInst>(user)) {
483483
if (li->getOwnershipQualifier() == LoadOwnershipQualifier::Take) {
484-
continue;
484+
return false;
485485
}
486486
}
487487

@@ -621,7 +621,7 @@ TempRValueOptPass::tryOptimizeStoreIntoTemp(StoreInst *si) {
621621
// our base, we fail since those would be re-initializations.
622622
if (auto *li = dyn_cast<LoadInst>(user)) {
623623
if (li->getOwnershipQualifier() == LoadOwnershipQualifier::Take) {
624-
continue;
624+
return {std::next(si->getIterator()), false};
625625
}
626626
}
627627

test/SILOptimizer/temp_rvalue_opt_ossa.sil

Lines changed: 15 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -610,15 +610,12 @@ bb3:
610610

611611
sil [ossa] @takeGuaranteedObj : $@convention(thin) (@guaranteed Builtin.NativeObject) -> ()
612612

613-
// Now that we support ossa, eliminate the alloc_stack and change the load
614-
// [take] to a load [copy] in the process.
613+
// We do not support this in 5.3.
615614
//
616615
// CHECK-LABEL: sil [ossa] @copyWithLoadRelease : $@convention(thin) (@in_guaranteed Builtin.NativeObject) -> () {
617616
// CHECK: bb0(%0 : $*Builtin.NativeObject):
618-
// CHECK-NOT: alloc_stack
619-
// CHECK: [[VAL:%.*]] = load [copy] %0 : $*Builtin.NativeObject
620-
// CHECK: apply %{{.*}}([[VAL]]) : $@convention(thin) (@guaranteed Builtin.NativeObject) -> ()
621-
// CHECK: destroy_value [[VAL]] : $Builtin.NativeObject
617+
// CHECK: alloc_stack
618+
// CHECK: load [take]
622619
// CHECK-LABEL: } // end sil function 'copyWithLoadRelease'
623620
sil [ossa] @copyWithLoadRelease : $@convention(thin) (@in_guaranteed Builtin.NativeObject) -> () {
624621
bb0(%0 : $*Builtin.NativeObject):
@@ -633,14 +630,11 @@ bb0(%0 : $*Builtin.NativeObject):
633630
return %v : $()
634631
}
635632

636-
// Remove a copy that is released via a load. Leave the load [take] alone since
637-
// our copy_addr is taking from source.
633+
// We do not support this in 5.3.
638634
//
639635
// CHECK-LABEL: sil [ossa] @takeWithLoadRelease : $@convention(thin) (@in Builtin.NativeObject) -> () {
640636
// CHECK: bb0(%0 : $*Builtin.NativeObject):
641-
// CHECK: [[V:%.*]] = load [take] %0 : $*Builtin.NativeObject
642-
// CHECK: apply %{{.*}}([[V]]) : $@convention(thin) (@guaranteed Builtin.NativeObject) -> ()
643-
// CHECK: destroy_value [[V]] : $Builtin.NativeObject
637+
// CHECK: alloc_stack
644638
// CHECK-LABEL: } // end sil function 'takeWithLoadRelease'
645639
sil [ossa] @takeWithLoadRelease : $@convention(thin) (@in Builtin.NativeObject) -> () {
646640
bb0(%0 : $*Builtin.NativeObject):
@@ -675,12 +669,11 @@ bb0(%0 : $*GS<Builtin.NativeObject>):
675669
return %v : $()
676670
}
677671

678-
// Make sure that when we convert the load [take] to a load [copy], we hoist the
679-
// load of src /before/ the destroy of %0.
672+
// We do not support this on 5.3.
673+
//
680674
// CHECK-LABEL: sil [ossa] @hoist_load_copy_to_src_copy_addr_site : $@convention(thin) (@owned GS<Builtin.NativeObject>) -> @owned GS<Builtin.NativeObject> {
681675
// CHECK: bb0([[ARG:%.*]] : @owned
682-
// CHECK: apply {{%.*}}([[ARG]])
683-
// CHECK: return [[ARG]]
676+
// CHECK: alloc_stack
684677
// CHECK: } // end sil function 'hoist_load_copy_to_src_copy_addr_site'
685678
sil [ossa] @hoist_load_copy_to_src_copy_addr_site : $@convention(thin) (@owned GS<Builtin.NativeObject>) -> @owned GS<Builtin.NativeObject> {
686679
bb0(%0 : @owned $GS<Builtin.NativeObject>):
@@ -693,24 +686,11 @@ bb0(%0 : @owned $GS<Builtin.NativeObject>):
693686
return %obj : $GS<Builtin.NativeObject>
694687
}
695688

689+
// We do not support this on 5.3.
690+
//
696691
// CHECK-LABEL: sil [ossa] @hoist_load_copy_to_src_copy_addr_site_two_takes : $@convention(thin) (@in GS<Builtin.NativeObject>) -> @owned GS<Builtin.NativeObject> {
697692
// CHECK: bb0([[ARG:%.*]] :
698-
// CHECK: [[COPY_1:%.*]] = load [copy] [[ARG]]
699-
// CHECK: [[COPY_2:%.*]] = load [copy] [[ARG]]
700-
// CHECK: destroy_addr [[ARG]]
701-
// CHECK: cond_br undef, bb1, bb2
702-
//
703-
// CHECK: bb1:
704-
// CHECK: destroy_value [[COPY_1]]
705-
// CHECK: br bb3([[COPY_2]] :
706-
//
707-
// CHECK: bb2:
708-
// CHECK: destroy_value [[COPY_2]]
709-
// CHECK: br bb3([[COPY_1]] :
710-
//
711-
// CHECK: bb3([[RESULT:%.*]] : @owned
712-
// CHECK: apply {{%.*}}([[RESULT]])
713-
// CHECK: return [[RESULT]]
693+
// CHECK: alloc_stack
714694
// CHECK: } // end sil function 'hoist_load_copy_to_src_copy_addr_site_two_takes'
715695
sil [ossa] @hoist_load_copy_to_src_copy_addr_site_two_takes : $@convention(thin) (@in GS<Builtin.NativeObject>) -> @owned GS<Builtin.NativeObject> {
716696
bb0(%0 : $*GS<Builtin.NativeObject>):
@@ -1016,12 +996,11 @@ bb0(%0 : $*Klass):
1016996
sil [ossa] @store_getP : $@convention(thin) () -> @out Optional<P>
1017997
sil [ossa] @store_takeGuaranteedObj : $@convention(thin) (@guaranteed Builtin.NativeObject) -> ()
1018998

1019-
// Now that we support ossa, eliminate the alloc_stack and change the load
1020-
// [take] to a load [copy] in the process.
999+
// We do not support this on 5.3.
10211000
//
10221001
// CHECK-LABEL: sil [ossa] @store_copyWithLoadRelease : $@convention(thin) (@guaranteed Builtin.NativeObject) -> () {
10231002
// CHECK: bb0(%0 : @guaranteed $Builtin.NativeObject):
1024-
// CHECK-NOT: alloc_stack
1003+
// CHECK: alloc_stack
10251004
// CHECK-LABEL: } // end sil function 'store_copyWithLoadRelease'
10261005
sil [ossa] @store_copyWithLoadRelease : $@convention(thin) (@guaranteed Builtin.NativeObject) -> () {
10271006
bb0(%0 : @guaranteed $Builtin.NativeObject):
@@ -1037,11 +1016,10 @@ bb0(%0 : @guaranteed $Builtin.NativeObject):
10371016
return %v : $()
10381017
}
10391018

1040-
// Remove a copy that is released via a load. Leave the load [take] alone since
1041-
// our copy_addr is taking from source.
1019+
// We do not support this on 5.3.
10421020
//
10431021
// CHECK-LABEL: sil [ossa] @store_takeWithLoadRelease : $@convention(thin) (@owned Builtin.NativeObject) -> () {
1044-
// CHECK-NOT: alloc_stack
1022+
// CHECK: alloc_stack
10451023
// CHECK-LABEL: } // end sil function 'store_takeWithLoadRelease'
10461024
sil [ossa] @store_takeWithLoadRelease : $@convention(thin) (@owned Builtin.NativeObject) -> () {
10471025
bb0(%0 : @owned $Builtin.NativeObject):

0 commit comments

Comments
 (0)