Skip to content

Commit 4c298db

Browse files
committed
[NFC] Extracted async call emission loading.
Previously the code for loading indirect returns was inline in the member function where it was performed. Here it is pulled out into a private method.
1 parent 6e0d894 commit 4c298db

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

lib/IRGen/GenCall.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1957,6 +1957,11 @@ class AsyncCallEmission final : public CallEmission {
19571957
auto &ti = cast<LoadableTypeInfo>(layout.getType());
19581958
ti.initialize(IGF, explosion, addr, isOutlined);
19591959
}
1960+
void loadValue(ElementLayout layout, Explosion &explosion) {
1961+
Address addr = layout.project(IGF, context, /*offsets*/ llvm::None);
1962+
auto &ti = layout.getType();
1963+
cast<LoadableTypeInfo>(ti).loadAsTake(IGF, addr, explosion);
1964+
}
19601965

19611966
public:
19621967
AsyncCallEmission(IRGenFunction &IGF, llvm::Value *selfValue, Callee &&callee)
@@ -2036,20 +2041,13 @@ class AsyncCallEmission final : public CallEmission {
20362041
// argument buffer.
20372042
return;
20382043
}
2039-
assert(call->arg_size() == 1);
2040-
auto context = call->arg_begin()->get();
20412044
// Gather the values.
20422045
Explosion nativeExplosion;
20432046
auto layout = getAsyncContextLayout();
2044-
auto dataAddr = layout.emitCastTo(IGF, context);
20452047
for (unsigned index = 0, count = layout.getDirectReturnCount();
20462048
index < count; ++index) {
20472049
auto fieldLayout = layout.getDirectReturnLayout(index);
2048-
Address fieldAddr =
2049-
fieldLayout.project(IGF, dataAddr, /*offsets*/ llvm::None);
2050-
auto &fieldTI = fieldLayout.getType();
2051-
cast<LoadableTypeInfo>(fieldTI).loadAsTake(IGF, fieldAddr,
2052-
nativeExplosion);
2050+
loadValue(fieldLayout, nativeExplosion);
20532051
}
20542052

20552053
out = nativeSchema.mapFromNative(IGF.IGM, IGF, nativeExplosion, resultType);

0 commit comments

Comments
 (0)