@@ -1207,6 +1207,14 @@ class AsyncNativeCCEntryPointArgumentEmission final
1207
1207
/* const*/ AsyncContextLayout layout;
1208
1208
const Address dataAddr;
1209
1209
1210
+ llvm::Value *loadValue (ElementLayout layout) {
1211
+ Address addr = layout.project (IGF, dataAddr, /* offsets*/ llvm::None);
1212
+ auto &ti = cast<LoadableTypeInfo>(layout.getType ());
1213
+ Explosion explosion;
1214
+ ti.loadAsTake (IGF, addr, explosion);
1215
+ return explosion.claimNext ();
1216
+ }
1217
+
1210
1218
public:
1211
1219
AsyncNativeCCEntryPointArgumentEmission (IRGenSILFunction &IGF,
1212
1220
SILBasicBlock &entry,
@@ -1222,22 +1230,15 @@ class AsyncNativeCCEntryPointArgumentEmission final
1222
1230
}
1223
1231
llvm::Value *getContext () override {
1224
1232
auto contextLayout = layout.getLocalContextLayout ();
1225
- Address addr = contextLayout.project (IGF, dataAddr, /* offsets*/ llvm::None);
1226
- auto &ti = cast<LoadableTypeInfo>(contextLayout.getType ());
1227
- Explosion explosion;
1228
- ti.loadAsTake (IGF, addr, explosion);
1229
- return explosion.claimNext ();
1233
+ return loadValue (contextLayout);
1230
1234
}
1231
1235
Explosion getArgumentExplosion (unsigned index, unsigned size) override {
1232
1236
assert (size > 0 );
1233
1237
Explosion result;
1234
1238
for (unsigned i = index, end = index + size; i < end; ++i) {
1235
1239
auto argumentLayout = layout.getArgumentLayout (i);
1236
- auto addr = argumentLayout.project (IGF, dataAddr, /* offsets*/ llvm::None);
1237
- auto &ti = cast<LoadableTypeInfo>(argumentLayout.getType ());
1238
- Explosion explosion;
1239
- ti.loadAsTake (IGF, addr, explosion);
1240
- result.add (explosion.claimAll ());
1240
+ auto *value = loadValue (argumentLayout);
1241
+ result.add (value);
1241
1242
}
1242
1243
return result;
1243
1244
}
@@ -1249,30 +1250,15 @@ class AsyncNativeCCEntryPointArgumentEmission final
1249
1250
}
1250
1251
llvm::Value *getIndirectResult (unsigned index) override {
1251
1252
auto fieldLayout = layout.getIndirectReturnLayout (index);
1252
- Address fieldAddr =
1253
- fieldLayout.project (IGF, dataAddr, /* offsets*/ llvm::None);
1254
- auto &ti = cast<LoadableTypeInfo>(fieldLayout.getType ());
1255
- Explosion explosion;
1256
- ti.loadAsTake (IGF, fieldAddr, explosion);
1257
- return explosion.claimNext ();
1253
+ return loadValue (fieldLayout);
1258
1254
};
1259
1255
llvm::Value *getSelfWitnessTable () override {
1260
1256
auto fieldLayout = layout.getSelfWitnessTableLayout ();
1261
- Address fieldAddr =
1262
- fieldLayout.project (IGF, dataAddr, /* offsets*/ llvm::None);
1263
- auto &ti = cast<LoadableTypeInfo>(fieldLayout.getType ());
1264
- Explosion explosion;
1265
- ti.loadAsTake (IGF, fieldAddr, explosion);
1266
- return explosion.claimNext ();
1257
+ return loadValue (fieldLayout);
1267
1258
}
1268
1259
llvm::Value *getSelfMetadata () override {
1269
1260
auto fieldLayout = layout.getSelfMetadataLayout ();
1270
- Address fieldAddr =
1271
- fieldLayout.project (IGF, dataAddr, /* offsets*/ llvm::None);
1272
- auto &ti = cast<LoadableTypeInfo>(fieldLayout.getType ());
1273
- Explosion explosion;
1274
- ti.loadAsTake (IGF, fieldAddr, explosion);
1275
- return explosion.claimNext ();
1261
+ return loadValue (fieldLayout);
1276
1262
}
1277
1263
llvm::Value *getCoroutineBuffer () override {
1278
1264
llvm_unreachable (" unimplemented" );
0 commit comments