aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-07-08 23:20:49 +0200
committerThomas Voss <mail@thomasvoss.com> 2024-07-08 23:20:49 +0200
commitca42c26f51117ae83fd9c2be3f7d35169b93e9aa (patch)
treec718d9cb2f059fe467c33744b87610629f206816
parent29a8383daba90d0d26de0ca1349d026240fc7aeb (diff)
Just use LLVMPrintModuleToString 🤡
-rw-r--r--src/codegen.c13
1 files 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;