diff options
| author | gingerBill <bill@gingerbill.org> | 2021-05-10 21:16:26 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2021-05-10 21:16:26 +0100 |
| commit | ff6fdc7812bce3edfbf102dddc97c5821da6e840 (patch) | |
| tree | ed51ae2f65ec915afe9ddf9db54cba30060b98f0 /src | |
| parent | c85c5ec38cae351ef8394553cdc701cb854656c9 (diff) | |
Correct SysV ABI for `-> (f32, bool)`
Diffstat (limited to 'src')
| -rw-r--r-- | src/llvm_abi.cpp | 5 | ||||
| -rw-r--r-- | src/llvm_backend.cpp | 27 |
2 files changed, 26 insertions, 6 deletions
diff --git a/src/llvm_abi.cpp b/src/llvm_abi.cpp index 739d43d60..6635423e7 100644 --- a/src/llvm_abi.cpp +++ b/src/llvm_abi.cpp @@ -549,6 +549,11 @@ namespace lbAbiAmd64SysV { } else if (oldv == RegClass_Memory || newv == RegClass_Memory) { return; } else if (oldv == RegClass_Int || newv == RegClass_Int) { + if (oldv == RegClass_SSEFv || oldv == RegClass_SSEFs) { + oldv = RegClass_Int; + } else if (newv == RegClass_SSEFv || newv == RegClass_SSEFs) { + oldv = RegClass_Int; + } return; } else if (oldv == RegClass_X87 || oldv == RegClass_X87Up || oldv == RegClass_ComplexX87 || newv == RegClass_X87 || newv == RegClass_X87Up || newv == RegClass_ComplexX87) { diff --git a/src/llvm_backend.cpp b/src/llvm_backend.cpp index 9a6595b24..78ffb36e5 100644 --- a/src/llvm_backend.cpp +++ b/src/llvm_backend.cpp @@ -5794,9 +5794,15 @@ lbValue lb_find_value_from_entity(lbModule *m, Entity *e) { if (USE_SEPARTE_MODULES) { lbModule *other_module = lb_pkg_module(m->gen, e->pkg); + + // TODO(bill): correct this logic bool is_external = other_module != m; if (!is_external) { - other_module = e->code_gen_module; + if (e->code_gen_module != nullptr) { + other_module = e->code_gen_module; + } else { + other_module = nullptr; + } is_external = other_module != m; } @@ -5806,8 +5812,20 @@ lbValue lb_find_value_from_entity(lbModule *m, Entity *e) { lbValue g = {}; g.value = LLVMAddGlobal(m->mod, lb_type(m, e->type), alloc_cstring(permanent_allocator(), name)); g.type = alloc_type_pointer(e->type); + lb_add_entity(m, e, g); + lb_add_member(m, name, g); + LLVMSetLinkage(g.value, LLVMExternalLinkage); + // if (other_module != nullptr) { + // lbValue *other_found = string_map_get(&other_module->members, name); + // if (other_found) { + // lbValue other_g = *other_found; + // } + // } + + // LLVMSetLinkage(other_g.value, LLVMExternalLinkage); + if (e->Variable.thread_local_model != "") { LLVMSetThreadLocal(g.value, true); @@ -5827,8 +5845,7 @@ lbValue lb_find_value_from_entity(lbModule *m, Entity *e) { LLVMSetThreadLocalMode(g.value, mode); } - lb_add_entity(m, e, g); - lb_add_member(m, name, g); + return g; } } @@ -14713,9 +14730,7 @@ void lb_generate_code(lbGenerator *gen) { if (is_export) { LLVMSetLinkage(g.value, LLVMDLLExportLinkage); LLVMSetDLLStorageClass(g.value, LLVMDLLExportStorageClass); - } - - if (e->flags & EntityFlag_Static) { + } else { // LLVMSetLinkage(g.value, LLVMInternalLinkage); } |