Skip to content

Commit

Permalink
Fix assertion failure when dumping array-of-records. Issue xxx
Browse files Browse the repository at this point in the history
  • Loading branch information
nickg committed Sep 21, 2024
1 parent 894865a commit 132de2f
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 10 deletions.
4 changes: 0 additions & 4 deletions src/lower.c
Original file line number Diff line number Diff line change
Expand Up @@ -6048,10 +6048,6 @@ static void lower_signal_assign_target(lower_unit_t *lu, target_part_t **ptr,
lower_check_scalar_bounds(lu, src_reg, type, where, p->target);

if (!type_is_homogeneous(type)) {
// XXX: debug for issue #972
if (type_is_generic(type))
fatal_at(tree_loc(where), "generic type was not rewritten");

vcode_reg_t args[2] = { reject, after };
vcode_reg_t locus = lower_debug_locus(where);
lower_for_each_field_2(lu, type, src_type, p->reg, src_reg, locus,
Expand Down
8 changes: 2 additions & 6 deletions src/rt/wave.c
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,8 @@ static void fst_get_array_range(wave_dumper_t *wd, type_t type,
}
}

ffi_dim_t *dims = fst_get_ptr(wd, scope, where) + 2*sizeof(int64_t);
const ptrdiff_t slots = type_is_homogeneous(type) ? 2 : 1;
ffi_dim_t *dims = fst_get_ptr(wd, scope, where) + slots * sizeof(int64_t);

*left = dims[dim].left;
*right = ffi_array_right(dims[dim].left, dims[dim].length);
Expand Down Expand Up @@ -758,11 +759,6 @@ static void fst_create_record_array_var(wave_dumper_t *wd, tree_t d,
type_t elem = type_elem(type);
const bool nested = type_is_array(elem);

// XXX: debug for #972
if (count % length != 0)
warn_at(tree_loc(d), "record array has unexpected count=%d "
"length=%"PRIi64, count, length);

assert(count % length == 0);
const int stride = count / length;

Expand Down
16 changes: 16 additions & 0 deletions test/regress/gold/issue972.dump
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#0 issue972.b.o[0].f 00000000000000000000000000000000
#0 issue972.b.o[1].f 00000000000000000000000000000000
#0 issue972.b.i[0].f 00000000000000000000000000000000
#0 issue972.b.i[1].f 00000000000000000000000000000000
#0 issue972.y[0].f 00000000000000000000000000000000
#0 issue972.y[1].f 00000000000000000000000000000000
#0 issue972.x[0].f 00000000000000000000000000000000
#0 issue972.x[1].f 00000000000000000000000000000000
#1000000 issue972.x[1].f 00000000000000000000000000000001
#1000000 issue972.b.i[1].f 00000000000000000000000000000001
#2000000 issue972.b.i[1].f 00000000000000000000000000000010
#2000000 issue972.x[1].f 00000000000000000000000000000010
#2000000 issue972.y[1].f 00000000000000000000000000000001
#2000000 issue972.b.o[1].f 00000000000000000000000000000001
#3000000 issue972.b.o[1].f 00000000000000000000000000000010
#3000000 issue972.y[1].f 00000000000000000000000000000010
29 changes: 29 additions & 0 deletions test/regress/issue972.vhd
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
entity issue972 is
end entity;

architecture a of issue972 is
type t_rec is record
f : natural;
end record;

type t_array is array (natural range <>) of t_rec;

subtype t_ports is natural range 0 to 1;

signal x, y : t_array(t_ports'high downto 0);

begin

x <= (0 => (f => 0), 1 => (f => 1)) after 1 ns,
(0 => (f => 0), 1 => (f => 2)) after 2 ns;

b: block is
generic ( type t );
generic map ( t => t_array );
port ( i : in t; o : out t );
port map ( x, y );
begin
o <= i after 1 ns;
end block;

end architecture;
1 change: 1 addition & 0 deletions test/regress/testlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1048,3 +1048,4 @@ issue978 normal,vhpi
issue985 wave,2008,dump-arrays
issue970 normal,gold,2019
issue983 normal,relaxed
issue972 wave,2008,dump-arrays

0 comments on commit 132de2f

Please sign in to comment.