Skip to content

Commit

Permalink
Serialise debug anchors.
Browse files Browse the repository at this point in the history
  • Loading branch information
vext01 committed Jan 10, 2025
1 parent 4b7a0d5 commit b70e734
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions llvm/lib/YkIR/YkIRWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class SerialiseInstructionException {

#define YK_OUTLINE_FNATTR "yk_outline"
#define YK_PROMOTE_PREFIX "__yk_promote"
#define YK_DEBUG_ANCHOR "yk_debug_anchor"
const char *SectionName = ".yk_ir";
const uint32_t Magic = 0xedd5f00d;
const uint32_t Version = 0;
Expand All @@ -74,6 +75,7 @@ enum OpCode {
OpCodeFCmp,
OpCodePromote,
OpCodeFNeg,
OpCodeDebugAnchor,
OpCodeUnimplemented = 255, // YKFIXME: Will eventually be deleted.
};

Expand Down Expand Up @@ -641,6 +643,21 @@ class YkIRWriter {
InstIdx++;
}

void serialiseDebugAnchor(CallInst *I, FuncLowerCtxt &FLCtxt,
unsigned &InstIdx) {
// We expect one argument: a `char *` to a message for the anchor.
assert(I->arg_size() == 1);
assert(I->getOperand(0)->getType()->isPointerTy());

// opcode:
serialiseOpcode(OpCodeDebugAnchor);
// message:
serialiseOperand(I, FLCtxt, I->getOperand(0));

FLCtxt.updateVLMap(I, InstIdx);
InstIdx++;
}

void serialiseIndirectCallInst(CallInst *I, FuncLowerCtxt &FLCtxt,
unsigned BBIdx, unsigned &InstIdx) {

Expand Down Expand Up @@ -784,6 +801,11 @@ class YkIRWriter {
return;
}

if (I->getCalledFunction()->getName() == YK_DEBUG_ANCHOR) {
serialiseDebugAnchor(I, FLCtxt, InstIdx);
return;
}

// FIXME: Note that this assertion can fail if you do a direct call without
// the correct type annotation at the call site.
//
Expand Down

0 comments on commit b70e734

Please sign in to comment.