Skip to content

Emit retags in codegen to support BorrowSanitizer (part 5)#159245

Open
icmccorm wants to merge 1 commit into
rust-lang:mainfrom
BorrowSanitizer:codegen-emit-retag-5
Open

Emit retags in codegen to support BorrowSanitizer (part 5)#159245
icmccorm wants to merge 1 commit into
rust-lang:mainfrom
BorrowSanitizer:codegen-emit-retag-5

Conversation

@icmccorm

@icmccorm icmccorm commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

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,

fn cell(x: &(i32, Cell<i32>)) { ... }

This program will have IR similar to the following:

@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

@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 Jul 13, 2026
@rust-bors

rust-bors Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #159498) made this pull request unmergeable. Please resolve the merge conflicts by rebasing.

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.

3 participants