Skip to content

Commit

Permalink
Merge branch 'main' into swt-module-clone-shadowstack
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel-Durov committed Jan 24, 2025
2 parents 78c196a + 5c65211 commit 53b42c5
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_STR "yk_debug_str"
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,
OpCodeDebugStr,
OpCodeUnimplemented = 255, // YKFIXME: Will eventually be deleted.
};

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

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

// opcode:
serialiseOpcode(OpCodeDebugStr);
// 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_STR) {
serialiseDebugStr(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 53b42c5

Please sign in to comment.