mirror of
https://github.com/roc-lang/roc.git
synced 2024-09-22 00:09:33 +03:00
enable tail-call elimination in llvm
This commit is contained in:
parent
9eed02ae4a
commit
08403b0a1f
@ -202,9 +202,13 @@ mod test_gen {
|
||||
let builder = context.create_builder();
|
||||
let fpm = PassManager::create(&module);
|
||||
|
||||
// Enable optimizations when running cargo test --release
|
||||
// tail-call elimination is always on
|
||||
// it needs a pass before it to work
|
||||
fpm.add_instruction_combining_pass();
|
||||
fpm.add_tail_call_elimination_pass();
|
||||
|
||||
// Enable more optimizations when running cargo test --release
|
||||
if !cfg!(debug_assertions) {
|
||||
fpm.add_instruction_combining_pass();
|
||||
fpm.add_reassociate_pass();
|
||||
fpm.add_basic_alias_analysis_pass();
|
||||
fpm.add_promote_memory_to_register_pass();
|
||||
@ -342,9 +346,12 @@ mod test_gen {
|
||||
let builder = context.create_builder();
|
||||
let fpm = PassManager::create(&module);
|
||||
|
||||
// Enable optimizations when running cargo test --release
|
||||
// tail-call elimination is always on
|
||||
fpm.add_instruction_combining_pass();
|
||||
fpm.add_tail_call_elimination_pass();
|
||||
|
||||
// Enable more optimizations when running cargo test --release
|
||||
if !cfg!(debug_assertions) {
|
||||
fpm.add_instruction_combining_pass();
|
||||
fpm.add_reassociate_pass();
|
||||
fpm.add_basic_alias_analysis_pass();
|
||||
fpm.add_promote_memory_to_register_pass();
|
||||
@ -473,9 +480,6 @@ mod test_gen {
|
||||
// These each rebuild everything from scratch, starting with
|
||||
// parsing the source, so that there's no chance their passing
|
||||
// or failing depends on leftover state from the previous one.
|
||||
{
|
||||
assert_crane_evals_to!($src, $expected, $ty, (|val| val));
|
||||
}
|
||||
{
|
||||
assert_llvm_evals_to!($src, $expected, $ty, (|val| val));
|
||||
}
|
||||
@ -485,9 +489,6 @@ mod test_gen {
|
||||
};
|
||||
($src:expr, $expected:expr, $ty:ty, $transform:expr) => {
|
||||
// Same as above, except with an additional transformation argument.
|
||||
{
|
||||
assert_crane_evals_to!($src, $expected, $ty, $transform);
|
||||
}
|
||||
{
|
||||
assert_llvm_evals_to!($src, $expected, $ty, $transform);
|
||||
}
|
||||
@ -1998,4 +1999,22 @@ mod test_gen {
|
||||
bool
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tail_call_elimination() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
sum = \n, accum ->
|
||||
when n is
|
||||
0 -> accum
|
||||
_ -> sum (n - 1) (n + accum)
|
||||
|
||||
sum 1_000_000 0
|
||||
"#
|
||||
),
|
||||
500000500000,
|
||||
i64
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user