From b70e734ccb68123078058c441fdd6e6f9f7a0c7e Mon Sep 17 00:00:00 2001 From: Edd Barrett Date: Thu, 9 Jan 2025 14:58:58 +0000 Subject: [PATCH] Serialise debug anchors. --- llvm/lib/YkIR/YkIRWriter.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/llvm/lib/YkIR/YkIRWriter.cpp b/llvm/lib/YkIR/YkIRWriter.cpp index e257b2c907e8e20..1c30e69de4d9813 100644 --- a/llvm/lib/YkIR/YkIRWriter.cpp +++ b/llvm/lib/YkIR/YkIRWriter.cpp @@ -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; @@ -74,6 +75,7 @@ enum OpCode { OpCodeFCmp, OpCodePromote, OpCodeFNeg, + OpCodeDebugAnchor, OpCodeUnimplemented = 255, // YKFIXME: Will eventually be deleted. }; @@ -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) { @@ -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. //