Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Moore] Fix the stacking fault caused by cast and remove unused headers #7219

Merged

Conversation

hailongSun2000
Copy link
Member

@hailongSun2000 hailongSun2000 commented Jun 20, 2024

Because every variable/net has been used by other ops. We must first read it. For example:

module foo(input clk, en, cin);
  reg q;
  always@(posedge clk) begin
          if(en) begin
             q <= cin;
          end
  end
endmodule      
moore.module @foo(in %clk : !moore.l1, in %en : !moore.l1, in %cin : !moore.l1) {
    %clk_0 = moore.net name "clk" wire : <l1>
    %en_1 = moore.net name "en" wire : <l1>
    %cin_2 = moore.net name "cin" wire : <l1>
    %q = moore.variable : <l1>
    moore.procedure always {
      %0 = moore.read %clk_0 : l1
      moore.wait_event posedge %0 : l1
      %1 = moore.read %en_1 : l1
      %2 = moore.conversion %1 : !moore.l1 -> i1
      scf.if %2 {
        %3 = moore.read %cin_2 : l1
        moore.nonblocking_assign %q, %3 : l1
      }
    }
    moore.assign %clk_0, %clk : l1
    moore.assign %en_1, %en : l1
    moore.assign %cin_2, %cin : l1
    moore.output
  }

SimplifyProcedures is through visit moore.read to get the user, but the user may be moore.net such as "clk". This situation will cause a segmentation fault.

@hailongSun2000 hailongSun2000 force-pushed the hailong/add-simplify-procedures-pass branch from c3f50cb to 69ef711 Compare June 20, 2024 07:48
@hailongSun2000 hailongSun2000 force-pushed the hailong/add-simplify-procedures-pass branch from 69ef711 to c871c38 Compare June 20, 2024 07:55
@hailongSun2000 hailongSun2000 merged commit c7f4557 into llvm:main Jun 20, 2024
4 checks passed
Copy link
Contributor

@fabianschuiki fabianschuiki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks!

uenoku pushed a commit that referenced this pull request Jul 3, 2024
@hailongSun2000 hailongSun2000 deleted the hailong/add-simplify-procedures-pass branch July 4, 2024 06:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants