Skip to content

Commit a52f437

Browse files
authored
Merge pull request rust-lang#147 from jacob-hughes/fold_stackmaps_into_switch
Fold stackmaps into switch
2 parents d47d38e + 27cea0e commit a52f437

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

llvm/lib/YkIR/YkIRWriter.cpp

+7-9
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ enum OpCode {
5151
OpCodePtrAdd,
5252
OpCodeBinOp,
5353
OpCodeCast,
54-
OpCodeDeoptSafepoint,
5554
OpCodeSwitch,
5655
OpCodeUnimplemented = 255, // YKFIXME: Will eventually be deleted.
5756
};
@@ -397,6 +396,9 @@ class YkIRWriter {
397396
}
398397

399398
void serialiseStackmapCall(CallInst *I, ValueLoweringMap &VLMap) {
399+
assert(I);
400+
assert(I->getCalledFunction()->isIntrinsic());
401+
assert(I->getIntrinsicID() == Intrinsic::experimental_stackmap);
400402
// stackmap ID:
401403
serialiseOperand(I, VLMap, I->getOperand(0));
402404

@@ -461,12 +463,9 @@ class YkIRWriter {
461463
}
462464
if (!I->getCalledFunction()->isDeclaration()) {
463465
// The next instruction will be the stackmap entry
464-
CallInst *SMI = dyn_cast<CallInst>(I->getNextNonDebugInstruction());
465-
assert(SMI);
466-
assert(SMI->getCalledFunction()->isIntrinsic());
467-
assert(SMI->getIntrinsicID() == Intrinsic::experimental_stackmap);
468466
// has_safepoint = 1:
469467
OutStreamer.emitInt8(1);
468+
CallInst *SMI = dyn_cast<CallInst>(I->getNextNonDebugInstruction());
470469
serialiseStackmapCall(SMI, VLMap);
471470
} else {
472471
// has_safepoint = 0:
@@ -506,9 +505,6 @@ class YkIRWriter {
506505
serialiseBlockLabel(I->getSuccessor(1));
507506

508507
CallInst *SMI = dyn_cast<CallInst>(I->getPrevNonDebugInstruction());
509-
assert(SMI);
510-
assert(SMI->getCalledFunction()->isIntrinsic());
511-
assert(SMI->getIntrinsicID() == Intrinsic::experimental_stackmap);
512508
serialiseStackmapCall(SMI, VLMap);
513509
}
514510
InstIdx++;
@@ -688,7 +684,9 @@ class YkIRWriter {
688684
for (auto &Case : I->cases()) {
689685
serialiseBlockLabel(Case.getCaseSuccessor());
690686
}
691-
687+
// safepoint:
688+
CallInst *SMI = dyn_cast<CallInst>(I->getPrevNonDebugInstruction());
689+
serialiseStackmapCall(SMI, VLMap);
692690
InstIdx++;
693691
}
694692

0 commit comments

Comments
 (0)