Skip to content

Fix IRList::structural_equals to ignore MFLOW_FALLTHROUGH - #997

Open
rootkiller6788 wants to merge 2 commits into
facebook:mainfrom
rootkiller6788:fix-irlist-structural-equals-fallthrough
Open

Fix IRList::structural_equals to ignore MFLOW_FALLTHROUGH#997
rootkiller6788 wants to merge 2 commits into
facebook:mainfrom
rootkiller6788:fix-irlist-structural-equals-fallthrough

Conversation

@rootkiller6788

Copy link
Copy Markdown
Contributor

Fixes #778

IRList::structural_equals compared every entry in the IR lists, including MFLOW_FALLTHROUGH no-ops, so two methods that differ only in the placement of a no-op (e.g. an unreferenced label lowered to FALLTHROUGH) were reported as not structurally equal. Trailing metadata/no-op entries after the last real instruction also caused a mismatch when the other list had already been fully consumed.

This change skips metadata and FALLTHROUGH entries on both sides before each comparison step, and skips any remaining trailing no-ops after the main loop. Unit tests are added for leading and trailing FALLTHROUGH entries, plus a negative case ensuring real differences are still detected.

structural_equals compared every entry in the IR lists, including
MFLOW_FALLTHROUGH no-ops. Two methods that differ only by a no-op
placement (e.g. one has an unreferenced label lowered to FALLTHROUGH)
were reported as not structurally equal. Trailing metadata/no-op
entries after the last real instruction also caused a mismatch when the
other list had already been fully consumed.

Skip metadata and FALLTHROUGH entries on both sides before each
comparison step, and skip any remaining trailing no-ops after the main
loop. Add unit tests covering leading and trailing FALLTHROUGH entries.

Closes facebook#778
@meta-cla meta-cla Bot added the CLA Signed label Aug 21, 2026
structural_equals is a const method, so m_list.begin() and other.begin()
return IRList::const_iterator. The skip_noops lambda declared its first
parameter as IRList::iterator&, so the calls at the top of the loop did
not match (no known conversion from const_iterator to iterator&), which
broke the build on GCC (both linux and windows).

Use IRList::const_iterator& for the iterator parameter so the lambda
accepts the iterators that a const comparison actually works with.
@rootkiller6788

Copy link
Copy Markdown
Contributor Author

Hi, thanks for the feedback!

This PR makes IRList::structural_equals ignore MFLOW_FALLTHROUGH no-op entries and trailing no-op/metadata so that identical methods are no longer reported as unequal purely because of fallthrough placement. I also pushed a follow-up commit fixing the GCC compile error in the skip_noops lambda (const_iterator type) that was failing the Linux GCC builds (gcc:latest, ubuntu:24.04, ubuntu:26.04). The change is limited to libredex/IRList.cpp and adds unit coverage for the fallthrough cases.

Could you please re-run the CI / take another look? Thanks!

@rootkiller6788
rootkiller6788 marked this pull request as ready for review August 27, 2026 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IRList.structural_equals doesn't handle some instructions

1 participant