Skip to content

Fix -Wunreachable-code-break findings in fbcode/executorch, xplat/executorch - #24155

Open
r-barnes wants to merge 1 commit into
pytorch:mainfrom
r-barnes:export-D127368223
Open

r-barnes wants to merge 1 commit into
pytorch:mainfrom
r-barnes:export-D127368223

Conversation

@r-barnes

Copy link
Copy Markdown
Contributor

Summary:
D127334907 enables -Wunreachable-code-break through the PACKAGE files of fbcode/example, fbcode/excalibur, fbcode/executorch, fbcode/experience-ai, xplat/executorch. This diff fixes the code that warning flags there, so the PACKAGE change builds cleanly on top of it.

Fixes the new warning in executorch (fbcode side edited; the xplat/executorch dirsync mirror is identical): removes break; statements that can never run because the preceding statement always leaves the case. In devtools/bundled_program/bundled_program.cpp they follow ET_CHECK_OR_RETURN_ERROR(false, ...) (always returns) or return; in extension/fb/ptez/ptez_data_loader.cpp and runtime/executor/method_meta.cpp (get_tag) they follow return; in backends/vulkan/runtime/vk_api/Pipeline.cpp (vk_layout) the inner switch returns on every path. Behavior is unchanged.

Removes unreachable break; statements in Vulkan test and tool code (fbcode side edited; the xplat/executorch mirror is identical): backends/vulkan/test/utils/test_utils.cpp (after throw), backends/vulkan/test/vulkan_compute_api_test.cpp (after an inner switch that returns on every path), and backends/vulkan/fb/tools/cli/{benchmark,correctness}/optparser.cpp (after exit(1)).

Reviewed By: dtolnay

Differential Revision: D127368223

…t/executorch`

Summary:
D127334907 enables `-Wunreachable-code-break` through the PACKAGE files of `fbcode/example`, `fbcode/excalibur`, `fbcode/executorch`, `fbcode/experience-ai`, `xplat/executorch`. This diff fixes the code that warning flags there, so the PACKAGE change builds cleanly on top of it.

Fixes the new warning in executorch (fbcode side edited; the `xplat/executorch` dirsync mirror is identical): removes `break;` statements that can never run because the preceding statement always leaves the case. In `devtools/bundled_program/bundled_program.cpp` they follow `ET_CHECK_OR_RETURN_ERROR(false, ...)` (always returns) or `return`; in `extension/fb/ptez/ptez_data_loader.cpp` and `runtime/executor/method_meta.cpp` (`get_tag`) they follow `return`; in `backends/vulkan/runtime/vk_api/Pipeline.cpp` (`vk_layout`) the inner `switch` returns on every path. Behavior is unchanged.

Removes unreachable `break;` statements in Vulkan test and tool code (fbcode side edited; the `xplat/executorch` mirror is identical): `backends/vulkan/test/utils/test_utils.cpp` (after `throw`), `backends/vulkan/test/vulkan_compute_api_test.cpp` (after an inner `switch` that returns on every path), and `backends/vulkan/fb/tools/cli/{benchmark,correctness}/optparser.cpp` (after `exit(1)`).

Reviewed By: dtolnay

Differential Revision: D127368223
Copilot AI balanced review requested due to automatic review settings October 26, 2026 16:40
@pytorch-bot

pytorch-bot Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/24155

Note: Links to docs will display an error until the docs builds have been completed.

✅ You can merge normally! (1 Unrelated Failure)

As of commit 56eadce with merge base f1de711 (image):

BROKEN TRUNK - The following job failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 26, 2026
@meta-codesync

meta-codesync Bot commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

@r-barnes has exported this pull request. If you are a Meta employee, you can view the originating Diff in D127368223.

@github-actions

Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

Copilot AI 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.

🟢 Approval recommended

The supplied changes remove only unreachable statements, preserve existing control flow, and have no unresolved findings.

No open issues 🎉

What changed in this PR

Removes unreachable break; statements from ExecuTorch runtime, bundled-program utilities, and Vulkan code to support enabling -Wunreachable-code-break without changing behavior.

Changes:

  • Removes redundant breaks after returns, error-return macros, and a throw.
  • Removes breaks after nested switches that return on every path.
File Description
runtime/​executor/​method_meta.cpp Removes breaks after tag returns.
devtools/​bundled_program/​bundled_program.cpp Removes breaks after error returns.
backends/​vulkan/​test/​vulkan_compute_api_test.cpp Removes a break after an always-returning switch.
backends/​vulkan/​test/​utils/​test_utils.cpp Removes a break after a throw.
backends/​vulkan/​runtime/​vk_api/​Pipeline.cpp Removes a break after an always-returning layout switch.

Review effort: Balanced

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants