Skip to content

cg_llvm: Use an invariant lifetime brand for LLVM values - #165804

Open
Zalathar wants to merge 2 commits into
rust-lang:mainfrom
Zalathar:llval
Open

Zalathar wants to merge 2 commits into
rust-lang:mainfrom
Zalathar:llval

Conversation

@Zalathar

Copy link
Copy Markdown
Member

This PR changes the type of LLVM value references from &'ll Value to Value<'ll> with an invariant lifetime brand, to help uphold soundness of the FFI bindings.

There should be no change to compiler output.


Value is one of the more widely-used types, much more so than Type, so unfortunately this step ends up needing to touch quite a lot of code. Thankfully almost all of the changes are trivial.

This pulls some less-trivial changes out of the main migration to `Value<'ll>`.
@rustbot

rustbot commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in compiler/rustc_codegen_llvm/src/builder/autodiff.rs

cc @ZuseZ4

Some changes occurred in compiler/rustc_codegen_llvm/src/llvm/enzyme_ffi.rs

cc @ZuseZ4

Some changes occurred in compiler/rustc_codegen_llvm/src/debuginfo

cc @Walnut356

@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. F-autodiff `#![feature(autodiff)]` labels Nov 11, 2026
@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 Nov 11, 2026
@rustbot

rustbot commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator

r? @tmiasko

rustbot has assigned @tmiasko.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 79 candidates
  • Random selection from 21 candidates

@Zalathar

Copy link
Copy Markdown
Member Author

cc @hanna-kruppe

The bulk of the migration was done with a few simple regex-replaces, after which I went through and cleaned up all the resulting compile errors by hand. Then I eyeballed every changed line a few times (over multiple days) to check for any unexpected weirdness.

@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job test-x86_64-gnu-tools failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
[WARNING] line 38: Delta is 0 for "x", maybe try to use `compare-elements-position` instead?

======== tests/rustdoc-gui/sidebar-resize-setting.goml ========

[ERROR] line 30
    at `tests/rustdoc-gui/utils.goml` line 52
    at `tests/rustdoc-gui/utils.goml` line 42: Error: The following CSS properties still don't match: [expected `block` for key `display`, found `none`]: for command `wait-for-css: ("#settings", {"display": "block"})`
    at <file:///checkout/obj/build/x86_64-unknown-linux-gnu/test/rustdoc-gui/doc/test_docs/index.html>


<= doc-ui tests done: 155 succeeded, 1 failed, 0 filtered out

Error: ()

@tmiasko

tmiasko commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

@bors r+ p=1

@rust-bors

rust-bors Bot commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 6c0a3df has been approved by tmiasko

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 Nov 11, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 11, 2026
cg_llvm: Use an invariant lifetime brand for LLVM values

This PR changes the type of LLVM value references from `&'ll Value` to `Value<'ll>` with an invariant lifetime brand, to help uphold soundness of the FFI bindings.

There should be no change to compiler output.

---

Value is one of the more widely-used types, much more so than Type, so unfortunately this step ends up needing to touch quite a lot of code. Thankfully almost all of the changes are trivial.
rust-bors Bot pushed a commit that referenced this pull request Nov 12, 2026
…uwer

Rollup of 6 pull requests

Successful merges:

 - #165804 (cg_llvm: Use an invariant lifetime brand for LLVM values)
 - #165412 (Implement `core::ops::FnAddr`)
 - #165487 (Migrate built-in macros `pattern_type` & `view_type` to macros 2.0 that expand to internal syntax)
 - #165818 (do not lint `redundant_lifetimes` on items from external macros)
 - #164795 (Extend support of lint `explicit_outlives_requirements` to checked type aliases)
 - #165824 (Add regression test for HRTB projection bound with TryFrom error)
Zalathar added a commit to Zalathar/rust that referenced this pull request Nov 12, 2026
cg_llvm: Use an invariant lifetime brand for LLVM values

This PR changes the type of LLVM value references from `&'ll Value` to `Value<'ll>` with an invariant lifetime brand, to help uphold soundness of the FFI bindings.

There should be no change to compiler output.

---

Value is one of the more widely-used types, much more so than Type, so unfortunately this step ends up needing to touch quite a lot of code. Thankfully almost all of the changes are trivial.
rust-bors Bot pushed a commit that referenced this pull request Nov 12, 2026
Rollup of 12 pull requests

Successful merges:

 - #165804 (cg_llvm: Use an invariant lifetime brand for LLVM values)
 - #165778 (Bump stage0 to 1.101.0-beta.1)
 - #165412 (Implement `core::ops::FnAddr`)
 - #165487 (Migrate built-in macros `pattern_type` & `view_type` to macros 2.0 that expand to internal syntax)
 - #165818 (do not lint `redundant_lifetimes` on items from external macros)
 - #163077 (feat: support nested functions with `#[offload_kernel]`)
 - #164795 (Extend support of lint `explicit_outlives_requirements` to checked type aliases)
 - #165578 (Avoid `Hash::hash` when stable-hashing various types)
 - #165729 (tests: Add regression test for infinite recursive dereference)
 - #165819 (Avoid redundant scans when extracting stage0 archives)
 - #165822 (Remove unused compiler modules and types)
 - #165824 (Add regression test for HRTB projection bound with TryFrom error)
@rust-bors

rust-bors Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

⌛ Testing commit 6c0a3df with merge f2e7c29...

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

rust-bors Bot pushed a commit that referenced this pull request Nov 12, 2026
cg_llvm: Use an invariant lifetime brand for LLVM values



This PR changes the type of LLVM value references from `&'ll Value` to `Value<'ll>` with an invariant lifetime brand, to help uphold soundness of the FFI bindings.

There should be no change to compiler output.

---

Value is one of the more widely-used types, much more so than Type, so unfortunately this step ends up needing to touch quite a lot of code. Thankfully almost all of the changes are trivial.
Zalathar added a commit to Zalathar/rust that referenced this pull request Nov 12, 2026
cg_llvm: Use an invariant lifetime brand for LLVM values

This PR changes the type of LLVM value references from `&'ll Value` to `Value<'ll>` with an invariant lifetime brand, to help uphold soundness of the FFI bindings.

There should be no change to compiler output.

---

Value is one of the more widely-used types, much more so than Type, so unfortunately this step ends up needing to touch quite a lot of code. Thankfully almost all of the changes are trivial.
@Zalathar

Copy link
Copy Markdown
Member Author

@bors yield (enclosing rollup)

@rust-bors

rust-bors Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Auto build was cancelled. Cancelled workflows:

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

rust-bors Bot pushed a commit that referenced this pull request Nov 12, 2026
Rollup of 11 pull requests

Successful merges:

 - #165804 (cg_llvm: Use an invariant lifetime brand for LLVM values)
 - #165778 (Bump stage0 to 1.101.0-beta.1)
 - #165412 (Implement `core::ops::FnAddr`)
 - #165487 (Migrate built-in macros `pattern_type` & `view_type` to macros 2.0 that expand to internal syntax)
 - #165818 (do not lint `redundant_lifetimes` on items from external macros)
 - #163077 (feat: support nested functions with `#[offload_kernel]`)
 - #164795 (Extend support of lint `explicit_outlives_requirements` to checked type aliases)
 - #165578 (Avoid `Hash::hash` when stable-hashing various types)
 - #165729 (tests: Add regression test for infinite recursive dereference)
 - #165822 (Remove unused compiler modules and types)
 - #165824 (Add regression test for HRTB projection bound with TryFrom error)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. F-autodiff `#![feature(autodiff)]` 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.

4 participants