Skip to content

Comments

Tighten the !range bounds on alignments in vtables#152929

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
scottmcm:better-alignment-ranges
Feb 21, 2026
Merged

Tighten the !range bounds on alignments in vtables#152929
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
scottmcm:better-alignment-ranges

Conversation

@scottmcm
Copy link
Member

@scottmcm scottmcm commented Feb 21, 2026

Right now we're only telling LLVM that they're non-zero, but alignments must be powers of two so can't be more than isize::MAX+1. And we actually never emit anything beyond LLVM's limit of 2²⁹, so outside of 16-bit targets the limit is that.

(Pulled out from #152867 which is starting to have too much in it.)

@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 Feb 21, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 21, 2026

r? @adwinwhite

rustbot has assigned @adwinwhite.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: codegen, compiler
  • codegen, compiler expanded to 68 candidates
  • Random selection from 14 candidates

@adwinwhite
Copy link
Contributor

@rustbot reroll

@scottmcm
Copy link
Member Author

Oh, looks like the bot isn't picking from the narrower group.
r? codegen

@rustbot rustbot assigned saethlin and unassigned dingxiangfei2009 Feb 21, 2026
@mati865
Copy link
Member

mati865 commented Feb 21, 2026

Nice.

@bors r+

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 21, 2026

📌 Commit 0187acc has been approved by mati865

It is now in the queue for this repository.

@rust-bors rust-bors bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 21, 2026
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 21, 2026
…r=mati865

Tighten the `!range` bounds on alignments in vtables

Right now we're only telling LLVM that they're non-zero, but alignments must be powers of two so can't be more than `isize::MAX+1`.  And we actually never emit anything beyond LLVM's limit of 2²⁹, so outside of 16-bit targets the limit is that.

(Pulled out from rust-lang#152867 which is starting to have too much in it.)
rust-bors bot pushed a commit that referenced this pull request Feb 21, 2026
Rollup of 6 pull requests

Successful merges:

 - #152929 (Tighten the `!range` bounds on alignments in vtables)
 - #151603 (Stabilize `str_as_str`)
 - #152878 (Remove two more flaky assertions from `oneshot` tests)
 - #152915 (Error on attempt to construct scalable vector type)
 - #152925 (Improve runtest revision redundant cfg check)
 - #152928 (Update wasm-component-ld)
pub fn max_for_target(tdl: &TargetDataLayout) -> Align {
let pointer_bits = tdl.pointer_size().bits();
if let Ok(pointer_bits) = u8::try_from(pointer_bits)
&& pointer_bits <= Align::MAX.pow2
Copy link
Contributor

@dingxiangfei2009 dingxiangfei2009 Feb 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question, are we taking the max between Align::MAX.pow2 and pointer_bits, or between Align::MAX.pow2 and pointer_bits - 1?

Could this be what we actually want?

Suggested change
&& pointer_bits <= Align::MAX.pow2
&& pointer_bits - 1 <= Align::MAX.pow2

rust-bors bot pushed a commit that referenced this pull request Feb 21, 2026
Rollup of 6 pull requests

Successful merges:

 - #152929 (Tighten the `!range` bounds on alignments in vtables)
 - #151603 (Stabilize `str_as_str`)
 - #152878 (Remove two more flaky assertions from `oneshot` tests)
 - #152915 (Error on attempt to construct scalable vector type)
 - #152925 (Improve runtest revision redundant cfg check)
 - #152928 (Update wasm-component-ld)
@rust-bors rust-bors bot merged commit 7339fc5 into rust-lang:main Feb 21, 2026
11 checks passed
@rustbot rustbot added this to the 1.95.0 milestone Feb 21, 2026
rust-timer added a commit that referenced this pull request Feb 21, 2026
Rollup merge of #152929 - scottmcm:better-alignment-ranges, r=mati865

Tighten the `!range` bounds on alignments in vtables

Right now we're only telling LLVM that they're non-zero, but alignments must be powers of two so can't be more than `isize::MAX+1`.  And we actually never emit anything beyond LLVM's limit of 2²⁹, so outside of 16-bit targets the limit is that.

(Pulled out from #152867 which is starting to have too much in it.)
@scottmcm scottmcm deleted the better-alignment-ranges branch February 21, 2026 23:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

6 participants