Mark return-by-pointer parameters as sret in LLVM

We need to do this so that LLVM picks up the correct calling convention
- in particular, on AArch64, return-by-pointer parameters need to go in
x8 for the C callconv!

This ends up fixing all `cli_run` tests!

```
running 35 tests
WARNING: skipping testing example form.roc because the test is broken right now!
test cli_run::cli ... ok
test cli_run::exposed_not_defined ... ok
test cli_run::format_check_folders ... ok
test cli_run::format_check_good ... ok
test cli_run::format_check_reformatting_needed ... ok
test cli_run::effects ... ok
test cli_run::fib ... ok
test cli_run::helloC ... ok
test cli_run::closure ... ok
WARNING: skipping testing example helloWeb.roc because the test is broken right now!
test cli_run::helloWeb ... ok
test cli_run::cfold ... ok
test cli_run::base64 ... ok
test cli_run::helloWorld ... ok
test cli_run::known_type_error ... ok
test cli_run::helloRust ... ok
test cli_run::helloZig ... ok
WARNING: skipping testing benchmark QuicksortApp.roc because the test is broken right now!
test cli_run::quicksort_app ... ok
test cli_run::astar ... ok
test cli_run::quicksort ... ok
test cli_run::issue2279 ... ok
test cli_run::helloSwift ... ok
test cli_run::run_multi_dep_str_optimized ... ok
test cli_run::nqueens ... ok
test cli_run::false_interpreter ... ok
test cli_run::rbtree_ck ... ok
test cli_run::unknown_generates_with ... ok
test cli_run::rbtree_insert ... ok
test cli_run::unused_import ... ok
test cli_run::run_multi_dep_str_unoptimized ... ok
test cli_run::tui ... ok
test cli_run::run_multi_dep_thunk_optimized ... ok
test cli_run::run_multi_dep_thunk_unoptimized ... ok
test cli_run::deriv ... ok
test cli_run::breakout ... ok
test cli_run::gui ... ok

test result: ok. 35 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 12.09s
```
This commit is contained in:
Ayaz Hafiz 2022-04-26 17:36:45 -04:00
parent 0f863bdd85
commit 6d9598a179
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
3 changed files with 192 additions and 112 deletions

View file

@ -18,7 +18,7 @@ use roc_module::symbol::Interns;
use roc_module::symbol::Symbol;
use roc_mono::layout::{Builtin, Layout, LayoutIds, UnionLayout};
use super::build::load_roc_value;
use super::build::{load_roc_value, FunctionSpec};
use super::convert::{argument_type_from_layout, argument_type_from_union_layout};
pub struct PointerToRefcount<'ctx> {
@ -143,11 +143,11 @@ impl<'ctx> PointerToRefcount<'ctx> {
);
let function_value = add_func(
env.context,
env.module,
fn_name,
fn_type,
FunctionSpec::known_fastcc(fn_type),
Linkage::Internal,
FAST_CALL_CONV, // Because it's an internal-only function, it should use the fast calling convention.
);
let subprogram = env.new_subprogram(fn_name);
@ -1138,11 +1138,11 @@ pub fn build_header_help<'a, 'ctx, 'env>(
};
let fn_val = add_func(
env.context,
env.module,
fn_name,
fn_type,
FunctionSpec::known_fastcc(fn_type),
Linkage::Private,
FAST_CALL_CONV, // Because it's an internal-only function, it should use the fast calling convention.
);
let subprogram = env.new_subprogram(fn_name);