File tree Expand file tree Collapse file tree 2 files changed +23
-5
lines changed
lib/SILOptimizer/Mandatory Expand file tree Collapse file tree 2 files changed +23
-5
lines changed Original file line number Diff line number Diff line change @@ -725,6 +725,9 @@ static SILValue tryRewriteToPartialApplyStack(
725725
726726 SmallSetVector<SILValue, 4 > borrowedOriginals;
727727
728+ unsigned appliedArgStartIdx =
729+ newPA->getOrigCalleeType ()->getNumParameters () - newPA->getNumArguments ();
730+
728731 for (unsigned i : indices (newPA->getArgumentOperands ())) {
729732 auto &arg = newPA->getArgumentOperands ()[i];
730733 SILValue copy = arg.get ();
@@ -747,11 +750,12 @@ static SILValue tryRewriteToPartialApplyStack(
747750 }
748751
749752 // Is the capture a borrow?
750- auto paramIndex = newPA
751- ->getArgumentIndexForOperandIndex (i + newPA->getArgumentOperandNumber ())
752- .value ();
753- if (!newPA->getOrigCalleeType ()->getParameters ()[paramIndex]
754- .isIndirectInGuaranteed ()) {
753+
754+ auto paramIndex = i + appliedArgStartIdx;
755+ auto param = newPA->getOrigCalleeType ()->getParameters ()[paramIndex];
756+ LLVM_DEBUG (param.print (llvm::dbgs ());
757+ llvm::dbgs () << ' \n ' );
758+ if (!param.isIndirectInGuaranteed ()) {
755759 LLVM_DEBUG (llvm::dbgs () << " -- not an in_guaranteed parameter\n " ;
756760 newPA->getOrigCalleeType ()->getParameters ()[paramIndex]
757761 .print (llvm::dbgs ());
Original file line number Diff line number Diff line change @@ -17,6 +17,8 @@ struct M {
1717#else
1818 private var x : Int = 0
1919#endif
20+
21+ borrowing func borrow( ) { }
2022}
2123
2224func borrow( _: borrowing M ) { }
@@ -156,6 +158,18 @@ func p(x: inout M) {
156158 clodger ( { consume ( x) ; x = M ( ) } )
157159}
158160
161+ func takesClosureWithArg( _: ( Int ) -> ( ) ) { }
162+
163+ func invokesWithClosureWithArg( ) {
164+ let m = M ( )
165+
166+ takesClosureWithArg { _ in
167+ m. borrow ( )
168+ }
169+
170+ m. borrow ( )
171+ }
172+
159173// need test cases for:
160174// - capturing local let
161175// - capturing local var
You can’t perform that action at this time.
0 commit comments