Emit retags in codegen to support BorrowSanitizer (part 1)#156208
Conversation
|
The GCC codegen subtree was changed |
|
r? @jackh726 rustbot has assigned @jackh726. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
r? saethlin |
824ce42 to
e15861b
Compare
|
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. |
|
@bors r+ |
…-1, r=saethlin Emit retags in codegen to support BorrowSanitizer (part 1) 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/593004012) This is the first 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 rust-lang#155965. This PR contains all of the changes that will affect codegen backends. It adds methods to `IntrinsicCallBuilderMethods` for emitting each kind of retag call. cc: @RalfJung
|
@bors try jobs=aarch64-apple |
|
⌛ Trying commit e15861b with merge e6b753f… To cancel the try build, run the command Workflow: https://github.com/rust-lang/rust/actions/runs/25990798832 |
Emit retags in codegen to support BorrowSanitizer (part 1) try-job: aarch64-apple
|
@bors try cancel |
|
Try build cancelled. Cancelled workflows: |
…uwer Rollup of 14 pull requests Successful merges: - #151742 (Remove redundant information in `rustc_abi::Variants`) - #151362 (Add interior-mutability suggestion to `static_mut_refs`) - #156121 (compiler: suggest `.collect()` when `String` is expected and `Iterator` is found) - #156208 (Emit retags in codegen to support BorrowSanitizer (part 1)) - #156596 (Split `LintExpectationId`s) - #156607 (ci: Update FreeBSD version to FreeBSD 14) - #156376 (suggest hex escapes for C-style escapes) - #156577 (Test EII UI tests with prefer-dynamic) - #156585 (explicit tail calls: ignore some tests on unsupported LLVM targets) - #156598 (Avoid rustfix suggestions for macro-expanded unused imports) - #156616 (rustdoc: add test case for `-Drustdoc::` and `--cap-lints`) - #156633 (Add regression test for issue #41261) - #156635 (rename unexpected_try_recover function) - #156636 (minor `rustc_mir_transform` cleanup)
…uwer Rollup of 14 pull requests Successful merges: - #151742 (Remove redundant information in `rustc_abi::Variants`) - #151362 (Add interior-mutability suggestion to `static_mut_refs`) - #156121 (compiler: suggest `.collect()` when `String` is expected and `Iterator` is found) - #156208 (Emit retags in codegen to support BorrowSanitizer (part 1)) - #156596 (Split `LintExpectationId`s) - #156607 (ci: Update FreeBSD version to FreeBSD 14) - #156376 (suggest hex escapes for C-style escapes) - #156577 (Test EII UI tests with prefer-dynamic) - #156585 (explicit tail calls: ignore some tests on unsupported LLVM targets) - #156598 (Avoid rustfix suggestions for macro-expanded unused imports) - #156616 (rustdoc: add test case for `-Drustdoc::` and `--cap-lints`) - #156633 (Add regression test for issue #41261) - #156635 (rename unexpected_try_recover function) - #156636 (minor `rustc_mir_transform` cleanup)
Rollup merge of #156208 - BorrowSanitizer:codegen-emit-retag-1, r=saethlin Emit retags in codegen to support BorrowSanitizer (part 1) 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 the first 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 contains all of the changes that will affect codegen backends. It adds methods to `IntrinsicCallBuilderMethods` for emitting each kind of retag call. cc: @RalfJung
…uwer Rollup of 14 pull requests Successful merges: - rust-lang/rust#151742 (Remove redundant information in `rustc_abi::Variants`) - rust-lang/rust#151362 (Add interior-mutability suggestion to `static_mut_refs`) - rust-lang/rust#156121 (compiler: suggest `.collect()` when `String` is expected and `Iterator` is found) - rust-lang/rust#156208 (Emit retags in codegen to support BorrowSanitizer (part 1)) - rust-lang/rust#156596 (Split `LintExpectationId`s) - rust-lang/rust#156607 (ci: Update FreeBSD version to FreeBSD 14) - rust-lang/rust#156376 (suggest hex escapes for C-style escapes) - rust-lang/rust#156577 (Test EII UI tests with prefer-dynamic) - rust-lang/rust#156585 (explicit tail calls: ignore some tests on unsupported LLVM targets) - rust-lang/rust#156598 (Avoid rustfix suggestions for macro-expanded unused imports) - rust-lang/rust#156616 (rustdoc: add test case for `-Drustdoc::` and `--cap-lints`) - rust-lang/rust#156633 (Add regression test for issue rust-lang/rust#41261) - rust-lang/rust#156635 (rename unexpected_try_recover function) - rust-lang/rust#156636 (minor `rustc_mir_transform` cleanup)
…-2, r=saethlin Emit retags in codegen to support BorrowSanitizer (part 2) 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/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 rust-lang#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 rust-lang#156208. r? @RalfJung
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
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
…-3, r=saethlin Emit retags in codegen to support BorrowSanitizer (part 3) 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/593004012) This is one of several PRs that will add experimental support for emitting retags as function calls in codegen. This PR adds `RetagPlan`, which describes where the pointers that need to be retagged live within the layout of a type. We create a `RetagPlan` ahead of time because only a subset of the variants of a type might contain retagable values. We only want to branch to these variants, and ignore all of the others. If a type can generate a `RetagPlan`, then we will use it as a guide for inserting calls to our retag intrinsics. If a type does not generate a `RetagPlan`, then it does not need to be retagged, and we can skip it. This does not emit a `RetagPlan::EmitRetag` yet. That will come in a subsequent PR. Previous parts: rust-lang#156208, rust-lang#156210 cc: @RalfJung r? @saethlin
Rollup merge of #157825 - BorrowSanitizer:codegen-emit-retag-3, r=saethlin Emit retags in codegen to support BorrowSanitizer (part 3) 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. This PR adds `RetagPlan`, which describes where the pointers that need to be retagged live within the layout of a type. We create a `RetagPlan` ahead of time because only a subset of the variants of a type might contain retagable values. We only want to branch to these variants, and ignore all of the others. If a type can generate a `RetagPlan`, then we will use it as a guide for inserting calls to our retag intrinsics. If a type does not generate a `RetagPlan`, then it does not need to be retagged, and we can skip it. This does not emit a `RetagPlan::EmitRetag` yet. That will come in a subsequent PR. Previous parts: #156208, #156210 cc: @RalfJung r? @saethlin
…-4, r=saethlin Emit retags in codegen to support BorrowSanitizer (part 4) 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/593004012) This is one of several PRs that add experimental support for emitting retags as function calls in codegen. This PR emits our retag intrinsics based on the structure of a `RetagPlan`. The feature works end-to-end now! But, it has two limitations: * We do not track interior mutable or pinned ranges precisely. This will come in the next PR, which should be the last one that we need to complete this feature (excluding documentation and compile tests). * We recurse into `repr(simd)` types when building a `RetagPlan`, but we do not emit retags for their fields. We would need `BuilderMethods::insert_element`, which isn't available. I'm not sure what the best workaround would be for this. Related: rust-lang#157825, rust-lang#156210, rust-lang#156208 Cc: @RalfJung r? @saethlin
Tracking issue: #154760
Zulip Thread
This is the first 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 contains all of the changes that will affect codegen backends. It adds methods to
IntrinsicCallBuilderMethodsfor emitting each kind of retag call.cc: @RalfJung