@@ -286,7 +286,8 @@ class SILInlineCloner
286
286
void cloneInline (ArrayRef<SILValue> AppliedArgs);
287
287
288
288
protected:
289
- SILValue borrowFunctionArgument (SILValue callArg, FullApplySite AI);
289
+ SILValue borrowFunctionArgument (SILValue callArg, FullApplySite AI,
290
+ unsigned index);
290
291
291
292
void visitDebugValueInst (DebugValueInst *Inst);
292
293
void visitHopToExecutorInst (HopToExecutorInst *Inst);
@@ -466,7 +467,7 @@ void SILInlineCloner::cloneInline(ArrayRef<SILValue> AppliedArgs) {
466
467
} else {
467
468
// Insert begin/end borrow for guaranteed arguments.
468
469
if (paramInfo.isGuaranteed ()) {
469
- if (SILValue newValue = borrowFunctionArgument (callArg, Apply)) {
470
+ if (SILValue newValue = borrowFunctionArgument (callArg, Apply, idx )) {
470
471
callArg = newValue;
471
472
borrowedArgs[idx] = true ;
472
473
}
@@ -612,7 +613,8 @@ void SILInlineCloner::postFixUp(SILFunction *calleeFunction) {
612
613
}
613
614
614
615
SILValue SILInlineCloner::borrowFunctionArgument (SILValue callArg,
615
- FullApplySite AI) {
616
+ FullApplySite AI,
617
+ unsigned index) {
616
618
auto &mod = Apply.getFunction ()->getModule ();
617
619
auto enableLexicalLifetimes =
618
620
mod.getASTContext ().SILOpts .supportsLexicalLifetimes (mod);
@@ -631,9 +633,13 @@ SILValue SILInlineCloner::borrowFunctionArgument(SILValue callArg,
631
633
return SILValue ();
632
634
}
633
635
636
+ SILFunctionArgument *argument = cast<SILFunctionArgument>(
637
+ getCalleeFunction ()->getEntryBlock ()->getArgument (index));
638
+
634
639
SILBuilderWithScope beginBuilder (AI.getInstruction (), getBuilder ());
635
- return beginBuilder.createBeginBorrow (AI.getLoc (), callArg,
636
- /* isLexical=*/ enableLexicalLifetimes);
640
+ auto isLexical =
641
+ enableLexicalLifetimes && argument->getLifetime ().isLexical ();
642
+ return beginBuilder.createBeginBorrow (AI.getLoc (), callArg, isLexical);
637
643
}
638
644
639
645
void SILInlineCloner::visitDebugValueInst (DebugValueInst *Inst) {
0 commit comments