Skip to content

Commit ca48f14

Browse files
committed
SILGen: Add ArgumentSource::getAsSingleValue() variant with re-abstraction
This matches the two forms of SILGen::forwardInto(). NFC
1 parent 33b83e2 commit ca48f14

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

lib/SILGen/ArgumentSource.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,18 @@ ManagedValue ArgumentSource::getAsSingleValue(SILGenFunction &gen,
7878
}
7979
}
8080

81+
82+
ManagedValue ArgumentSource::getAsSingleValue(SILGenFunction &gen,
83+
AbstractionPattern origFormalType,
84+
SGFContext C) && {
85+
auto loc = getLocation();
86+
auto substFormalType = getSubstType();
87+
ManagedValue outputValue = std::move(*this).getAsSingleValue(gen);
88+
return gen.emitSubstToOrigValue(loc,
89+
outputValue, origFormalType,
90+
substFormalType, C);
91+
}
92+
8193
void ArgumentSource::forwardInto(SILGenFunction &gen, Initialization *dest) && {
8294
assert(!isLValue());
8395
if (isRValue()) {
@@ -152,12 +164,10 @@ void ArgumentSource::forwardInto(SILGenFunction &SGF,
152164

153165
// Otherwise, emit as a single independent value.
154166
SILLocation loc = getLocation();
155-
ManagedValue inputValue = std::move(*this).getAsSingleValue(SGF);
156-
157-
// Reabstract.
158167
ManagedValue outputValue =
159-
SGF.emitSubstToOrigValue(loc, inputValue, origFormalType,
160-
substFormalType, SGFContext(dest));
168+
std::move(*this).getAsSingleValue(SGF, origFormalType,
169+
SGFContext(dest));
170+
161171
if (outputValue.isInContext()) return;
162172

163173
// Use RValue's forward-into-initialization code. We have to lie to

lib/SILGen/ArgumentSource.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,9 @@ class ArgumentSource {
256256
RValue getAsRValue(SILGenFunction &gen, SGFContext C = SGFContext()) &&;
257257
ManagedValue getAsSingleValue(SILGenFunction &gen,
258258
SGFContext C = SGFContext()) &&;
259+
ManagedValue getAsSingleValue(SILGenFunction &gen,
260+
AbstractionPattern origFormalType,
261+
SGFContext C = SGFContext()) &&;
259262

260263
void forwardInto(SILGenFunction &gen, Initialization *dest) &&;
261264
void forwardInto(SILGenFunction &gen, AbstractionPattern origFormalType,

0 commit comments

Comments
 (0)