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

Use liveness info to speed up allocation #965

Merged
merged 1 commit into from
Nov 29, 2024
Merged

Conversation

eponier
Copy link
Contributor

@eponier eponier commented Nov 25, 2024

The tables used in allocation can be huge. We remove the dead variables from the tables, to reduce their sizes and speed up the pass. Inspired by CompCert that does something similar to reduce the cost of the value analysis.

Please review carefully the changes to Liveness, because I don't know what I did.

On this implementation of Keccak, the time taken by the analysis after inlining goes down from 20s to 1.5s. It still feels too much for 4 inlined functions (size 1700, 3800 variables). (More functions are inlined, but these are the ones where the time is spent).

Comment on lines 55 to 56
let s_o' = if weak then Sv.add (L.unloc x) s_o else s_o in
let s_i, c = live_c weak c s_o' in
Copy link
Member

Choose a reason for hiding this comment

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

This looks wrong. s_o' should be s_o and x should be removed from s_i.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, this was certainly wrong. Is this better?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

libjade fails, so I guess it's wrong.

Copy link
Member

@vbgl vbgl left a comment

Choose a reason for hiding this comment

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

This change might deserve an entry in the changelog.

@eponier
Copy link
Contributor Author

eponier commented Nov 28, 2024

This change might deserve an entry in the changelog.

I added an item.

if Sv.subset s_i s_o then s_i, c
else loop (Sv.union s_i s_o) in
let s_i, c = loop s_o in
s_i, (if weak then Sv.add (L.unloc x) s_o else s_o), Cfor (x, r, c)
Copy link
Member

Choose a reason for hiding this comment

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

Why do you look at weak?

The variables occurring in the range are live before the for instruction.

The tables used in allocation can be huge. We remove the dead variables
from the tables, to reduce their sizes and speed up the pass.
@vbgl vbgl force-pushed the allocation-with-liveness branch from b2a2625 to f9714fb Compare November 29, 2024 07:59
@vbgl vbgl merged commit 89d0344 into main Nov 29, 2024
1 check passed
@vbgl vbgl deleted the allocation-with-liveness branch November 29, 2024 08:30
@eponier
Copy link
Contributor Author

eponier commented Nov 29, 2024

Thanks!

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