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

Ensure EoL at the end of trivia to prevent inlining issues #916

Conversation

drwcx
Copy link
Contributor

@drwcx drwcx commented Mar 14, 2024

This is a fix for the issue described in #914.

Functional evidence:

(base) drw@pirate slang % ./build/bin/slang ../inlining-repro/foo.sv ../inlining-repro/main.sv -I ../inlining-repro --single-unit --macros-only

BUS_WIDTH 2
SOMETHING 2
SV_COV_ASSERTION 20
SV_COV_CHECK 3
SV_COV_ERROR -1
SV_COV_FSM_STATE 21
SV_COV_HIER 11
SV_COV_MODULE 10
SV_COV_NOCOV 0
SV_COV_OK 1
SV_COV_OVERFLOW -2
SV_COV_PARTIAL 2
SV_COV_RESET 2
SV_COV_START 0
SV_COV_STATEMENT 22
SV_COV_STOP 1
SV_COV_TOGGLE 23
__slang__ 1
__slang_major__ 5
__slang_minor__ 0
(base) drw@pirate slang % git log -1
commit 594e3aaab7bd76458da9997c72749227c5ef2e80 (HEAD -> fix/ensure-eof-trivia-to-prevent-inlining-issues, origin/fix/ensure-eof-trivia-to-prevent-inlining-issues)
Author: drw <[email protected]>
Date:   Thu Mar 14 13:44:15 2024 -0700

    Ensure EoF at the end of trivia to prevent inlining issues

Before:

(base) drw@pirate slang % ./build/bin/slang ../inlining-repro/foo.sv ../inlining-repro/main.sv -I ../inlining-repro --single-unit --macros-only

SOMETHING 2`include "defs.svh"
SV_COV_ASSERTION 20
SV_COV_CHECK 3
SV_COV_ERROR -1
SV_COV_FSM_STATE 21
SV_COV_HIER 11
SV_COV_MODULE 10
SV_COV_NOCOV 0
SV_COV_OK 1
SV_COV_OVERFLOW -2
SV_COV_PARTIAL 2
SV_COV_RESET 2
SV_COV_START 0
SV_COV_STATEMENT 22
SV_COV_STOP 1
SV_COV_TOGGLE 23
__slang__ 1
__slang_major__ 5
__slang_minor__ 0
(base) drw@pirate slang % git log -1
commit cad562f821a575728e65f5414375c7cb94d2d124 (HEAD -> master, origin/master, origin/HEAD)
Author: MikePopoloski <[email protected]>
Date:   Wed Mar 13 20:09:09 2024 -0400

    Add explicit test for function result chaining

Copy link
Owner

@MikePopoloski MikePopoloski left a comment

Choose a reason for hiding this comment

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

This looks good but can you add a test to PreprocessorTests.cpp to cover the problem?

Copy link

codecov bot commented Mar 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.84%. Comparing base (cad562f) to head (71e28fb).
Report is 22 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #916      +/-   ##
==========================================
+ Coverage   93.75%   93.84%   +0.08%     
==========================================
  Files         190      190              
  Lines       47784    47925     +141     
==========================================
+ Hits        44799    44973     +174     
+ Misses       2985     2952      -33     
Files Coverage Δ
source/parsing/Preprocessor.cpp 99.86% <100.00%> (+<0.01%) ⬆️

... and 55 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cad562f...71e28fb. Read the comment docs.

@drwcx drwcx changed the title Ensure EoF at the end of trivia to prevent inlining issues Ensure EoL at the end of trivia to prevent inlining issues Mar 19, 2024
@drwcx
Copy link
Contributor Author

drwcx commented Mar 19, 2024

With patch commented out the unit test fails:

Test project /home/morty/slang/build
    Start 1: unittests
1/6 Test #1: unittests ........................***Failed    0.69 sec
data/file_uses_define_in_file_with_no_cr.sv:2:5: error: member not allowed at compilation unit scope
    initial begin
    ^~~~~~~~~~~~~
data/file_uses_define_in_file_with_no_cr.sv:3:32: error: expected ','
        $display("Something: %d", `SOMETHING);
                                  ^
data/file_with_no_cr.sv:1:23: note: expanded from macro 'SOMETHING'
`define SOMETHING 1337
                      ^
data/file_uses_define_in_file_with_no_cr.sv:3:44: error: expected ')'
        $display("Something: %d", `SOMETHING);
                                              ^
data/file_uses_define_in_file_with_no_cr.sv:3:14: note: to match this '('
        $display("Something: %d", `SOMETHING);
                ^
data/file_uses_define_in_file_with_no_cr.sv:5:1: error: expected member
endmodule
^~~~~~~~~
Randomness seeded to: 420428605

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
unittests is a Catch2 v3.5.3 host application.
Run with -? for options

-------------------------------------------------------------------------------
Driver single-unit parsing files with no EOL
-------------------------------------------------------------------------------
/home/morty/slang/tests/unittests/DriverTests.cpp:244
...............................................................................

/home/morty/slang/tests/unittests/DriverTests.cpp:253: FAILED:
  CHECK( driver.reportParseDiags() )
with expansion:
  false

===============================================================================
test cases:  1590 |  1589 passed | 1 failed
assertions: 18619 | 18618 passed | 1 failed

@MikePopoloski MikePopoloski merged commit 29785c8 into MikePopoloski:master Mar 23, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants