File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
lib/SILOptimizer/Analysis Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -566,6 +566,17 @@ static SILValue getBeginScopeInst(SILValue V) {
566
566
if (BorrowedValue borrowedObj = getSingleBorrowIntroducingValue (object)) {
567
567
return borrowedObj.value ;
568
568
}
569
+ if (!object->getFunction ()->hasOwnership ()) {
570
+ // In non-OSSA, do a quick check if the object is a guaranteed function
571
+ // argument.
572
+ // Note that in OSSA, getSingleBorrowIntroducingValue will detect a
573
+ // guaranteed argument.
574
+ SILValue root = findOwnershipReferenceAggregate (object);
575
+ if (auto *funcArg = dyn_cast<SILFunctionArgument>(root)) {
576
+ if (funcArg->getArgumentConvention ().isGuaranteedConvention ())
577
+ return funcArg;
578
+ }
579
+ }
569
580
return SILValue ();
570
581
}
571
582
Original file line number Diff line number Diff line change @@ -618,6 +618,19 @@ bb0(%0 : @guaranteed $X):
618
618
return %3 : $Int32
619
619
}
620
620
621
+ // CHECK-LABEL: @testNonOSSAImmutableRefWithGuaranteedParam
622
+ // CHECK: PAIR #1.
623
+ // CHECK-NEXT: %4 = apply %3() : $@convention(thin) () -> ()
624
+ // CHECK-NEXT: %1 = ref_element_addr [immutable] %0 : $X, #X.a
625
+ // CHECK-NEXT: r=1,w=0
626
+ sil @testNonOSSAImmutableRefWithGuaranteedParam : $@convention(thin) (@guaranteed X) -> Int32 {
627
+ bb0(%0 : $X):
628
+ %1 = ref_element_addr [immutable] %0 : $X, #X.a
629
+ %3 = load %1 : $*Int32
630
+ %5 = function_ref @nouser_func : $@convention(thin) () -> ()
631
+ %6 = apply %5() : $@convention(thin) () -> ()
632
+ return %3 : $Int32
633
+ }
621
634
// CHECK-LABEL: @testImmutableRefWithBorrow
622
635
// CHECK: PAIR #1.
623
636
// CHECK-NEXT: %5 = apply %4() : $@convention(thin) () -> ()
You can’t perform that action at this time.
0 commit comments