Skip to content

Fix variable reference in ScanDominatorsForDefs#238

Closed
zchengchen wants to merge 1 commit intomozilla-firefox:mainfrom
zchengchen:main
Closed

Fix variable reference in ScanDominatorsForDefs#238
zchengchen wants to merge 1 commit intomozilla-firefox:mainfrom
zchengchen:main

Conversation

@zchengchen
Copy link
Copy Markdown
Contributor

Bug report:
https://bugzilla.mozilla.org/show_bug.cgi?id=2035965

The loop body uses the parameter block instead of the loop variable i:

static bool ScanDominatorsForDefs(MBasicBlock* block) {
  for (MBasicBlock* i = block;;) {
    if (BlockHasInterestingDefs(block)) {  // <-- should be `i`
      return true;
    }
    MBasicBlock* immediateDominator = i->immediateDominator();
    if (immediateDominator == i) {
      break;
    }
    i = immediateDominator;
  }
  return false;
}

Although i is updated on each iteration, it is never used in the loop body.
As a result, the function is effectively equivalent to:

return BlockHasInterestingDefs(block);
The intended dominator-chain traversal does not actually occur.

Expected results:

The loop should call BlockHasInterestingDefs(i), so that it correctly walks up
the dominator tree and checks each ancestor block.

This matches both the function comment:

"Walk up the dominator tree from block to the root and test for any defs"

and the behavior of the related two-argument overload.

Bug report:
https://bugzilla.mozilla.org/show_bug.cgi?id=2035965

Signed-off-by: Zhicheng Chen <84196090+zchengchen@users.noreply.github.com>
@firefoxci-taskcluster
Copy link
Copy Markdown

No Taskcluster jobs started for this pull request

The allowPullRequests configuration for this repository (in .taskcluster.yml on the default branch) does not allow starting tasks for this pull request.

@github-actions
Copy link
Copy Markdown
Contributor

(Automated Close) Please do not file pull requests here, see https://firefox-source-docs.mozilla.org/contributing/how_to_submit_a_patch.html

@github-actions github-actions Bot closed this Apr 30, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant