Skip to content

[WIP] Use assume rather than range metadata #122728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

dianqk
Copy link
Member

@dianqk dianqk commented Mar 19, 2024

Fixes #122726.

Currently, range can only be used in load, call and invoke instructions. Due to SROA being run before other passes, even in the simplest IR, LLVM cannot infer that %i1 is 0. Most of the range metadata will be dropped before they work.

define noundef i32 @src(i32 noundef %arg) {
  %i = alloca i32, align 4
  store i32 %arg, ptr %i, align 4
  %i1 = load i32, ptr %i, align 4, !range !0
  ret i32 %i1
}

https://alive2.llvm.org/ce/z/MjsH9b

r? @ghost

@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 Mar 19, 2024
@dianqk
Copy link
Member Author

dianqk commented Mar 19, 2024

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Mar 19, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 19, 2024
[WIP] Use assume rather than range metadata

Fixes rust-lang#122726.

Currently, range can only be used in load, call and invoke instructions. Due to SROA being run before other passes, even in the simplest IR, LLVM cannot infer that `%i1` is 0.

```llvm
define noundef i32 `@src(i32` noundef %arg) {
  %i = alloca i32, align 4
  store i32 %arg, ptr %i, align 4
  %i1 = load i32, ptr %i, align 4, !range !0
  ret i32 %i1
}
```

https://alive2.llvm.org/ce/z/MjsH9b

r? `@ghost`
@bors
Copy link
Collaborator

bors commented Mar 19, 2024

⌛ Trying commit f50d551 with merge 4c17eaa...

@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-llvm-17 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
#16 exporting to docker image format
#16 sending tarball 44.0s done
#16 DONE 62.0s
##[endgroup]
Setting extra environment values for docker:  --env ENABLE_GCC_CODEGEN=1 --env GCC_EXEC_PREFIX=/usr/lib/gcc/
[CI_JOB_NAME=x86_64-gnu-llvm-17]
##[group]Clock drift check
  local time: Tue Mar 19 14:05:17 UTC 2024
  network time: Tue, 19 Mar 2024 14:05:17 GMT
  network time: Tue, 19 Mar 2024 14:05:17 GMT
##[endgroup]
sccache: Starting the server...
##[group]Configure the build
configure: processing command line
configure: 
configure: build.configure-args := ['--build=x86_64-unknown-linux-gnu', '--llvm-root=/usr/lib/llvm-17', '--enable-llvm-link-shared', '--set', 'rust.thin-lto-import-instr-limit=10', '--set', 'change-id=99999999', '--enable-verbose-configure', '--enable-sccache', '--disable-manage-submodules', '--enable-locked-deps', '--enable-cargo-native-static', '--set', 'rust.codegen-units-std=1', '--set', 'dist.compression-profile=balanced', '--dist-compression-formats=xz', '--disable-dist-src', '--release-channel=nightly', '--enable-debug-assertions', '--enable-overflow-checks', '--enable-llvm-assertions', '--set', 'rust.verify-llvm-ir', '--set', 'rust.codegen-backends=llvm,cranelift,gcc', '--set', 'llvm.static-libstdcpp', '--enable-new-symbol-mangling']
configure: target.x86_64-unknown-linux-gnu.llvm-config := /usr/lib/llvm-17/bin/llvm-config
configure: llvm.link-shared     := True
configure: rust.thin-lto-import-instr-limit := 10
configure: change-id            := 99999999
---
failures:

---- [ui] tests/ui/abi/stack-protector.rs#no-ssp stdout ----

error in revision `no-ssp`: test run failed!
status: signal: 4 (SIGILL) (core dumped)
command: cd "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/abi/stack-protector.no-ssp" && RUST_TEST_THREADS="16" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/abi/stack-protector.no-ssp/a"
status: exit status: 0
status: exit status: 0
stdout: pwned!
------------------------------------------
stderr: none



---- [ui] tests/ui/abi/stack-protector.rs#ssp stdout ----

error in revision `ssp`: test run failed!
status: signal: 4 (SIGILL) (core dumped)
command: cd "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/abi/stack-protector.ssp" && RUST_TEST_THREADS="16" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/abi/stack-protector.ssp/a"
--- stdout -------------------------------
status: signal: 6 (SIGABRT) (core dumped)
stdout: 
stderr: *** stack smashing detected ***: terminated
stderr: none


---- [ui] tests/ui/backtrace.rs stdout ----
---- [ui] tests/ui/backtrace.rs stdout ----

error: test run failed!
status: signal: 4 (SIGILL) (core dumped)
command: cd "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/backtrace" && RUST_TEST_THREADS="16" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/backtrace/a"
stderr: none


---- [ui] tests/ui/std-backtrace.rs stdout ----
---- [ui] tests/ui/std-backtrace.rs stdout ----

error: test run failed!
status: signal: 4 (SIGILL) (core dumped)
command: cd "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/std-backtrace" && RUST_TEST_THREADS="16" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/std-backtrace/a"
stderr: none



@bors
Copy link
Collaborator

bors commented Mar 19, 2024

☀️ Try build successful - checks-actions
Build commit: 4c17eaa (4c17eaae24ad25a8e12b6a6a79f95266853fd829)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (4c17eaa): comparison URL.

Overall result: ❌✅ regressions and improvements - ACTION NEEDED

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
2.4% [0.3%, 4.7%] 32
Regressions ❌
(secondary)
4.4% [0.2%, 64.0%] 40
Improvements ✅
(primary)
-1.4% [-25.2%, -0.2%] 91
Improvements ✅
(secondary)
-0.7% [-1.8%, -0.1%] 27
All ❌✅ (primary) -0.4% [-25.2%, 4.7%] 123

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
2.5% [1.3%, 3.7%] 2
Regressions ❌
(secondary)
2.1% [2.1%, 2.1%] 1
Improvements ✅
(primary)
-5.3% [-5.3%, -5.3%] 1
Improvements ✅
(secondary)
-3.8% [-3.8%, -3.8%] 1
All ❌✅ (primary) -0.1% [-5.3%, 3.7%] 3

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
2.5% [1.3%, 3.6%] 23
Regressions ❌
(secondary)
11.1% [2.4%, 48.6%] 11
Improvements ✅
(primary)
-9.2% [-26.8%, -1.7%] 12
Improvements ✅
(secondary)
-3.0% [-3.5%, -2.1%] 3
All ❌✅ (primary) -1.5% [-26.8%, 3.6%] 35

Binary size

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.3% [0.0%, 2.1%] 55
Regressions ❌
(secondary)
1.3% [0.0%, 3.3%] 87
Improvements ✅
(primary)
-6.0% [-14.0%, -0.1%] 27
Improvements ✅
(secondary)
-0.8% [-0.8%, -0.8%] 1
All ❌✅ (primary) -1.8% [-14.0%, 2.1%] 82

Bootstrap: 669.996s -> 691.729s (3.24%)
Artifact size: 312.80 MiB -> 312.82 MiB (0.00%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Mar 19, 2024
@dianqk
Copy link
Member Author

dianqk commented Mar 21, 2024

I would prefer to add range on arguments with the support of LLVM 19.

@dianqk dianqk closed this Mar 21, 2024
@dianqk dianqk deleted the range_metadata branch March 21, 2024 05:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
perf-regression Performance regression. 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

match generates more branch instructions
5 participants