aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMorten Hauke Solvang <morten.hauke.solvang@gmail.com>2023-10-13 21:21:54 +0200
committerMorten Hauke Solvang <morten.hauke.solvang@gmail.com>2023-10-13 21:21:54 +0200
commitfb5bb1cd83df0b41c68ea7a2427a57df1a82e3ca (patch)
tree01012531522f863d5a85ad17597d7800a6a1e64b /src
parent23c4615f5e4aff1ff85918aa666b35864ab34089 (diff)
llvm: specify calling convention on call
Looks like the compiler only was specifying the calling convention on function declarations, but not on function calls. But LLVM seems to produce "bad" code when optimizing with level -O2 unless you specify the same calling convention on the call too.
Diffstat (limited to 'src')
-rw-r--r--src/llvm_backend_proc.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/llvm_backend_proc.cpp b/src/llvm_backend_proc.cpp
index 7c0fbd0b9..ba920c042 100644
--- a/src/llvm_backend_proc.cpp
+++ b/src/llvm_backend_proc.cpp
@@ -891,6 +891,9 @@ gb_internal lbValue lb_emit_call_internal(lbProcedure *p, lbValue value, lbValue
LLVMValueRef ret = LLVMBuildCall2(p->builder, fnp, fn, args, arg_count, "");
+ auto llvm_cc = lb_calling_convention_map[proc_type->Proc.calling_convention];
+ LLVMSetInstructionCallConv(ret, llvm_cc);
+
LLVMAttributeIndex param_offset = LLVMAttributeIndex_FirstArgIndex;
if (return_ptr.value != nullptr) {
param_offset += 1;