Emit retags in codegen to support BorrowSanitizer (part 5) - #159245
Merged
rust-bors[bot] merged 2 commits intoAug 1, 2026
Conversation
This comment has been minimized.
This comment has been minimized.
icmccorm
force-pushed
the
codegen-emit-retag-5
branch
from
July 20, 2026 20:04
b7d93a2 to
a3a56d7
Compare
Collaborator
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
saethlin
reviewed
Jul 30, 2026
icmccorm
force-pushed
the
codegen-emit-retag-5
branch
from
July 30, 2026 15:49
e06b5d4 to
a87d3c3
Compare
Member
|
@bors r+ |
Contributor
jhpratt
added a commit
to jhpratt/rust
that referenced
this pull request
Aug 1, 2026
…-5, r=saethlin Emit retags in codegen to support BorrowSanitizer (part 5) Tracking issue: rust-lang#154760 [Zulip Thread](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Staging.20for.20emitting.20retags.20in.20codegen/with/592364811) This is one of several PRs that add experimental support for emitting retags as function calls in codegen. This PR adds support for emitting global arrays that specify the ranges of interior mutable and pinned data. For example, ```rust fn cell(x: &(i32, Cell<i32>)) { ... } ``` This program will have IR similar to the following: ```llvm @anon.0 = unnamed_addr constant [16 x i8] c"\04...\04..." define void @cell(ptr %0) { start: %x = call ptr @__rust_retag_reg(ptr %0, i64 8, i8 1, ptr @anon.0, ptr null) ... } ``` The last four bytes at offset four are interior mutable. Users can disable this behavior by passing `no-precise-im` or `no-precise-pin` as options to `-Zcodegen-emit-retag`. In that case, the last two parameters to the retag intrinsic will always be null pointers. BorrowSanitizer will be able to switch to using nightly once this is merged. Thank you @saethlin for reviewing these PRs! Note: we still do not support retagging SIMD types, since cg-ssa does not support `insertelement`. Related: rust-lang#158100 Cc: @RalfJung r? @saethlin
jhpratt
added a commit
to jhpratt/rust
that referenced
this pull request
Aug 1, 2026
…-5, r=saethlin Emit retags in codegen to support BorrowSanitizer (part 5) Tracking issue: rust-lang#154760 [Zulip Thread](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Staging.20for.20emitting.20retags.20in.20codegen/with/592364811) This is one of several PRs that add experimental support for emitting retags as function calls in codegen. This PR adds support for emitting global arrays that specify the ranges of interior mutable and pinned data. For example, ```rust fn cell(x: &(i32, Cell<i32>)) { ... } ``` This program will have IR similar to the following: ```llvm @anon.0 = unnamed_addr constant [16 x i8] c"\04...\04..." define void @cell(ptr %0) { start: %x = call ptr @__rust_retag_reg(ptr %0, i64 8, i8 1, ptr @anon.0, ptr null) ... } ``` The last four bytes at offset four are interior mutable. Users can disable this behavior by passing `no-precise-im` or `no-precise-pin` as options to `-Zcodegen-emit-retag`. In that case, the last two parameters to the retag intrinsic will always be null pointers. BorrowSanitizer will be able to switch to using nightly once this is merged. Thank you @saethlin for reviewing these PRs! Note: we still do not support retagging SIMD types, since cg-ssa does not support `insertelement`. Related: rust-lang#158100 Cc: @RalfJung r? @saethlin
This was referenced Aug 1, 2026
rust-bors Bot
pushed a commit
that referenced
this pull request
Aug 1, 2026
Rollup of 14 pull requests Successful merges: - #159245 (Emit retags in codegen to support BorrowSanitizer (part 5)) - #159864 (Report "capacity overflow" for oversized Rc<[T]>/Arc<[T]>) - #160079 (make atomic operations const) - #160124 (Structurally prevent zero-count `BackendRepr::SimdVector`s) - #160162 (Make `#[fundamental]` only apply to the first argument of `Box`) - #160210 (Remove an outdated FIXME) - #160282 (Improve diagnostic for patterns in function pointer types) - #157928 (Eagerly fetch typeck results when linting) - #159672 (Improve suggestions when multiples tuples implement the same trait) - #159861 (Add documentation for the `non_exhaustive` attribute) - #159907 (Fix `hidden_glob_reexports` in `rustc_ast`) - #159998 (Align expect messages with guidance) - #160145 (Expand checks for register_tool) - #160307 (Update `minifier` version to `0.4.0`)
rust-timer
added a commit
that referenced
this pull request
Aug 1, 2026
Rollup merge of #159245 - BorrowSanitizer:codegen-emit-retag-5, r=saethlin Emit retags in codegen to support BorrowSanitizer (part 5) Tracking issue: #154760 [Zulip Thread](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Staging.20for.20emitting.20retags.20in.20codegen/with/592364811) This is one of several PRs that add experimental support for emitting retags as function calls in codegen. This PR adds support for emitting global arrays that specify the ranges of interior mutable and pinned data. For example, ```rust fn cell(x: &(i32, Cell<i32>)) { ... } ``` This program will have IR similar to the following: ```llvm @anon.0 = unnamed_addr constant [16 x i8] c"\04...\04..." define void @cell(ptr %0) { start: %x = call ptr @__rust_retag_reg(ptr %0, i64 8, i8 1, ptr @anon.0, ptr null) ... } ``` The last four bytes at offset four are interior mutable. Users can disable this behavior by passing `no-precise-im` or `no-precise-pin` as options to `-Zcodegen-emit-retag`. In that case, the last two parameters to the retag intrinsic will always be null pointers. BorrowSanitizer will be able to switch to using nightly once this is merged. Thank you @saethlin for reviewing these PRs! Note: we still do not support retagging SIMD types, since cg-ssa does not support `insertelement`. Related: #158100 Cc: @RalfJung r? @saethlin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tracking issue: #154760
Zulip Thread
This is one of several PRs that add experimental support for emitting retags as function calls in codegen.
This PR adds support for emitting global arrays that specify the ranges of interior mutable and pinned data. For example,
This program will have IR similar to the following:
The last four bytes at offset four are interior mutable.
Users can disable this behavior by passing
no-precise-imorno-precise-pinas options to-Zcodegen-emit-retag. In that case, the last two parameters to the retag intrinsic will always be null pointers.BorrowSanitizer will be able to switch to using nightly once this is merged. Thank you @saethlin for reviewing these PRs!
Note: we still do not support retagging SIMD types, since cg-ssa does not support
insertelement.Related: #158100
Cc: @RalfJung
r? @saethlin