Skip to content

Commit

Permalink
some code_native fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vtjnash committed Jan 8, 2025
1 parent 82497e1 commit a90df10
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/disasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,9 @@ static void jl_strip_llvm_debug(Module *m, bool all_meta, LineNumberAnnotatedWri
if (AAW)
AAW->addDebugLoc(&inst, inst.getDebugLoc());
inst.setDebugLoc(DebugLoc());
#if JL_LLVM_VERSION >= 190000
inst.dropDbgRecords();
#endif
}
if (deletelast) {
deletelast->eraseFromParent();
Expand Down Expand Up @@ -869,6 +872,8 @@ static void jl_dump_asm_internal(
SourceMgr SrcMgr;

MCTargetOptions Options;
Options.AsmVerbose = true;
Options.MCUseDwarfDirectory = MCTargetOptions::EnableDwarfDirectory;
std::unique_ptr<MCAsmInfo> MAI(
TheTarget->createMCAsmInfo(*TheTarget->createMCRegInfo(TheTriple.str()), TheTriple.str(), Options));
assert(MAI && "Unable to create target asm info!");
Expand Down Expand Up @@ -1237,6 +1242,11 @@ jl_value_t *jl_dump_function_asm_impl(jl_llvmf_dump_t* dump, char emit_mc, const
});
auto TMBase = jl_ExecutionEngine->cloneTargetMachine();
LLVMTargetMachine *TM = static_cast<LLVMTargetMachine*>(TMBase.get());
MCTargetOptions &Options = TM->Options.MCOptions;
Options.AsmVerbose = true;
Options.MCUseDwarfDirectory = MCTargetOptions::EnableDwarfDirectory;
if (binary)
Options.ShowMCEncoding = true;
legacy::PassManager PM;
addTargetPasses(&PM, TM->getTargetTriple(), TM->getTargetIRAnalysis());
if (emit_mc) {
Expand Down Expand Up @@ -1266,8 +1276,8 @@ jl_value_t *jl_dump_function_asm_impl(jl_llvmf_dump_t* dump, char emit_mc, const
OutputAsmDialect = 1;
MCInstPrinter *InstPrinter = TM->getTarget().createMCInstPrinter(
jl_ExecutionEngine->getTargetTriple(), OutputAsmDialect, MAI, MII, MRI);
std::unique_ptr<MCAsmBackend> MAB(TM->getTarget().createMCAsmBackend(
STI, MRI, TM->Options.MCOptions));
std::unique_ptr<MCAsmBackend> MAB(TM->getTarget().createMCAsmBackend(
STI, MRI, Options));
std::unique_ptr<MCCodeEmitter> MCE;
if (binary) { // enable MCAsmStreamer::AddEncodingComment printing
MCE.reset(TM->getTarget().createMCCodeEmitter(MII, *Context));
Expand All @@ -1281,8 +1291,7 @@ jl_value_t *jl_dump_function_asm_impl(jl_llvmf_dump_t* dump, char emit_mc, const
std::move(MAB), false
#endif
));
std::unique_ptr<AsmPrinter> Printer(
TM->getTarget().createAsmPrinter(*TM, std::move(S)));
AsmPrinter *Printer = TM->getTarget().createAsmPrinter(*TM, std::move(S));
#if JL_LLVM_VERSION >= 190000
Printer->addDebugHandler(
std::make_unique<LineNumberPrinterHandler>(*Printer, debuginfo));
Expand All @@ -1293,7 +1302,7 @@ jl_value_t *jl_dump_function_asm_impl(jl_llvmf_dump_t* dump, char emit_mc, const
#endif
if (!Printer)
return jl_an_empty_string;
PM.add(Printer.release());
PM.add(Printer);
PM.add(createFreeMachineFunctionPass());
TSM->withModuleDo([&](Module &m){ PM.run(m); });
}
Expand Down

0 comments on commit a90df10

Please sign in to comment.