rust-lang / rust-lang/rust

Does LLVM's quirk of counting in bits matter to us?

Open
#130,683 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-docs A-LLVM T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Location

In a lot of different places we document an isize::MAX limit on object sizes, for example, see this: https://doc.rust-lang.org/std/slice/fn.from_raw_parts.html

Summary

So, hypothetically, we "only" can have an object countable by LLVM within 64 bits:
https://github.com/rust-lang/rust/blob/55043f067dcf7067e7c6ebccf3639af94ff57bda/compiler/rustc_abi/src/lib.rs#L340-L350

However, hypothetically, we "should" be able to use an object that is isize::MAX bytes. These two facts contradict each other, since that suggests we should be able to have an object that is greater than 2^61 bytes. It is hard to validate whether or not LLVM miscompiles this, though, as most computers do not deal in greater than around 56 bits of address space.

Anyone working in HPC is encouraged to let us know?

Honestly, it's not even clear what we mean by "object" here. Allocation, probably?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the object-size limit documented for std::slice::from_raw_parts and the LLVM-related code in compiler/rustc_abi/src/lib.rs around lines 340-350. Clarify whether the relevant object is an allocation, how LLVM's bit-counting limit applies, and whether the documented isize::MAX limit is affected; done means a supported conclusion and any required documentation change.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers, documentation
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.