fix logic error

This commit is contained in:
Folkert 2023-05-17 22:49:59 +02:00
parent 58d4ae91d2
commit c24312a045
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
2 changed files with 32 additions and 23 deletions

View file

@ -2744,15 +2744,6 @@ impl<
match *nullable_id { match *nullable_id {
true => { true => {
ASM::neq_reg_reg_reg(
&mut self.buf,
RegisterWidth::W64,
dst_reg,
src1_reg,
src2_reg,
);
}
false => {
ASM::eq_reg_reg_reg( ASM::eq_reg_reg_reg(
&mut self.buf, &mut self.buf,
RegisterWidth::W64, RegisterWidth::W64,
@ -2761,7 +2752,18 @@ impl<
src2_reg, src2_reg,
); );
} }
false => {
ASM::neq_reg_reg_reg(
&mut self.buf,
RegisterWidth::W64,
dst_reg,
src1_reg,
src2_reg,
);
}
} }
self.free_symbol(&tmp);
} }
x => todo!("getting tag id of union with layout ({:?})", x), x => todo!("getting tag id of union with layout ({:?})", x),
}; };
@ -2778,10 +2780,12 @@ impl<
let layout_interner: &mut STLayoutInterner<'a> = self.layout_interner; let layout_interner: &mut STLayoutInterner<'a> = self.layout_interner;
let buf: &mut Vec<'a, u8> = &mut self.buf; let buf: &mut Vec<'a, u8> = &mut self.buf;
let (data_size, data_alignment) =
union_layout.data_size_and_alignment(layout_interner, target_info);
match union_layout { match union_layout {
UnionLayout::NonRecursive(field_layouts) => { UnionLayout::NonRecursive(field_layouts) => {
let (data_size, data_alignment) =
union_layout.data_size_and_alignment(layout_interner, target_info);
let id_offset = data_size - data_alignment; let id_offset = data_size - data_alignment;
let base_offset = self.storage_manager.claim_stack_area(sym, data_size); let base_offset = self.storage_manager.claim_stack_area(sym, data_size);
let mut current_offset = base_offset; let mut current_offset = base_offset;
@ -2820,23 +2824,28 @@ impl<
other_fields, other_fields,
} => { } => {
if tag_id == *nullable_id as TagIdIntType { if tag_id == *nullable_id as TagIdIntType {
// step 1: make the struct // it's just a null pointer
self.load_literal_i64(sym, 0);
} else {
// construct the payload as a struct on the stack
let temp_sym = Symbol::DEV_TMP5; let temp_sym = Symbol::DEV_TMP5;
let layout = let layout = self
layout_interner.insert_no_semantic(LayoutRepr::Struct(other_fields)); .layout_interner
.insert_no_semantic(LayoutRepr::Struct(other_fields));
self.load_literal_symbols(fields);
self.storage_manager.create_struct( self.storage_manager.create_struct(
layout_interner, self.layout_interner,
buf, &mut self.buf,
&temp_sym, &temp_sym,
&layout, &layout,
fields, fields,
); );
// now effectively box this struct // now effectively box this struct
self.expr_box(*sym, Symbol::DEV_TMP5, layout) self.expr_box(*sym, temp_sym, layout);
} else {
// it's just a null pointer self.free_symbol(&temp_sym);
self.load_literal_i64(sym, 0);
} }
} }
x => todo!("creating unions with layout: {:?}", x), x => todo!("creating unions with layout: {:?}", x),

View file

@ -1244,7 +1244,7 @@ fn return_wrapped_closure() {
} }
#[test] #[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] #[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn linked_list_is_singleton() { fn linked_list_is_singleton() {
assert_evals_to!( assert_evals_to!(
indoc!( indoc!(
@ -1314,7 +1314,7 @@ fn linked_list_is_empty_1() {
} }
#[test] #[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] #[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn linked_list_is_empty_2() { fn linked_list_is_empty_2() {
assert_evals_to!( assert_evals_to!(
indoc!( indoc!(
@ -1346,7 +1346,7 @@ fn linked_list_is_empty_2() {
} }
#[test] #[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] #[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn linked_list_singleton() { fn linked_list_singleton() {
// verifies only that valid llvm is produced // verifies only that valid llvm is produced
assert_evals_to!( assert_evals_to!(