Skip to content

Commit 46caa45

Browse files
committed
Avoid AllocBoxToStack crash (TF-585).
Generate `fix_lifetime` instruction on `alloc_box` to avoid crash.
1 parent 3eb19ba commit 46caa45

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

lib/SILOptimizer/Mandatory/Differentiation.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3063,6 +3063,9 @@ class VJPEmitter final
30633063
auto *projectBox = builder.createProjectBox(loc, allocBox, /*index*/ 0);
30643064
builder.createStore(loc, pbStructVal, projectBox,
30653065
getBufferSOQ(projectBox->getType().getASTType(), *vjp));
3066+
// NOTE(TF-585): `fix_lifetime` is generated to avoid AllocBoxToStack crash
3067+
// for nested loop AD.
3068+
builder.createFixLifetime(loc, allocBox);
30663069
return builder.createEnum(loc, allocBox, enumEltDecl, enumLoweredTy);
30673070
}
30683071

0 commit comments

Comments
 (0)