From ca42c26f51117ae83fd9c2be3f7d35169b93e9aa Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Mon, 8 Jul 2024 23:20:49 +0200 Subject: Just use LLVMPrintModuleToString 🤡 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/codegen.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/codegen.c b/src/codegen.c index 5cd7ed4..14d7c20 100644 --- a/src/codegen.c +++ b/src/codegen.c @@ -111,15 +111,10 @@ codegen(const char *file, bitset_t *cnst, fold_t *folds, scope_t *scps, LLVMDisposeMessage(error); if (lflag) { - if (oflag == NULL) - oflag = "/dev/stdout"; - /* Stupid hack to make this work with Neovim */ - if (LLVMPrintModuleToFile(llmod, oflag, &error) == 1) { - if (errno != ENXIO) - err("codegen: %s: %s", oflag, error); - LLVMDisposeMessage(error); - LLVMDumpModule(llmod); - } + /* Needlessly inefficient… but that’s LLVM for you */ + char *s = LLVMPrintModuleToString(llmod); + fputs(s, stdout); + LLVMDisposeMessage(s); } else { LLVMCodeGenFileType ft; const char *dst = oflag == NULL ? "out.o" : oflag; -- cgit v1.2.3