From 029d37d6a7dc96f71dded5d5a9c8e7477aaa4146 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 10 Nov 2017 14:58:50 -0500 Subject: fix bug when multiple function definitions exist This might be related to #529 --- src/codegen.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/codegen.cpp') diff --git a/src/codegen.cpp b/src/codegen.cpp index 38a1a2cbea..248dc7a382 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -408,6 +408,7 @@ static LLVMValueRef fn_llvm_value(CodeGen *g, FnTableEntry *fn_table_entry) { LLVMValueRef existing_llvm_fn = LLVMGetNamedFunction(g->module, buf_ptr(symbol_name)); if (existing_llvm_fn) { fn_table_entry->llvm_value = LLVMConstBitCast(existing_llvm_fn, LLVMPointerType(fn_llvm_type, 0)); + return fn_table_entry->llvm_value; } else { fn_table_entry->llvm_value = LLVMAddFunction(g->module, buf_ptr(symbol_name), fn_llvm_type); } -- cgit v1.2.3