Skip to content

Conversation

durin42
Copy link
Contributor

@durin42 durin42 commented Sep 22, 2025

LLVM change dfbd76bda01e removed separate remark support entirely, but
it turns out we can just drop the parameter and everything appears to
work fine.

Fixes #146912 as far as I can tell (the test passes.)

@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. 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 Sep 22, 2025
@rustbot
Copy link
Collaborator

rustbot commented Sep 22, 2025

r? @cuviper

rustbot has assigned @cuviper.
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

@rustbot rustbot added the llvm-main Marks PRs that are making Rust work with LLVM main (this label is consumed by CI tooling) label Sep 22, 2025
@rust-log-analyzer

This comment has been minimized.

@durin42
Copy link
Contributor Author

durin42 commented Sep 22, 2025

I've logged #146912 for the future work required on this. I didn't do enough digging today to figure out if the feature even makes sense with the changes in LLVM.

@durin42 durin42 force-pushed the llvm-22-bitstream-remarks branch from 36e8c75 to f9c040b Compare September 22, 2025 21:23
@cuviper
Copy link
Member

cuviper commented Sep 22, 2025

Won't we need something like //@ max-llvm-major-version: 21 on the remarks-dir tests?

Copy link
Contributor

@nikic nikic left a comment

Choose a reason for hiding this comment

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

Given the additional information in #146912, we should not land this patch and instead make the minor necessary changes to support the change.

View changes since this review

@durin42 durin42 force-pushed the llvm-22-bitstream-remarks branch from f9c040b to 2ef90bb Compare September 23, 2025 17:21
@rustbot

This comment has been minimized.

@durin42 durin42 force-pushed the llvm-22-bitstream-remarks branch from 2ef90bb to 156cfb3 Compare September 23, 2025 17:23
@rustbot

This comment has been minimized.

@durin42 durin42 changed the title llvm: disable remarks support on LLVM 22 llvm: update remarks support on LLVM 22 Sep 23, 2025
LLVM change dfbd76bda01e removed separate remark support entirely, but
it turns out we can just drop the parameter and everything appears to
work fine.

Fixes 146912 as far as I can tell (the test passes.)

@rustbot label llvm-main
@durin42 durin42 force-pushed the llvm-22-bitstream-remarks branch from 156cfb3 to 42cf78f Compare September 23, 2025 17:25
@cuviper
Copy link
Member

cuviper commented Sep 23, 2025

The upgrade remarks also mention release/finalization:

You can safely remove SerializerMode::Separate from createRemarkSerializer(). If you move the created Serializer into LLVMRemarkStreamer, you will have to call LLVMRemarkStreamer::releaseSerializer() once you're done emitting Remarks. Calling llvm::finalizeLLVMOptimizationRemarks() can do this for you.

I'm not sure off-hand where that should go...

@nikic
Copy link
Contributor

nikic commented Sep 24, 2025

If I understand correctly, we should get an assertion failure if we're using it incorrectly. Assuming the tests don't assert on LLVM 22, we should be fine.

@Prabhuk
Copy link

Prabhuk commented Sep 24, 2025

@nikic -- I do not fully understand the context here but our builders are broken and this patch could unblock us. What else that needs to happen here to land this change besides the concern about necessary finalization?

@durin42
Copy link
Contributor Author

durin42 commented Sep 24, 2025

If I understand correctly, we should get an assertion failure if we're using it incorrectly. Assuming the tests don't assert on LLVM 22, we should be fine.

They don't assert as far as I can tell. Our buildkite has been happy with this patch applied.

@nikic
Copy link
Contributor

nikic commented Sep 24, 2025

If I understand correctly, we should get an assertion failure if we're using it incorrectly. Assuming the tests don't assert on LLVM 22, we should be fine.

They don't assert as far as I can tell. Our buildkite has been happy with this patch applied.

Is that with or without the rm -rf tests/run-make/optimization-remarks-dir buildkite is doing?

@durin42
Copy link
Contributor Author

durin42 commented Sep 24, 2025

Shoot, I forgot we'd also done that. I just ran that test on my workstation with this PR applied at LLVM HEAD and it's passing without any assertion output that I see:

python3 x.py test tests/ui/zero-sized/zero-sized-btreemap-insert.rs
Building bootstrap
    Finished `dev` profile [unoptimized] target(s) in 0.14s
Building stage1 compiler artifacts (stage0 -> stage1, x86_64-unknown-linux-gnu)
    Finished `release` profile [optimized] target(s) in 0.40s
Creating a sysroot for stage1 compiler (use `rustup toolchain link 'name' build/host/stage1`)
Building stage1 lld-wrapper (stage0 -> stage1, x86_64-unknown-linux-gnu)
    Finished `release` profile [optimized] target(s) in 0.15s
Building stage1 library artifacts (stage1 -> stage1, x86_64-unknown-linux-gnu)
    Finished `release` profile [optimized] target(s) in 0.05s
Building stage1 compiletest (stage0 -> stage1, x86_64-unknown-linux-gnu)
    Finished `release` profile [optimized] target(s) in 0.20s
Building test helpers for x86_64-unknown-linux-gnu
Testing stage1 with compiletest suite=ui mode=ui (x86_64-unknown-linux-gnu)

