Repository navigation
Loop IDs that do not count pseudo-loops - #9637
Draft
tautschnig wants to merge 1 commit into
Draft
tautschnig wants to merge 1 commit into
tautschnig wants to merge 1 commit into
Conversation
Loop IDs of the form F.N number all loops of function F, including
pseudo-loops: loops whose condition is constant false, such as the
do { ... } while(0) that C macros commonly expand to. Adding or removing
such a macro before a loop therefore changes the ID of that loop, and
--unwindset settings silently stop applying to the intended loop. In
mlkem-native, a change to debug-assertion macros turned
polyvec_basemul_acc_montgomery_cached.3 into .0, and for 37 mainline
commits an UNWINDSET entry .0 bounded the do-while(0) of a bounds-check
macro instead of the loop it was meant for.
--show-loops now also shows a loop ID of the form F.L-N for each loop
that is not a pseudo-loop, where N only counts such loops, and
--unwindset accepts these IDs. Pseudo-loops have no such ID, so a loop
added later never takes over an ID that belonged to a pseudo-loop. IDs
of the form F.N keep their meaning; `-` cannot occur in labels, so the
new form cannot be mistaken for a label either. As a bound for a
pseudo-loop has no effect, --unwindset now warns when a loop ID refers
to one.
Replaying the histories of mlkem-native and mldsa-native (1151 pairs of
consecutive mainline commits that touch the sources or CBMC proofs, with
ground truth from a line diff of each loop's header) shows that F.L-N
would never have referred to the wrong loop for a loop named in an
UNWINDSET entry. Over all 1544 loops that a commit changed, F.L-N
referred to the wrong loop 7 times, compared to 19 times for F.N. F.L-N
still changes when a real loop is inserted earlier in the same
function.
Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
4 tasks done
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #9637 +/- ##
===========================================
+ Coverage 81.34% 81.36% +0.01%
===========================================
Files 1727 1728 +1
Lines 191715 191809 +94
Branches 73 73
===========================================
+ Hits 155950 156062 +112
+ Misses 35765 35747 -18 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Collaborator
|
Should we not pursue the idea of a "structural hash" ID for loops? The pseudo-loops then don't really bother anymore, and loop IDs might be more stable. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Loop IDs of the form F.N number all loops of function F, including pseudo-loops: loops whose condition is constant false, such as the do { ... } while(0) that C macros commonly expand to. Adding or removing such a macro before a loop therefore changes the ID of that loop, and --unwindset settings silently stop applying to the intended loop. In mlkem-native, a change to debug-assertion macros turned polyvec_basemul_acc_montgomery_cached.3 into .0, and for 37 mainline commits an UNWINDSET entry .0 bounded the do-while(0) of a bounds-check macro instead of the loop it was meant for.
--show-loops now also shows a loop ID of the form F.L-N for each loop that is not a pseudo-loop, where N only counts such loops, and --unwindset accepts these IDs. Pseudo-loops have no such ID, so a loop added later never takes over an ID that belonged to a pseudo-loop. IDs of the form F.N keep their meaning;
-cannot occur in labels, so the new form cannot be mistaken for a label either. As a bound for a pseudo-loop has no effect, --unwindset now warns when a loop ID refers to one.Replaying the histories of mlkem-native and mldsa-native (1151 pairs of consecutive mainline commits that touch the sources or CBMC proofs, with ground truth from a line diff of each loop's header) shows that F.L-N would never have referred to the wrong loop for a loop named in an UNWINDSET entry. Over all 1544 loops that a commit changed, F.L-N referred to the wrong loop 7 times, compared to 19 times for F.N. F.L-N still changes when a real loop is inserted earlier in the same function.