Skip to content

Rework SetIsReq and overlay and combine them into a single function - #1424

Merged
vgvassilev merged 1 commit into
vgvassilev:masterfrom
PetroZarytskyi:var-use
Jun 29, 2025
Merged

Rework SetIsReq and overlay and combine them into a single function#1424
vgvassilev merged 1 commit into
vgvassilev:masterfrom
PetroZarytskyi:var-use

Conversation

@PetroZarytskyi

Copy link
Copy Markdown
Collaborator

The problem this PR solves is explained in detail in #1423. For short, when we set vars to used/unused in TBR, we handle constant array indices (like arr[3]) in TBR::SetIsRequired and partly cover the gaps in the logic in TBR::overlay. This PR moves handling of all cases to TBR::SetIsRequired and fixes the bug in #1423. Also, this PR removes the state variable TBR::m_NonConstIndexFound that was used to detect the cases when TBR::overlay should be called.
Apart from that, ProfileID sequences are now reversed to the right order for easier handling: the sequence of arr[2].k used to be {k, 2} and is now {2, k}. Iterating backwards through the sequence in recursion resulted in code that was quite hard to read.

Fixes #1423

@codecov

codecov Bot commented Jun 28, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

Comment thread lib/Differentiator/TBRAnalyzer.cpp
Comment thread lib/Differentiator/TBRAnalyzer.h Outdated
Comment thread lib/Differentiator/TBRAnalyzer.h Outdated
@github-actions

Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

The problem this PR solves is explained in detail in vgvassilev#1423. For short, when we set vars to `used`/`unused` in TBR, we handle constant array indices (like `arr[3]`) in `TBR::SetIsRequired` and partly cover the gaps in the logic in `TBR::overlay`. This PR moves handling of all cases to `TBR::SetIsRequired` and fixes the bug in vgvassilev#1423. Also, this PR removes the state variable `TBR::m_NonConstIndexFound` that was used to detect the cases when `TBR::overlay` should be called.
Apart from that, `ProfileID` sequences are now reversed to the right order for easier handling: the sequence of `arr[2].k` used to be `{k, 2}` and is now `{2, k}`. Iterating backwards through the sequence in recursion resulted in code that was quite hard to read.

Fixes vgvassilev#1423
@github-actions

Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@vgvassilev vgvassilev left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

LGTM!

@vgvassilev
vgvassilev merged commit 2c0c325 into vgvassilev:master Jun 29, 2025
89 checks passed
@PetroZarytskyi
PetroZarytskyi deleted the var-use branch June 29, 2025 11:50
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.

If a constant element is used, mark the default index as used as well in TBR

2 participants