running 1 tests
.

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 19817 filtered out; finished in 332.67ms

Build completed successfully in 0:00:02

@cuviper
Copy link
Member

cuviper commented Sep 24, 2025

You need LLVM_ENABLE_ASSERTIONS=ON too, and this does fail for me:

rustc: /home/jistone/llvm-project/llvm/lib/Remarks/RemarkStreamer.cpp:38: llvm::remarks::RemarkStreamer::~RemarkStreamer(): Assertion `!RemarkSerializer && "RemarkSerializer must be released before RemarkStreamer is " "destroyed. Ensure llvm::finalizeOptimizationRemarks is called."' failed.

@nikic
Copy link
Contributor

nikic commented Sep 24, 2025

Okay, then we do need a call to finalizeOptimizationRemarks(). I think the destructor of RustDiagnosticHandler would work for that purpose?

@cuviper
Copy link
Member

cuviper commented Sep 24, 2025

I added a destructor, and it fixes the assertion while passing our test.

r? nikic

@rustbot rustbot assigned nikic and unassigned cuviper Sep 24, 2025
@rust-log-analyzer
Copy link
Collaborator

A job failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)

@nikic nikic closed this Sep 25, 2025
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 25, 2025
@nikic nikic reopened this Sep 25, 2025
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 25, 2025
@nikic
Copy link
Contributor

nikic commented Sep 25, 2025

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Sep 25, 2025

📌 Commit fe440ec has been approved by nikic

It is now in the queue for this repository.

@bors bors 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 Sep 25, 2025
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Sep 25, 2025
… r=nikic

llvm: update remarks support on LLVM 22

LLVM change dfbd76bda01e removed separate remark support entirely, but
it turns out we can just drop the parameter and everything appears to
work fine.

Fixes rust-lang#146912 as far as I can tell (the test passes.)
bors added a commit that referenced this pull request Sep 25, 2025
Rollup of 14 pull requests

Successful merges:

 - #145067 (RawVecInner: add missing `unsafe` to unsafe fns)
 - #145277 (Do not materialise X in [X; 0] when X is unsizing a const)
 - #145973 (Add `std` support for `armv7a-vex-v5`)
 - #146667 (Add an attribute to check the number of lanes in a SIMD vector after monomorphization)
 - #146735 (unstably constify float mul_add methods)
 - #146737 (f16_f128: enable some more tests in Miri)
 - #146766 (Add attributes for #[global_allocator] functions)
 - #146905 (llvm: update remarks support on LLVM 22)
 - #146982 (Remove erroneous normalization step in `tests/run-make/linker-warning`)
 - #147005 (Small string formatting cleanup)
 - #147007 (Explicitly note `&[SocketAddr]` impl of `ToSocketAddrs`)
 - #147008 (bootstrap.py: Respect build.jobs while building bootstrap tool)
 - #147013 (rustdoc: Fix documentation for `--doctest-build-arg`)
 - #147015 (Use `LLVMDisposeTargetMachine`)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 2565b27 into rust-lang:master Sep 25, 2025
12 of 20 checks passed
@rustbot rustbot added this to the 1.92.0 milestone Sep 25, 2025
rust-timer added a commit that referenced this pull request Sep 25, 2025
Rollup merge of #146905 - durin42:llvm-22-bitstream-remarks, r=nikic

llvm: update remarks support on LLVM 22

LLVM change dfbd76bda01e removed separate remark support entirely, but
it turns out we can just drop the parameter and everything appears to
work fine.

Fixes #146912 as far as I can tell (the test passes.)
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Sep 26, 2025
Rollup of 14 pull requests

Successful merges:

 - rust-lang/rust#145067 (RawVecInner: add missing `unsafe` to unsafe fns)
 - rust-lang/rust#145277 (Do not materialise X in [X; 0] when X is unsizing a const)
 - rust-lang/rust#145973 (Add `std` support for `armv7a-vex-v5`)
 - rust-lang/rust#146667 (Add an attribute to check the number of lanes in a SIMD vector after monomorphization)
 - rust-lang/rust#146735 (unstably constify float mul_add methods)
 - rust-lang/rust#146737 (f16_f128: enable some more tests in Miri)
 - rust-lang/rust#146766 (Add attributes for #[global_allocator] functions)
 - rust-lang/rust#146905 (llvm: update remarks support on LLVM 22)
 - rust-lang/rust#146982 (Remove erroneous normalization step in `tests/run-make/linker-warning`)
 - rust-lang/rust#147005 (Small string formatting cleanup)
 - rust-lang/rust#147007 (Explicitly note `&[SocketAddr]` impl of `ToSocketAddrs`)
 - rust-lang/rust#147008 (bootstrap.py: Respect build.jobs while building bootstrap tool)
 - rust-lang/rust#147013 (rustdoc: Fix documentation for `--doctest-build-arg`)
 - rust-lang/rust#147015 (Use `LLVMDisposeTargetMachine`)

r? `@ghost`
`@rustbot` modify labels: rollup
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. llvm-main Marks PRs that are making Rust work with LLVM main (this label is consumed by CI tooling) 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.

LLVM 22: optimization remarks no longer support "separate" mode
7 participants