Skip to content

Emit retags in codegen to support BorrowSanitizer (part 2)#156210

Merged
rust-bors[bot] merged 5 commits into
rust-lang:mainfrom
BorrowSanitizer:codegen-emit-retag-2
Jun 4, 2026
Merged

Emit retags in codegen to support BorrowSanitizer (part 2)#156210
rust-bors[bot] merged 5 commits into
rust-lang:mainfrom
BorrowSanitizer:codegen-emit-retag-2

Conversation

@icmccorm
Copy link
Copy Markdown
Contributor

@icmccorm icmccorm commented May 5, 2026

Tracking issue: #154760
Zulip Thread

This is one of several PRs that will add experimental support for emitting retags as function calls in codegen. Each PR will be a minimal, improved slice of the changes in #155965.

This PR adds a new unstable flag -Zcodegen-emit-retag, which will enable experimental retag calls in generated code. This flag is a nop for now, but the relevant methods have been added to codegen_ssa, and they are called wherever retags are necessary. Subsequent PRs will complete this implementation.

This does not depend on #156208.

r? @RalfJung

@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 May 5, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 5, 2026

RalfJung is not on the review rotation at the moment.
They may take a while to respond.

@saethlin
Copy link
Copy Markdown
Member

saethlin commented May 5, 2026

r? saethlin

@rustbot rustbot assigned saethlin and unassigned RalfJung May 5, 2026
@rust-log-analyzer

This comment has been minimized.

@icmccorm icmccorm force-pushed the codegen-emit-retag-2 branch from 951a9ed to 4e3df71 Compare May 7, 2026 17:02
@rustbot

This comment has been minimized.

@icmccorm
Copy link
Copy Markdown
Contributor Author

icmccorm commented May 7, 2026

Now that #154327 has been merged, we no longer need special handling for drop glue.

@rust-bors

This comment has been minimized.

@icmccorm icmccorm force-pushed the codegen-emit-retag-2 branch from 4e3df71 to 5135340 Compare May 15, 2026 16:53
@rustbot

This comment has been minimized.

LocalRef::PendingOperand => LocalRef::PendingOperand,
})
.collect::<Vec<_>>();
// If we branched during retagging, then we need to update the
Copy link
Copy Markdown
Member

@saethlin saethlin May 18, 2026

Choose a reason for hiding this comment

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

How would retagging introduce a branch?

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We selectively retag variants of enums that contain references or Box. For example,

fn foo(opt: Option<Box<i32>>) { .. }

This will branch on the discriminant of opt to retag the Box, if it's there.

Comment thread compiler/rustc_codegen_ssa/src/mir/block.rs Outdated
Comment thread compiler/rustc_codegen_ssa/src/mir/retag.rs Outdated
@icmccorm icmccorm force-pushed the codegen-emit-retag-2 branch from 5135340 to 23602aa Compare May 20, 2026 18:54
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 20, 2026

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
Copy link
Copy Markdown
Member

saethlin commented Jun 4, 2026

@bors r+ rollup=iffy

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Jun 4, 2026

📌 Commit 23602aa has been approved by saethlin

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 Jun 4, 2026
rust-bors Bot pushed a commit that referenced this pull request Jun 4, 2026
Rollup of 3 pull requests

Successful merges:

 - #156210 (Emit retags in codegen to support BorrowSanitizer (part 2))
 - #157317 (Fix ICE when wrong intra-doc link on type alias)
 - #157391 (Reorganize `tests/ui/issues` [4/N])
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Jun 4, 2026

⌛ Testing commit 23602aa with merge 509a1fb...

Workflow: https://github.com/rust-lang/rust/actions/runs/26929479425

rust-bors Bot pushed a commit that referenced this pull request Jun 4, 2026
Emit retags in codegen to support BorrowSanitizer (part 2)

Tracking issue: #154760 
[Zulip Thread](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Staging.20for.20emitting.20retags.20in.20codegen/with/593004012)

This is one of several PRs that will add experimental support for emitting retags as function calls in codegen. Each PR will be a minimal, improved slice of the changes in #155965.

This PR adds a new unstable flag `-Zcodegen-emit-retag`, which will enable experimental retag calls in generated code. This flag is a nop for now, but the relevant methods have been added to codegen_ssa, and they are called wherever retags are necessary. Subsequent PRs will complete this implementation.

This does not depend on #156208. 

r? @RalfJung
@jhpratt
Copy link
Copy Markdown
Member

jhpratt commented Jun 4, 2026

@bors yield

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Jun 4, 2026

Auto build was cancelled. Cancelled workflows:

The next pull request likely to be tested is #157404.

rust-bors Bot pushed a commit that referenced this pull request Jun 4, 2026
Rollup of 3 pull requests

Successful merges:

 - #156210 (Emit retags in codegen to support BorrowSanitizer (part 2))
 - #157317 (Fix ICE when wrong intra-doc link on type alias)
 - #157391 (Reorganize `tests/ui/issues` [4/N])
@rust-bors rust-bors Bot merged commit fa82c8d into rust-lang:main Jun 4, 2026
11 of 12 checks passed
@rustbot rustbot added this to the 1.98.0 milestone Jun 4, 2026
rust-timer added a commit that referenced this pull request Jun 4, 2026
Rollup merge of #156210 - BorrowSanitizer:codegen-emit-retag-2, r=saethlin

Emit retags in codegen to support BorrowSanitizer (part 2)

Tracking issue: #154760
[Zulip Thread](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Staging.20for.20emitting.20retags.20in.20codegen/with/593004012)

This is one of several PRs that will add experimental support for emitting retags as function calls in codegen. Each PR will be a minimal, improved slice of the changes in #155965.

This PR adds a new unstable flag `-Zcodegen-emit-retag`, which will enable experimental retag calls in generated code. This flag is a nop for now, but the relevant methods have been added to codegen_ssa, and they are called wherever retags are necessary. Subsequent PRs will complete this implementation.

This does not depend on #156208.

r? @RalfJung
@icmccorm icmccorm deleted the codegen-emit-retag-2 branch June 7, 2026 21:12
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