Skip to content

Commit 580ca72

Browse files
committed
[silgen] Always ensure that we have a +1 value when emitting reabstraction thunks.
The machinery assumes that it will always have a +1 value. I am attempting to do the minimal fix here for cherry-picking purposes. There isn't a test case with this commit since the immutable address verifier (in the next commit) verifies that this is done correctly. The specific test that will trip is vtable_thunks_reabstraction.swift. rdar://50212579
1 parent 7ba9d65 commit 580ca72

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lib/SILGen/SILGenPoly.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,9 +1116,18 @@ namespace {
11161116

11171117
// Load if necessary.
11181118
if (elt.getType().isAddress()) {
1119+
// This code assumes that we have each element at +1. So, if we do
1120+
// not have a cleanup, we emit a load [copy]. This can occur if we
1121+
// are translating in_guaranteed parameters.
1122+
IsTake_t isTakeVal = ([&] {
1123+
if (elt.isPlusZero()) {
1124+
return IsNotTake;
1125+
}
1126+
return IsTake;
1127+
}());
11191128
elt = SGF.emitLoad(Loc, elt.forward(SGF),
1120-
SGF.getTypeLowering(elt.getType()),
1121-
SGFContext(), IsTake);
1129+
SGF.getTypeLowering(elt.getType()), SGFContext(),
1130+
isTakeVal);
11221131
}
11231132
}
11241133

0 commit comments

Comments
 (0)