@@ -53,6 +53,7 @@ enum OpCode {
53
53
OpCodeCast,
54
54
OpCodeSwitch,
55
55
OpCodePHI,
56
+ OpCodeIndirectCall,
56
57
OpCodeUnimplemented = 255 , // YKFIXME: Will eventually be deleted.
57
58
};
58
59
@@ -479,6 +480,29 @@ class YkIRWriter {
479
480
}
480
481
}
481
482
483
+ void serialiseIndirectCallInst (CallInst *I, FuncLowerCtxt &FLCtxt,
484
+ unsigned BBIdx, unsigned &InstIdx) {
485
+
486
+ serialiseOpcode (OpCodeIndirectCall);
487
+ // function type:
488
+ OutStreamer.emitSizeT (typeIndex (I->getFunctionType ()));
489
+ // callee (operand):
490
+ serialiseOperand (I, FLCtxt, I->getCalledOperand ());
491
+ // num_args:
492
+ // (this includes static and varargs arguments)
493
+ OutStreamer.emitInt32 (I->arg_size ());
494
+ // args:
495
+ for (unsigned OI = 0 ; OI < I->arg_size (); OI++) {
496
+ serialiseOperand (I, FLCtxt, I->getOperand (OI));
497
+ }
498
+
499
+ // If the return type is non-void, then this defines a local.
500
+ if (!I->getType ()->isVoidTy ()) {
501
+ FLCtxt.updateVLMap (I, InstIdx);
502
+ }
503
+ InstIdx++;
504
+ }
505
+
482
506
void serialiseCallInst (CallInst *I, FuncLowerCtxt &FLCtxt, unsigned BBIdx,
483
507
unsigned &InstIdx) {
484
508
if (I->isInlineAsm ()) {
@@ -494,16 +518,19 @@ class YkIRWriter {
494
518
return ;
495
519
}
496
520
521
+ if (I->isIndirectCall ()) {
522
+ serialiseIndirectCallInst (I, FLCtxt, BBIdx, InstIdx);
523
+ return ;
524
+ }
525
+
497
526
// Stackmap calls are serialised on-demand by folding them into the `call`
498
527
// or `condbr` instruction which they belong to.
499
528
if (I->getCalledFunction ()->isIntrinsic () &&
500
529
I->getIntrinsicID () == Intrinsic::experimental_stackmap) {
501
530
return ;
502
531
}
503
532
504
- // FIXME: indirect calls.
505
- //
506
- // Note that this assertion can also fail if you do a direct call without
533
+ // FIXME: Note that this assertion can fail if you do a direct call without
507
534
// the correct type annotation at the call site.
508
535
//
509
536
// e.g. for a functiion:
0 commit comments