mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 06:44:46 +00:00
All of test_gen works again
This commit is contained in:
parent
3c2dd488a5
commit
bc987fd4d7
2 changed files with 59 additions and 13 deletions
|
@ -8,3 +8,16 @@ test-gen-wasm = "test -p roc_gen_wasm -p test_gen --no-default-features --featur
|
||||||
# opt-level=s Optimizations should focus more on size than speed
|
# opt-level=s Optimizations should focus more on size than speed
|
||||||
# lto=fat Spend extra effort on link-time optimization across crates
|
# lto=fat Spend extra effort on link-time optimization across crates
|
||||||
rustflags = ["-Copt-level=s", "-Clto=fat"]
|
rustflags = ["-Copt-level=s", "-Clto=fat"]
|
||||||
|
|
||||||
|
[env]
|
||||||
|
# Debug flags. Keep this up-to-date with compiler/debug_flags/src/lib.rs.
|
||||||
|
# Set = "1" to turn a debug flag on.
|
||||||
|
ROC_PRETTY_PRINT_ALIAS_CONTENTS = "0"
|
||||||
|
ROC_PRINT_UNIFICATIONS = "0"
|
||||||
|
ROC_PRINT_MISMATCHES = "0"
|
||||||
|
ROC_PRINT_IR_AFTER_SPECIALIZATION = "0"
|
||||||
|
ROC_PRINT_IR_AFTER_RESET_REUSE = "0"
|
||||||
|
ROC_PRINT_IR_AFTER_REFCOUNT = "0"
|
||||||
|
ROC_DEBUG_ALIAS_ANALYSIS = "0"
|
||||||
|
ROC_PRINT_LLVM_FN_VERIFICATION = "0"
|
||||||
|
ROC_PRINT_LOAD_LOG = "0"
|
||||||
|
|
|
@ -2465,6 +2465,17 @@ fn specialize_external<'a>(
|
||||||
(Some(closure_layout), CapturedSymbols::Captured(captured)) => {
|
(Some(closure_layout), CapturedSymbols::Captured(captured)) => {
|
||||||
// debug_assert!(!captured.is_empty());
|
// debug_assert!(!captured.is_empty());
|
||||||
|
|
||||||
|
// An argument from the closure list may have taken on a specialized symbol
|
||||||
|
// name during the evaluation of the def body. If this is the case, load the
|
||||||
|
// specialized name rather than the original captured name!
|
||||||
|
// let get_specialized_name = |symbol, layout| {
|
||||||
|
// procs
|
||||||
|
// .needed_symbol_specializations
|
||||||
|
// .get(&(symbol, layout))
|
||||||
|
// .map(|(_, specialized)| *specialized)
|
||||||
|
// .unwrap_or(symbol)
|
||||||
|
// };
|
||||||
|
|
||||||
match closure_layout.layout_for_member(proc_name) {
|
match closure_layout.layout_for_member(proc_name) {
|
||||||
ClosureRepresentation::Union {
|
ClosureRepresentation::Union {
|
||||||
alphabetic_order_fields: field_layouts,
|
alphabetic_order_fields: field_layouts,
|
||||||
|
@ -2499,6 +2510,8 @@ fn specialize_external<'a>(
|
||||||
union_layout,
|
union_layout,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// let symbol = get_specialized_name(**symbol, **layout);
|
||||||
|
|
||||||
specialized_body = Stmt::Let(
|
specialized_body = Stmt::Let(
|
||||||
**symbol,
|
**symbol,
|
||||||
expr,
|
expr,
|
||||||
|
@ -2540,6 +2553,8 @@ fn specialize_external<'a>(
|
||||||
structure: Symbol::ARG_CLOSURE,
|
structure: Symbol::ARG_CLOSURE,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// let symbol = get_specialized_name(**symbol, **layout);
|
||||||
|
|
||||||
specialized_body = Stmt::Let(
|
specialized_body = Stmt::Let(
|
||||||
**symbol,
|
**symbol,
|
||||||
expr,
|
expr,
|
||||||
|
@ -2585,8 +2600,9 @@ fn specialize_external<'a>(
|
||||||
.map(|&(layout, symbol)| {
|
.map(|&(layout, symbol)| {
|
||||||
let symbol = procs
|
let symbol = procs
|
||||||
.needed_symbol_specializations
|
.needed_symbol_specializations
|
||||||
.get(&(symbol, layout))
|
// We can remove the specialization since this is the definition site.
|
||||||
.map(|(_, specialized_symbol)| *specialized_symbol)
|
.remove(&(symbol, layout))
|
||||||
|
.map(|(_, specialized_symbol)| specialized_symbol)
|
||||||
.unwrap_or(symbol);
|
.unwrap_or(symbol);
|
||||||
|
|
||||||
(layout, symbol)
|
(layout, symbol)
|
||||||
|
@ -3002,19 +3018,25 @@ fn specialize_naked_symbol<'a>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
use roc_can::expr::Expr;
|
let mut symbol = symbol;
|
||||||
if let ReuseSymbol::Value(_symbol) = can_reuse_symbol(env, procs, &Expr::Var(symbol)) {
|
|
||||||
let real_symbol =
|
|
||||||
possible_reuse_symbol_or_spec(env, procs, layout_cache, &Expr::Var(symbol), variable);
|
|
||||||
return match hole {
|
|
||||||
Stmt::Jump(id, _) => Stmt::Jump(*id, env.arena.alloc([real_symbol])),
|
|
||||||
_ => Stmt::Ret(real_symbol),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
let result = match hole {
|
let result = match hole {
|
||||||
Stmt::Jump(id, _) => Stmt::Jump(*id, env.arena.alloc([symbol])),
|
Stmt::Jump(id, _) => Stmt::Jump(*id, env.arena.alloc([symbol])),
|
||||||
_ => Stmt::Ret(symbol),
|
_ => {
|
||||||
|
use roc_can::expr::Expr;
|
||||||
|
if let ReuseSymbol::Value(_symbol) = can_reuse_symbol(env, procs, &Expr::Var(symbol)) {
|
||||||
|
let real_symbol = possible_reuse_symbol_or_spec(
|
||||||
|
env,
|
||||||
|
procs,
|
||||||
|
layout_cache,
|
||||||
|
&Expr::Var(symbol),
|
||||||
|
variable,
|
||||||
|
);
|
||||||
|
symbol = real_symbol;
|
||||||
|
Stmt::Ret(real_symbol)
|
||||||
|
} else {
|
||||||
|
Stmt::Ret(symbol)
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// if the symbol is a function symbol, ensure it is properly specialized!
|
// if the symbol is a function symbol, ensure it is properly specialized!
|
||||||
|
@ -4717,6 +4739,7 @@ fn get_specialization<'a>(
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn construct_closure_data<'a, I>(
|
fn construct_closure_data<'a, I>(
|
||||||
env: &mut Env<'a, '_>,
|
env: &mut Env<'a, '_>,
|
||||||
|
// procs: &mut Procs<'a>,
|
||||||
lambda_set: LambdaSet<'a>,
|
lambda_set: LambdaSet<'a>,
|
||||||
name: Symbol,
|
name: Symbol,
|
||||||
symbols: I,
|
symbols: I,
|
||||||
|
@ -4730,6 +4753,16 @@ where
|
||||||
let lambda_set_layout = Layout::LambdaSet(lambda_set);
|
let lambda_set_layout = Layout::LambdaSet(lambda_set);
|
||||||
let symbols = symbols.into_iter();
|
let symbols = symbols.into_iter();
|
||||||
|
|
||||||
|
// It may be the case that while capturing a symbol, we actually want to capture it under a
|
||||||
|
// different name than what the
|
||||||
|
// let get_specialized_name = |symbol, layout| {
|
||||||
|
// procs
|
||||||
|
// .needed_symbol_specializations
|
||||||
|
// .get(&(symbol, layout))
|
||||||
|
// .map(|(_, specialized)| *specialized)
|
||||||
|
// .unwrap_or(symbol)
|
||||||
|
// };
|
||||||
|
|
||||||
let result = match lambda_set.layout_for_member(name) {
|
let result = match lambda_set.layout_for_member(name) {
|
||||||
ClosureRepresentation::Union {
|
ClosureRepresentation::Union {
|
||||||
tag_id,
|
tag_id,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue