diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-06-17 17:03:14 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-06-17 17:03:14 +0200 |
commit | 97c386b7cd2d3074e8609513ef85218268635cb3 (patch) | |
tree | ec9ef53d8cfcacb6c48d423a015e19015e5c8d88 /src | |
parent | a1657b2baebb8569395c1314bb1f9bdeab32ea6d (diff) |
Don’t create a new builder every iteration
Diffstat (limited to 'src')
-rw-r--r-- | src/codegen.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/codegen.c b/src/codegen.c index dd21ad7..1db5625 100644 --- a/src/codegen.c +++ b/src/codegen.c @@ -20,8 +20,8 @@ static size_t codegenexpr(LLVMBuilderRef, struct ast, struct lexemes, void codegen(struct ast ast, struct lexemes toks) { - exit(EXIT_SUCCESS); LLVMModuleRef mod = LLVMModuleCreateWithName("oryx"); + LLVMBuilderRef builder = LLVMCreateBuilder(); for (size_t i = 0; i < ast.len;) { if (ast.kinds[i] != ASTCDECL) @@ -59,7 +59,6 @@ codegen(struct ast ast, struct lexemes toks) LLVMValueRef fn = LLVMAddFunction(mod, fnname, fnproto); LLVMBasicBlockRef entry = LLVMAppendBasicBlock(fn, "entry"); - LLVMBuilderRef builder = LLVMCreateBuilder(); LLVMPositionBuilderAtEnd(builder, entry); free(fnname); @@ -67,9 +66,10 @@ codegen(struct ast ast, struct lexemes toks) for (i = ast.kids[body].lhs; i <= ast.kids[body].rhs;) i = codegenstmt(builder, ast, toks, i); - LLVMDisposeBuilder(builder); } + LLVMDisposeBuilder(builder); + char *error = NULL; LLVMVerifyModule(mod, LLVMAbortProcessAction, &error); LLVMDisposeMessage(error); |