Skip to content

Fix/ref prop preserve field alignment - #164600

Open
YunusMutlu wants to merge 2 commits into
rust-lang:mainfrom
YunusMutlu:fix/ref-prop-preserve-field-alignment
Open

YunusMutlu wants to merge 2 commits into
rust-lang:mainfrom
YunusMutlu:fix/ref-prop-preserve-field-alignment

Conversation

@YunusMutlu

@YunusMutlu YunusMutlu commented Oct 19, 2026 •

Copy link
Copy Markdown

Fixes #164599

Summary

Problem: A read through a raw u32 field pointer can be transformed by ReferencePropagation into an access through a misaligned Aligned8 pointer.

Fix: This change adds a conservative guard that prevents potentially unsafe raw-pointer field projections from being recorded as replacement targets.

Validation: I reproduced the align 8 versus align 4 difference on both stable and nightly Rust. I also ran the codegen regression tests, the negative MIR test, and the positive reborrow test.

Limitation: The guard may prevent some otherwise safe optimizations. Its performance impact has not yet been measured.

@rustbot

rustbot commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 19, 2026
@rustbot

rustbot commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust Project has assigned @jieyouxu (or someone else) to review your changes, you should hear from them (or someone else) within the next two weeks.

Please see the contribution instructions and our LLM policy for more information.

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 77 candidates
  • Random selection from 18 candidates

@jieyouxu

Copy link
Copy Markdown
Member

r? mir-opt

@rustbot rustbot assigned oli-obk and unassigned jieyouxu Oct 20, 2026

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

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ReferencePropagation incorrectly increases alignment of raw field loads

4 participants