YosysHQ / yosys

Yosys Open SYnthesis Suite
https://yosyshq.net/yosys/
ISC License
3.3k stars 860 forks source link

Another out-of-memory problem with for loop #4345

Open YikeZhou opened 2 months ago

YikeZhou commented 2 months ago

Version

Yosys 0.40+25 (git sha1 171577f90, clang++ 14.0.6 -fPIC -Os)

On which OS did this happen?

Linux

Reproduction Steps

Hello. After searching existing issues, I found #3447 and #3456. However, the problem I encountered seems different from those former ones. Therefore, I opened this new issue. Any help would be appreciated!

I managed to reduce the input program into oom.v as below:

module oom #(parameter P = 4);

function [31:0] foo;
  input [31:0]  x;
  begin
    foo = x;
  end
endfunction

localparam STEP = foo(P);
integer i;
  always @(*) begin
    for (i = 4; i >= 0; i=i-STEP) begin
      /* empty */
    end
  end

endmodule

Command:

yosys -p "read_verilog oom.v"

Expected Behavior

To perform read_verilog successfully.

Actual Behavior

Before the Yosys process got killed, it took nearly 20g of virtual memory on my PC.

Console output:

$ yosys -p "read_verilog oom.v"

 /----------------------------------------------------------------------------\
 |  yosys -- Yosys Open SYnthesis Suite                                       |
 |  Copyright (C) 2012 - 2024  Claire Xenia Wolf <claire@yosyshq.com>         |
 |  Distributed under an ISC-like license, type "license" to see terms        |
 \----------------------------------------------------------------------------/
 Yosys 0.40+25 (git sha1 171577f90, clang++ 14.0.6 -fPIC -Os)

-- Running command `read_verilog oom.v' --

1. Executing Verilog-2005 frontend: oom.v
Parsing Verilog input from `oom.v' to AST representation.
Generating RTLIL representation for module `\oom'.
Killed