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(
725
725
726
726
SmallSetVector<SILValue, 4 > borrowedOriginals;
727
727
728
+ unsigned appliedArgStartIdx =
729
+ newPA->getOrigCalleeType ()->getNumParameters () - newPA->getNumArguments ();
730
+
728
731
for (unsigned i : indices (newPA->getArgumentOperands ())) {
729
732
auto &arg = newPA->getArgumentOperands ()[i];
730
733
SILValue copy = arg.get ();
@@ -747,11 +750,12 @@ static SILValue tryRewriteToPartialApplyStack(
747
750
}
748
751
749
752
// 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 ()) {
755
759
LLVM_DEBUG (llvm::dbgs () << " -- not an in_guaranteed parameter\n " ;
756
760
newPA->getOrigCalleeType ()->getParameters ()[paramIndex]
757
761
.print (llvm::dbgs ());
Original file line number Diff line number Diff line change @@ -17,6 +17,8 @@ struct M {
17
17
#else
18
18
private var x : Int = 0
19
19
#endif
20
+
21
+ borrowing func borrow( ) { }
20
22
}
21
23
22
24
func borrow( _: borrowing M ) { }
@@ -156,6 +158,18 @@ func p(x: inout M) {
156
158
clodger ( { consume ( x) ; x = M ( ) } )
157
159
}
158
160
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
+
159
173
// need test cases for:
160
174
// - capturing local let
161
175
// - capturing local var
You can’t perform that action at this time.
0 commit comments