aboutsummaryrefslogtreecommitdiff
path: root/src/llvm_backend_proc.cpp
diff options
context:
space:
mode:
authorgingerBill <gingerBill@users.noreply.github.com>2022-11-01 15:52:40 +0000
committerGitHub <noreply@github.com>2022-11-01 15:52:40 +0000
commit382bd87667a275f9b276886f7c1e8caac4dda5f6 (patch)
treebcfb541078f7e1d45fc3e1be7da5bb9cae864502 /src/llvm_backend_proc.cpp
parent6cc07dc24e4eb9800b1086580d271970b45f77cb (diff)
parentc39ef1b25cc77f0179156430e45ef1d3c2028b7b (diff)
Merge pull request #2169 from odin-lang/location-byvaldev-2022-11
Ad-hoc pass source code location directly by pointer without stack copy
Diffstat (limited to 'src/llvm_backend_proc.cpp')
-rw-r--r--src/llvm_backend_proc.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/llvm_backend_proc.cpp b/src/llvm_backend_proc.cpp
index ed7587bfd..a9de7b231 100644
--- a/src/llvm_backend_proc.cpp
+++ b/src/llvm_backend_proc.cpp
@@ -911,6 +911,9 @@ lbValue lb_emit_call(lbProcedure *p, lbValue value, Array<lbValue> const &args,
auto processed_args = array_make<lbValue>(permanent_allocator(), 0, args.count);
{
+
+ bool is_odin_cc = is_calling_convention_odin(pt->Proc.calling_convention);
+
lbFunctionType *ft = lb_get_function_type(m, p, pt);
bool return_by_pointer = ft->ret.kind == lbArg_Indirect;
@@ -946,8 +949,12 @@ lbValue lb_emit_call(lbProcedure *p, lbValue value, Array<lbValue> const &args,
} else if (arg->kind == lbArg_Indirect) {
lbValue ptr = {};
if (arg->is_byval) {
- ptr = lb_copy_value_to_ptr(p, x, original_type, arg->byval_alignment);
- } else if (is_calling_convention_odin(pt->Proc.calling_convention)) {
+ if (is_odin_cc && are_types_identical(original_type, t_source_code_location)) {
+ ptr = lb_address_from_load_or_generate_local(p, x);
+ } else {
+ ptr = lb_copy_value_to_ptr(p, x, original_type, arg->byval_alignment);
+ }
+ } else if (is_odin_cc) {
// NOTE(bill): Odin parameters are immutable so the original value can be passed if possible
// i.e. `T const &` in C++
ptr = lb_address_from_load_or_generate_local(p, x);