aboutsummaryrefslogtreecommitdiff
path: root/src/codegen.cpp
diff options
context:
space:
mode:
authorLemonBoy <thatlemon@gmail.com>2019-12-15 11:24:44 +0100
committerAndrew Kelley <andrew@ziglang.org>2019-12-15 14:42:53 -0500
commitf1407b4b7ebe33f00cc8222e875ce271716671ad (patch)
tree6de02da9460658c297e0de3322dc4b0b166719cb /src/codegen.cpp
parent19ddbd9e9e691ff7ab8789e8c6962497fbba4b88 (diff)
downloadzig-f1407b4b7ebe33f00cc8222e875ce271716671ad.tar.gz
zig-f1407b4b7ebe33f00cc8222e875ce271716671ad.zip
Generate the fn pointers into the correct address space
Fixes #3645
Diffstat (limited to 'src/codegen.cpp')
-rw-r--r--src/codegen.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp
index 845375a25c..45e6f867eb 100644
--- a/src/codegen.cpp
+++ b/src/codegen.cpp
@@ -422,9 +422,10 @@ static LLVMValueRef make_fn_llvm_value(CodeGen *g, ZigFn *fn) {
LLVMTypeRef fn_llvm_type = fn->raw_type_ref;
LLVMValueRef llvm_fn = nullptr;
if (fn->body_node == nullptr) {
+ const unsigned fn_addrspace = ZigLLVMDataLayoutGetProgramAddressSpace(g->target_data_ref);
LLVMValueRef existing_llvm_fn = LLVMGetNamedFunction(g->module, symbol_name);
if (existing_llvm_fn) {
- return LLVMConstBitCast(existing_llvm_fn, LLVMPointerType(fn_llvm_type, 0));
+ return LLVMConstBitCast(existing_llvm_fn, LLVMPointerType(fn_llvm_type, fn_addrspace));
} else {
Buf *buf_symbol_name = buf_create_from_str(symbol_name);
auto entry = g->exported_symbol_names.maybe_get(buf_symbol_name);
@@ -447,7 +448,7 @@ static LLVMValueRef make_fn_llvm_value(CodeGen *g, ZigFn *fn) {
resolve_llvm_types_fn(g, tld_fn->fn_entry);
tld_fn->fn_entry->llvm_value = LLVMAddFunction(g->module, symbol_name,
tld_fn->fn_entry->raw_type_ref);
- llvm_fn = LLVMConstBitCast(tld_fn->fn_entry->llvm_value, LLVMPointerType(fn_llvm_type, 0));
+ llvm_fn = LLVMConstBitCast(tld_fn->fn_entry->llvm_value, LLVMPointerType(fn_llvm_type, fn_addrspace));
return llvm_fn;
}
}