@@ -234,6 +234,12 @@ namespace irgen {
234
234
// / The actual pointer, either to the function or to its descriptor.
235
235
llvm::Value *Value;
236
236
237
+ // / An additional value whose meaning varies by the FunctionPointer's Kind:
238
+ // / - Kind::AsyncFunctionPointer -> pointer to the corresponding function
239
+ // / if the FunctionPointer was created via
240
+ // / forDirect; nullptr otherwise.
241
+ llvm::Value *SecondaryValue;
242
+
237
243
PointerAuthInfo AuthInfo;
238
244
239
245
Signature Sig;
@@ -243,9 +249,11 @@ namespace irgen {
243
249
// / We may add more arguments to this; try to use the other
244
250
// / constructors/factories if possible.
245
251
explicit FunctionPointer (Kind kind, llvm::Value *value,
252
+ llvm::Value *secondaryValue,
246
253
PointerAuthInfo authInfo,
247
254
const Signature &signature)
248
- : kind(kind), Value(value), AuthInfo(authInfo), Sig(signature) {
255
+ : kind(kind), Value(value), SecondaryValue(secondaryValue),
256
+ AuthInfo(authInfo), Sig(signature) {
249
257
// The function pointer should have function type.
250
258
assert (value->getType ()->getPointerElementType ()->isFunctionTy ());
251
259
// TODO: maybe assert similarity to signature.getType()?
@@ -258,18 +266,25 @@ namespace irgen {
258
266
}
259
267
}
260
268
269
+ explicit FunctionPointer (Kind kind, llvm::Value *value,
270
+ PointerAuthInfo authInfo,
271
+ const Signature &signature)
272
+ : FunctionPointer(kind, value, nullptr , authInfo, signature){};
273
+
261
274
// Temporary only!
262
275
explicit FunctionPointer (Kind kind, llvm::Value *value,
263
276
const Signature &signature)
264
277
: FunctionPointer(kind, value, PointerAuthInfo(), signature) {}
265
278
266
- static FunctionPointer forDirect (IRGenModule &IGM,
267
- llvm::Constant *value ,
279
+ static FunctionPointer forDirect (IRGenModule &IGM, llvm::Constant *value,
280
+ llvm::Constant *secondaryValue ,
268
281
CanSILFunctionType fnType);
269
282
270
283
static FunctionPointer forDirect (Kind kind, llvm::Constant *value,
284
+ llvm::Constant *secondaryValue,
271
285
const Signature &signature) {
272
- return FunctionPointer (kind, value, PointerAuthInfo (), signature);
286
+ return FunctionPointer (kind, value, secondaryValue, PointerAuthInfo (),
287
+ signature);
273
288
}
274
289
275
290
static FunctionPointer forExplosionValue (IRGenFunction &IGF,
@@ -295,6 +310,13 @@ namespace irgen {
295
310
// / Return the actual function pointer.
296
311
llvm::Value *getRawPointer () const { return Value; }
297
312
313
+ // / Assuming that the receiver is of kind AsyncFunctionPointer, returns the
314
+ // / pointer to the corresponding function if available.
315
+ llvm::Value *getRawAsyncFunction () const {
316
+ assert (kind.isAsyncFunctionPointer ());
317
+ return SecondaryValue;
318
+ }
319
+
298
320
// / Given that this value is known to have been constructed from
299
321
// / a direct function, return the function pointer.
300
322
llvm::Constant *getDirectPointer () const {
0 commit comments