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

Support variable declaration in for loop setup #117

Merged
merged 1 commit into from
Mar 21, 2024

Conversation

ChAoSUnItY
Copy link
Collaborator

  • Resolve Declare variables where needed #115 , this allows variables declare in the scope of for loop body, to avoid loose variable liveness, in other word, variable can have stricter scope liveness by declaring in setup section of for loop.

@jserv jserv requested a review from vacantron March 4, 2024 03:13
@jserv
Copy link
Collaborator

jserv commented Mar 4, 2024

CI complains below:

tests/check-snapshots.sh
Files /dev/fd/63 and /dev/fd/62 differ
Error: writing output failed: Broken pipe
cat: write error: Broken pipe
Files /dev/fd/63 and /dev/fd/62 differ

@vacantron, can you help resolve?

tests/driver.sh Outdated Show resolved Hide resolved
src/parser.c Outdated Show resolved Hide resolved
@vacantron
Copy link
Collaborator

vacantron commented Mar 4, 2024

CI complains below:

tests/check-snapshots.sh
Files /dev/fd/63 and /dev/fd/62 differ
Error: writing output failed: Broken pipe
cat: write error: Broken pipe
Files /dev/fd/63 and /dev/fd/62 differ

@vacantron, can you help resolve?

The new cfront feature is going to change the CFGs. Use tests/update-snapshots.sh to update the outdated ones.

By the way, the changes causes the inconsistent behavior with GCC build while unwinding the phi instruction in the second stage, and breaks the self-hosting. I'm trying to figure it out.

jserv

This comment was marked as resolved.

@vacantron
Copy link
Collaborator

vacantron commented Mar 17, 2024

Rebase the master branch after #113 being merged, and re-run the tests/update-snapshots.sh . The error should be solved.

@ChAoSUnItY
Copy link
Collaborator Author

That's weird, I updated snapshot after rebase and it still panics on stage 2.

@vacantron
Copy link
Collaborator

vacantron commented Mar 18, 2024

That's weird, I updated snapshot after rebase and it still panics on stage 2.

The second stage is broken by the SSA now, but the snapshot test should be passed tho.

I run head -c20 tests/snapshots/xxx.json | tail -c19 for the hello and fib, and both of them has 469 basic blocks. It is definitely incorrect. The fib one should have ten more than the hello. Can you try it again with make distclean and make config ARCH=arm ?

@ChAoSUnItY
Copy link
Collaborator Author

Can you try it again with make disclean and make config ARCH=arm ?

After running disclean and config ARCH=arm, now running tests/update-snapshots.sh would stuck forever (I terminted it after running for 2.6 mins). Can you confirm this weird behavior?

@vacantron
Copy link
Collaborator

After running disclean and config ARCH=arm, now running tests/update-snapshots.sh would stuck forever (I terminted it after running for 2.6 mins). Can you confirm this weird behavior?

There is a typo in the commands that I provided previously. Try make distclean config ARCH=riscv out/shecc-stage1.elf and tests/update-snapshots.sh again. Do you run them on Linux?

@ChAoSUnItY
Copy link
Collaborator Author

ChAoSUnItY commented Mar 19, 2024

Do you run them on Linux?

Yes, specifically, on Arch Linux.

Try make distclean config ARCH=riscv out/shecc-stage1.elf and tests/update-snapshots.sh again.

It still failed on stage 2.

@vacantron
Copy link
Collaborator

Yes, specifically, on Arch Linux.

Can you test the jq command with -S option separately on your machine? The result seems not to be sorted in ascending order by the _gvid.

@ChAoSUnItY
Copy link
Collaborator Author

ChAoSUnItY commented Mar 19, 2024

I can confirm that using jq -S -c . hello.json > hello.json (from tests/update-snapshot.sh) does only sorts entries by json keys but _gvid value.

@vacantron vacantron mentioned this pull request Mar 19, 2024
Copy link
Collaborator

@jserv jserv left a comment

Choose a reason for hiding this comment

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

Rebase the latest master branch and re-generate snapshots.

Copy link
Collaborator

@vacantron vacantron left a comment

Choose a reason for hiding this comment

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

Leave a blank line between the subject and the body of the commit message, and use git rebase -i to squash some commits

@jserv
Copy link
Collaborator

jserv commented Mar 20, 2024

Leave a blank line between the subject and the body of the commit message, and use git rebase -i to squash some commits

See also: https://cbea.ms/git-commit/

This allows variables declare in the scope of for loop body, to
avoid loose variable liveness, in other word, variable can have
stricter scope liveness.
@jserv jserv merged commit d9a989d into sysprog21:master Mar 21, 2024
4 checks passed
@jserv
Copy link
Collaborator

jserv commented Mar 21, 2024

Thank @ChAoSUnItY for contributing!

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.

Declare variables where needed
3 participants