From 2754c6b75b253fd249d069836def584dbc0c2c36 Mon Sep 17 00:00:00 2001 From: Zentrik Date: Fri, 6 Sep 2024 21:12:17 +0100 Subject: [PATCH] Adapt properly to https://github.com/llvm/llvm-project/pull/96785 and https://github.com/llvm/llvm-project/pull/97046 --- src/disasm.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/disasm.cpp b/src/disasm.cpp index ff16686314093..ebe8f2ac397c0 100644 --- a/src/disasm.cpp +++ b/src/disasm.cpp @@ -103,6 +103,7 @@ // for outputting assembly #include #include +#include #include #include #include @@ -1154,7 +1155,11 @@ addPassesToGenerateCode(LLVMTargetMachine *TM, PassManagerBase &PM) { return &MMIWP->getMMI().getContext(); } +#if JL_LLVM_VERSION >= 190000 +class LineNumberPrinterHandler : public DebugHandlerBase { +#else class LineNumberPrinterHandler : public AsmPrinterHandler { +#endif MCStreamer &S; LineNumberAnnotatedWriter LinePrinter; std::string Buffer; @@ -1163,7 +1168,11 @@ class LineNumberPrinterHandler : public AsmPrinterHandler { public: LineNumberPrinterHandler(AsmPrinter &Printer, const char *debuginfo) - : S(*Printer.OutStreamer), + : +#if JL_LLVM_VERSION >= 190000 + DebugHandlerBase(&Printer), +#endif + S(*Printer.OutStreamer), LinePrinter("; ", true, debuginfo), RawStream(Buffer), Stream(RawStream) {} @@ -1182,12 +1191,20 @@ class LineNumberPrinterHandler : public AsmPrinterHandler { //virtual void beginModule(Module *M) override {} virtual void endModule() override {} /// note that some AsmPrinter implementations may not call beginFunction at all +#if JL_LLVM_VERSION >= 190000 + virtual void beginFunctionImpl(const MachineFunction *MF) override { +#else virtual void beginFunction(const MachineFunction *MF) override { +#endif LinePrinter.emitFunctionAnnot(&MF->getFunction(), Stream); emitAndReset(); } //virtual void markFunctionEnd() override {} +#if JL_LLVM_VERSION >= 190000 + virtual void endFunctionImpl(const MachineFunction *MF) override { +#else virtual void endFunction(const MachineFunction *MF) override { +#endif LinePrinter.emitEnd(Stream); emitAndReset(); } @@ -1272,9 +1289,14 @@ jl_value_t *jl_dump_function_asm_impl(jl_llvmf_dump_t* dump, char emit_mc, const )); std::unique_ptr Printer( TM->getTarget().createAsmPrinter(*TM, std::move(S))); +#if JL_LLVM_VERSION >= 190000 + Printer->addDebugHandler( + std::make_unique(*Printer, debuginfo)); +#else Printer->addAsmPrinterHandler(AsmPrinter::HandlerInfo( std::unique_ptr(new LineNumberPrinterHandler(*Printer, debuginfo)), "emit", "Debug Info Emission", "Julia", "Julia::LineNumberPrinterHandler Markup")); +#endif if (!Printer) return jl_an_empty_string; PM.add(Printer.release());