Skip to content

Conversation

durin42
Copy link
Contributor

@durin42 durin42 commented Sep 18, 2025

LLVM 22 is able to drop assumes that seem to not help further optimizations, which actually seems to dramatically help further optimizations in some of our small test cases.

I'm a little unclear how to fix the last failure, in tests/codegen-llvm/issues/issue-122600-ptr-discriminant-update.rs:

-; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite, inaccessiblemem: write) uwtable
+; Function Attrs: mustprogress nofree norecurse nosync nounwind nonlazybind willreturn memory(argmem: readwrite, inaccessiblemem: write) uwtable
 define void @update(ptr noundef captures(none) %s) unnamed_addr #0 {
 start:
-  %_3.sroa.0.0.copyload = load i8, ptr %s, align 1
-  %0 = trunc nuw i8 %_3.sroa.0.0.copyload to i1
-  %1 = xor i1 %0, true
-  tail call void @llvm.assume(i1 %1)
   store i8 1, ptr %s, align 1
   ret void
 }

I'm just not conversant enough in LLVM IR to follow the changes here.

@rustbot label llvm-main
r? nikic

@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. llvm-main Marks PRs that are making Rust work with LLVM main (this label is consumed by CI tooling) labels Sep 18, 2025
@rust-log-analyzer

This comment has been minimized.

@durin42
Copy link
Contributor Author

durin42 commented Sep 18, 2025

@rustbot label +S-waiting-on-author -S-waiting-on-review

Well that's annoying, I'll have to figure out how to make it pass on LLVM 21 as well as 22.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 18, 2025
LLVM 22 is able to drop assumes that seem to not help further
optimizations, which actually seems to dramatically _help_ further
optimizations in some of our small test cases.
@durin42 durin42 force-pushed the llvm-22-less-assumes branch from 8f97242 to e32b975 Compare September 19, 2025 17:56
@durin42
Copy link
Contributor Author

durin42 commented Sep 19, 2025

Updated, all three tests should now pass on LLVM 22+ and LLVM < 22. I decided to just accept the two disappeared instructions in issue-122600-ptr-discriminant-update.rs since it sounds like the CHECK-NOT bits were the actually-important parts.

@durin42
Copy link
Contributor Author

durin42 commented Sep 19, 2025

@rustbot label -S-waiting-on-author +S-waiting-on-review

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 19, 2025
aarongable pushed a commit to chromium/chromium that referenced this pull request Sep 24, 2025
llvm/llvm-project#159403 adds a pass which
causes the tests in question to fail because it removes several calls to
`llvm.assume(...)`. The fix at
rust-lang/rust#146732 effectively neuters the
test, so we may as well temporarily disable it on our side.

Bug: 446928953
Change-Id: Iade597d144e68bf384076673b75f2f3f616de5b8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6977874
Auto-Submit: Alan Zhao <[email protected]>
Reviewed-by: Hans Wennborg <[email protected]>
Commit-Queue: Hans Wennborg <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1519796}
@nikic
Copy link
Contributor

nikic commented Sep 26, 2025

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Sep 26, 2025

📌 Commit 99456cc 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 26, 2025
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Sep 27, 2025
tests: relax expectations after llvm change 902ddda120a5

LLVM 22 is able to drop assumes that seem to not help further optimizations, which actually seems to dramatically _help_ further optimizations in some of our small test cases.

I'm a little unclear how to fix the last failure, in `tests/codegen-llvm/issues/issue-122600-ptr-discriminant-update.rs`:

```
-; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite, inaccessiblemem: write) uwtable
+; Function Attrs: mustprogress nofree norecurse nosync nounwind nonlazybind willreturn memory(argmem: readwrite, inaccessiblemem: write) uwtable
 define void `@update(ptr` noundef captures(none) %s) unnamed_addr #0 {
 start:
-  %_3.sroa.0.0.copyload = load i8, ptr %s, align 1
-  %0 = trunc nuw i8 %_3.sroa.0.0.copyload to i1
-  %1 = xor i1 %0, true
-  tail call void `@llvm.assume(i1` %1)
   store i8 1, ptr %s, align 1
   ret void
 }
```

I'm just not conversant enough in LLVM IR to follow the changes here.

`@rustbot` label llvm-main
r? nikic
bors added a commit that referenced this pull request Sep 27, 2025
Rollup of 9 pull requests

Successful merges:

 - #140482 (std::net: update tcp deferaccept delay type to Duration.)
 - #146037 (Introduce CoerceShared lang item and trait, and basic Reborrow tests)
 - #146732 (tests: relax expectations after llvm change 902ddda120a5)
 - #147018 (re-order normalizations in run-make linker-warning test)
 - #147032 (Fix doctest compilation time display)
 - #147046 (Rename `rust.use-lld` to `rust.bootstrap-override-lld`)
 - #147050 (PassWrapper: update for new PGOOptions args in LLVM 22)
 - #147075 (Make `def_path_hash_to_def_id` not panic when passed an invalid hash)
 - #147076 (update issue number for more_float_constants)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Sep 27, 2025
Rollup of 8 pull requests

Successful merges:

 - #146037 (Introduce CoerceShared lang item and trait, and basic Reborrow tests)
 - #146732 (tests: relax expectations after llvm change 902ddda120a5)
 - #147018 (re-order normalizations in run-make linker-warning test)
 - #147032 (Fix doctest compilation time display)
 - #147046 (Rename `rust.use-lld` to `rust.bootstrap-override-lld`)
 - #147050 (PassWrapper: update for new PGOOptions args in LLVM 22)
 - #147075 (Make `def_path_hash_to_def_id` not panic when passed an invalid hash)
 - #147076 (update issue number for more_float_constants)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit c772af7 into rust-lang:master Sep 28, 2025
10 checks passed
@rustbot rustbot added this to the 1.92.0 milestone Sep 28, 2025
rust-timer added a commit that referenced this pull request Sep 28, 2025
Rollup merge of #146732 - durin42:llvm-22-less-assumes, r=nikic

tests: relax expectations after llvm change 902ddda120a5

LLVM 22 is able to drop assumes that seem to not help further optimizations, which actually seems to dramatically _help_ further optimizations in some of our small test cases.

I'm a little unclear how to fix the last failure, in `tests/codegen-llvm/issues/issue-122600-ptr-discriminant-update.rs`:

```
-; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite, inaccessiblemem: write) uwtable
+; Function Attrs: mustprogress nofree norecurse nosync nounwind nonlazybind willreturn memory(argmem: readwrite, inaccessiblemem: write) uwtable
 define void ``@update(ptr`` noundef captures(none) %s) unnamed_addr #0 {
 start:
-  %_3.sroa.0.0.copyload = load i8, ptr %s, align 1
-  %0 = trunc nuw i8 %_3.sroa.0.0.copyload to i1
-  %1 = xor i1 %0, true
-  tail call void ``@llvm.assume(i1`` %1)
   store i8 1, ptr %s, align 1
   ret void
 }
```

I'm just not conversant enough in LLVM IR to follow the changes here.

``@rustbot`` label llvm-main
r? nikic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

5 participants