@@ -431,7 +431,9 @@ class YkIRWriter {
431
431
serialiseOperand (I, VLMap, I->getOperand (OI));
432
432
}
433
433
434
- VLMap[I] = {BBIdx, InstIdx};
434
+ if (!I->getType ()->isVoidTy ()) {
435
+ VLMap[I] = {BBIdx, InstIdx};
436
+ }
435
437
InstIdx++;
436
438
}
437
439
@@ -447,14 +449,28 @@ class YkIRWriter {
447
449
// num_operands:
448
450
// We don't serialise any operands, because traces will guide us.
449
451
OutStreamer.emitInt32 (0 );
450
-
451
- VLMap[I] = {BBIdx, InstIdx};
452
- InstIdx++;
453
452
} else {
453
+ // type_index:
454
+ OutStreamer.emitSizeT (typeIndex (I->getType ()));
455
+ // opcode:
456
+ serialiseOpcode (OpCode::CondBr);
454
457
// We DO need operands for conditional branches, so that we can build
455
458
// guards.
456
- serialiseInstGeneric (I, VLMap, BBIdx, InstIdx, OpCode::CondBr);
459
+ //
460
+ // Note that in LLVM IR, the operands are ordered (despite the order they
461
+ // appear in the language reference): cond, if-false, if-true. We
462
+ // re-order those during lowering to avoid confusion.
463
+ //
464
+ // num_operands:
465
+ OutStreamer.emitInt32 (3 );
466
+ // OPERAND 0: condition.
467
+ serialiseOperand (I, VLMap, I->getOperand (0 ));
468
+ // OPERAND 1: block to go to if true.
469
+ serialiseOperand (I, VLMap, I->getOperand (2 ));
470
+ // OPERAND 2: block to go to if false.
471
+ serialiseOperand (I, VLMap, I->getOperand (1 ));
457
472
}
473
+ InstIdx++;
458
474
}
459
475
460
476
void serialiseGetElementPtr (GetElementPtrInst *I, ValueLoweringMap &VLMap,
0 commit comments