Skip to content

Remove fewer Storage calls in GVN #142819

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

ohadravid
Copy link
Contributor

@ohadravid ohadravid commented Jun 21, 2025

Followup to #142531 (Remove fewer Storage calls in copy_prop)

Modify the GVN MIR optimization pass to remove fewer Storage{Live,Dead} calls, allowing for better optimizations by LLVM - see #141649.

After replacing locals with values, use the MaybeStorageDead analysis to check that the replaced locals are storage-live.

A slight problem: In #142531, @tmiasko noted #142531 (comment) that MaybeStorageDead isn't enough since there can be a Live(_1); Dead(_1); Live(_1); block which forces the optimization to check that each value is initialised (and not only storage-live).

This is easy enough in copy_prop (because we are checking before the replacement), but in GVN it is actually hard to tell for each statement if the local must be initialized or not after the fact (and modifying VnState seems even harder).

I opted for something else which might be wrong (implemented in the last two commits):
If we consider Dead->Live to be the same as Deinit, than such a local shouldn't be considered SSA - so I updated SsaVisitor to mark such cases as non-SSA.

r? tmiasko

@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 Jun 21, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jun 21, 2025

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@Urgau
Copy link
Member

Urgau commented Jun 21, 2025

@bors2 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 Jun 21, 2025
@rust-timer

This comment was marked as duplicate.

@Urgau

This comment was marked as duplicate.

@rust-bors
Copy link

rust-bors bot commented Jun 21, 2025

⌛ Trying commit 1ea73cf with merge e92550a

To cancel the try build, run the command @bors2 try cancel.

rust-bors bot added a commit that referenced this pull request Jun 21, 2025
Remove fewer Storage calls in GVN

Followup to #142531 (Remove fewer Storage calls in `copy_prop`)

Modify the GVN MIR optimization pass to remove fewer Storage{Live,Dead} calls, allowing for better optimizations by LLVM - see #141649.

After replacing locals with values, use the `MaybeStorageDead` analysis to check that the replaced locals are storage-live.

**A slight problem**: In #142531, `@tmiasko` noted #142531 (comment) that `MaybeStorageDead` isn't enough since there can be a `Live(_1); Dead(_1); Live(_1);` block which forces the optimization to check that each value is initialised (and not only storage-live).

This is easy enough in `copy_prop` (because we are checking _before_ the replacement), but in GVN it is actually hard to tell for each statement if the local must be initialized or not after the fact (and modifying `VnState` seems even harder).

I opted for something else which might be wrong (implemented in the last two commits):
If we consider `Dead->Live` to be the same as `Deinit`, than such a local shouldn't be considered SSA - so I updated `SsaVisitor` to mark such cases as non-SSA.

r? tmiasko
@rust-log-analyzer

This comment has been minimized.

@ohadravid ohadravid force-pushed the better-storage-calls-gvn-v2 branch from 1ea73cf to 954274b Compare June 21, 2025 10:53
@rust-log-analyzer

This comment has been minimized.

@ohadravid ohadravid force-pushed the better-storage-calls-gvn-v2 branch from 954274b to 780d162 Compare June 21, 2025 11:55
@rust-bors
Copy link

rust-bors bot commented Jun 21, 2025

☀️ Try build successful (CI)
Build commit: e92550a (e92550ae94bf4a3d3939d7899ec5a4b690b1a9b2, parent: df4ad9e28b9fb973e244ebc65a8167a261b8f45e)

@rust-timer

This comment has been minimized.

@cjgillot
Copy link
Contributor

If we consider Dead->Live to be the same as Deinit, than such a local shouldn't be considered SSA - so I updated SsaVisitor to mark such cases as non-SSA.

I'm not sure this change is desirable. For now, we only consider assignments in SSA. If we have this sequence:

StorageLive(_a);
_a = something;
StorageDead(_a);
StorageLive(_a);
_b = _a;

The _a is uninit after the second StorageLive, so any later load is UB. We are allowed to remove the UB by making _a hold the value it held before the StorageDead.

Instead, I recommend you check for each local which get new use sites:

  1. all uses of are definitely live;
  2. there is a single StorageLive statement for that local, which dominates the defining assignment.

That should be enough to answer to @tmiasko's counterexample.

@cjgillot cjgillot self-assigned this Jun 21, 2025
@ohadravid
Copy link
Contributor Author

ohadravid commented Jun 21, 2025

Instead, I recommend you check for each local which get new use sites:
all uses of are definitely live;
there is a single StorageLive statement for that local, which dominates the defining assignment.

Sounds good, I'll try to implement that - do you think that implementing this using something like the current StorageChecker and matching on every type of statement in visit_local (that requires that the local is alive) is the right approach?

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (e92550a): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

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

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
0.5% [0.2%, 1.6%] 43
Regressions ❌
(secondary)
0.6% [0.1%, 1.5%] 23
Improvements ✅
(primary)
-0.8% [-1.8%, -0.2%] 3
Improvements ✅
(secondary)
-1.1% [-2.7%, -0.2%] 9
All ❌✅ (primary) 0.4% [-1.8%, 1.6%] 46

Max RSS (memory usage)

Results (primary 0.1%, secondary -3.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
3.3% [2.5%, 4.1%] 5
Regressions ❌
(secondary)
5.6% [5.6%, 5.6%] 1
Improvements ✅
(primary)
-4.0% [-6.7%, -2.6%] 4
Improvements ✅
(secondary)
-7.4% [-9.0%, -5.8%] 2
All ❌✅ (primary) 0.1% [-6.7%, 4.1%] 9

Cycles

Results (primary 0.4%, secondary 1.3%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
1.5% [1.3%, 1.7%] 2
Regressions ❌
(secondary)
2.6% [2.1%, 3.5%] 3
Improvements ✅
(primary)
-1.7% [-1.7%, -1.7%] 1
Improvements ✅
(secondary)
-2.5% [-2.5%, -2.5%] 1
All ❌✅ (primary) 0.4% [-1.7%, 1.7%] 3

Binary size

Results (primary 0.3%, secondary 0.4%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
0.4% [0.0%, 1.2%] 68
Regressions ❌
(secondary)
1.0% [0.0%, 5.0%] 41
Improvements ✅
(primary)
-0.2% [-1.0%, -0.0%] 17
Improvements ✅
(secondary)
-0.2% [-2.6%, -0.1%] 40
All ❌✅ (primary) 0.3% [-1.0%, 1.2%] 85

Bootstrap: 689.042s -> 692.911s (0.56%)
Artifact size: 371.85 MiB -> 372.10 MiB (0.07%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jun 21, 2025
@cjgillot
Copy link
Contributor

Sounds good, I'll try to implement that - do you think that implementing this using something like the current StorageChecker and matching on every type of statement in visit_local (that requires that the local is alive) is the right approach?

That's what I'd do.

@ohadravid
Copy link
Contributor Author

ohadravid commented Jun 21, 2025

there is a single StorageLive statement for that local, which dominates the defining assignment.

@cjgillot - do we need to check this? Seems like checking for alive locals is enough, since there must always be such a statement? (otherwise it's UB anyway?)

I far as I can see there can only be these (non-normal) cases:

  1. Use after StorageLive (or StorageDead, for that matter):
let _a = something;
// .. anything else
StorageLive(_a); 
let _b = copy _a;

handled by MaybeUninitializedLocals since StorageLive makes the local uninit.

  1. Use after StorageLive and assignment:
let _a = something;
StorageLive(_a);
let _a = something else;
let _b = copy _a;

_a is not SSA, so won't be replaced anyway.

  1. _a was never assigned:
StorageLive(_a); 
let _b = copy _a;

(handled by MaybeUninitializedLocals)

(in the meantime, pushed a version that's rebased on top of the copy_prop branch which uses MaybeUninitializedLocals)

@ohadravid ohadravid force-pushed the better-storage-calls-gvn-v2 branch 2 times, most recently from b00b762 to a259605 Compare June 21, 2025 14:34
@ohadravid ohadravid force-pushed the better-storage-calls-gvn-v2 branch from a259605 to f403fb6 Compare June 21, 2025 14:36
@cjgillot
Copy link
Contributor

For case 1, this is handled by checking if the StorageLive dominates the assignment.
For case 3, this is not SSA either.
Why use MaybeUninitializedLocals and not MaybeStorageDead?

@rust-log-analyzer
Copy link
Collaborator

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

Click to see the possible cause of the failure (guessed by this bot)
#19 exporting to docker image format
#19 sending tarball 27.8s done
#19 DONE 31.8s
##[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-19]
[CI_JOB_NAME=x86_64-gnu-llvm-19]
debug: `DISABLE_CI_RUSTC_IF_INCOMPATIBLE` configured.
---
sccache: Listening on address 127.0.0.1:4226
##[group]Configure the build
configure: processing command line
configure: 
configure: build.configure-args := ['--build=x86_64-unknown-linux-gnu', '--llvm-root=/usr/lib/llvm-19', '--enable-llvm-link-shared', '--set', 'rust.randomize-layout=true', '--set', 'rust.thin-lto-import-instr-limit=10', '--set', 'build.print-step-timings', '--enable-verbose-tests', '--set', 'build.metrics', '--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', '--set', 'rust.lld=false', '--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', '--set', 'gcc.download-ci-gcc=true', '--enable-new-symbol-mangling']
configure: build.build          := x86_64-unknown-linux-gnu
configure: target.x86_64-unknown-linux-gnu.llvm-config := /usr/lib/llvm-19/bin/llvm-config
configure: llvm.link-shared     := True
configure: rust.randomize-layout := True
configure: rust.thin-lto-import-instr-limit := 10
---
[RUSTC-TIMING] build_script_build test:false 0.308
[RUSTC-TIMING] build_script_build test:false 0.348
error: rustc interrupted by SIGSEGV, printing backtrace

/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0xd8bcaf) [0x7fd1dc58bcaf]
/lib/x86_64-linux-gnu/libc.so.6(+0x45250) [0x7fd1db625250]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x1a8fd83) [0x7fd1dd28fd83]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x1646fc8) [0x7fd1dce46fc8]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x164fe92) [0x7fd1dce4fe92]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x15addb6) [0x7fd1dcdaddb6]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x164e5e0) [0x7fd1dce4e5e0]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x15e0444) [0x7fd1dcde0444]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x165076e) [0x7fd1dce5076e]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x15addb6) [0x7fd1dcdaddb6]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x164e5e0) [0x7fd1dce4e5e0]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x15af78f) [0x7fd1dcdaf78f]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x19c0a9b) [0x7fd1dd1c0a9b]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x17d6654) [0x7fd1dcfd6654]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x3cd5d75) [0x7fd1df4d5d75]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x3bf27b5) [0x7fd1df3f27b5]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x3c515d6) [0x7fd1df4515d6]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(_RINvNtNtCs84bsPMht6PI_18rustc_query_system5query8plumbing17try_execute_queryINtCslI3kgiXDuPK_16rustc_query_impl13DynamicConfigINtNtCsiTeKLRZOH8s_21rustc_data_structures9vec_cache8VecCacheNtNtCsjcKHtBRH91P_10rustc_span6def_id10LocalDefIdINtNtNtCshTBOVh5DaSH_12rustc_middle5query5erase6ErasedAhj8_ENtNtNtB6_9dep_graph5graph12DepNodeIndexEKb0_KB5p_KB5p_ENtNtB1f_8plumbing9QueryCtxtKB5p_EB1f_+0x4bc) [0x7fd1df34908c]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x3ee12b6) [0x7fd1df6e12b6]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(_RNvNtNtNtCs8TGoOa95eJt_15rustc_mir_build4thir7pattern11check_match11check_match+0xdb) [0x7fd1ddc3ca6b]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x3cadda5) [0x7fd1df4adda5]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x3ba2145) [0x7fd1df3a2145]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x3c51cb6) [0x7fd1df451cb6]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(_RINvNtNtCs84bsPMht6PI_18rustc_query_system5query8plumbing17try_execute_queryINtCslI3kgiXDuPK_16rustc_query_impl13DynamicConfigINtNtCsiTeKLRZOH8s_21rustc_data_structures9vec_cache8VecCacheNtNtCsjcKHtBRH91P_10rustc_span6def_id10LocalDefIdINtNtNtCshTBOVh5DaSH_12rustc_middle5query5erase6ErasedAhj1_ENtNtNtB6_9dep_graph5graph12DepNodeIndexEKb0_KB5p_KB5p_ENtNtB1f_8plumbing9QueryCtxtKB5p_EB1f_+0x4a3) [0x7fd1df341593]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x3db286c) [0x7fd1df5b286c]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x237e9ec) [0x7fd1ddb7e9ec]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(_RNvNtCs8TGoOa95eJt_15rustc_mir_build7builder9build_mir+0x108) [0x7fd1ddb82df8]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(_RNvCs3fnCy3MkdhE_19rustc_mir_transform9mir_built+0x20) [0x7fd1ddad06d0]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x3cd7c75) [0x7fd1df4d7c75]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x3bf66e5) [0x7fd1df3f66e5]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x3c515d6) [0x7fd1df4515d6]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(_RINvNtNtCs84bsPMht6PI_18rustc_query_system5query8plumbing17try_execute_queryINtCslI3kgiXDuPK_16rustc_query_impl13DynamicConfigINtNtCsiTeKLRZOH8s_21rustc_data_structures9vec_cache8VecCacheNtNtCsjcKHtBRH91P_10rustc_span6def_id10LocalDefIdINtNtNtCshTBOVh5DaSH_12rustc_middle5query5erase6ErasedAhj8_ENtNtNtB6_9dep_graph5graph12DepNodeIndexEKb0_KB5p_KB5p_ENtNtB1f_8plumbing9QueryCtxtKB5p_EB1f_+0x4bc) [0x7fd1df34908c]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x3ed9f26) [0x7fd1df6d9f26]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(_RNvNtCs3fnCy3MkdhE_19rustc_mir_transform16ffi_unwind_calls20has_ffi_unwind_calls+0x384) [0x7fd1dd7d6134]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x3cc3685) [0x7fd1df4c3685]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x3bcd715) [0x7fd1df3cd715]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x3c51cb6) [0x7fd1df451cb6]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(_RINvNtNtCs84bsPMht6PI_18rustc_query_system5query8plumbing17try_execute_queryINtCslI3kgiXDuPK_16rustc_query_impl13DynamicConfigINtNtCsiTeKLRZOH8s_21rustc_data_structures9vec_cache8VecCacheNtNtCsjcKHtBRH91P_10rustc_span6def_id10LocalDefIdINtNtNtCshTBOVh5DaSH_12rustc_middle5query5erase6ErasedAhj1_ENtNtNtB6_9dep_graph5graph12DepNodeIndexEKb0_KB5p_KB5p_ENtNtB1f_8plumbing9QueryCtxtKB5p_EB1f_+0x4a3) [0x7fd1df341593]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x3db57ac) [0x7fd1df5b57ac]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(_RNvCs3fnCy3MkdhE_19rustc_mir_transform12mir_promoted+0x64b) [0x7fd1ddad0d9b]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x3cb0bca) [0x7fd1df4b0bca]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x3ba821d) [0x7fd1df3a821d]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x3c51bce) [0x7fd1df451bce]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(_RINvNtNtCs84bsPMht6PI_18rustc_query_system5query8plumbing17try_execute_queryINtCslI3kgiXDuPK_16rustc_query_impl13DynamicConfigINtNtCsiTeKLRZOH8s_21rustc_data_structures9vec_cache8VecCacheNtNtCsjcKHtBRH91P_10rustc_span6def_id10LocalDefIdINtNtNtCshTBOVh5DaSH_12rustc_middle5query5erase6ErasedAhj10_ENtNtNtB6_9dep_graph5graph12DepNodeIndexEKb0_KB5q_KB5q_ENtNtB1f_8plumbing9QueryCtxtKB5q_EB1f_+0x4db) [0x7fd1df33d6db]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x3e9e146) [0x7fd1df69e146]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(_RNvCs6HWLe8BaQ4z_14rustc_borrowck12mir_borrowck+0xf5) [0x7fd1ddecc745]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x3cb0775) [0x7fd1df4b0775]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x3ba78e5) [0x7fd1df3a78e5]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x3c515d6) [0x7fd1df4515d6]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(_RINvNtNtCs84bsPMht6PI_18rustc_query_system5query8plumbing17try_execute_queryINtCslI3kgiXDuPK_16rustc_query_impl13DynamicConfigINtNtCsiTeKLRZOH8s_21rustc_data_structures9vec_cache8VecCacheNtNtCsjcKHtBRH91P_10rustc_span6def_id10LocalDefIdINtNtNtCshTBOVh5DaSH_12rustc_middle5query5erase6ErasedAhj8_ENtNtNtB6_9dep_graph5graph12DepNodeIndexEKb0_KB5p_KB5p_ENtNtB1f_8plumbing9QueryCtxtKB5p_EB1f_+0x4bc) [0x7fd1df34908c]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x3ee19a6) [0x7fd1df6e19a6]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x1cf9b79) [0x7fd1dd4f9b79]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x1e345c8) [0x7fd1dd6345c8]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x3cb50da) [0x7fd1df4b50da]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x3bb0c09) [0x7fd1df3b0c09]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x3c5046b) [0x7fd1df45046b]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(_RINvNtNtCs84bsPMht6PI_18rustc_query_system5query8plumbing17try_execute_queryINtCslI3kgiXDuPK_16rustc_query_impl13DynamicConfigINtNtB4_6caches10DefIdCacheINtNtNtCshTBOVh5DaSH_12rustc_middle5query5erase6ErasedAhj8_EEKb0_KB3r_KB3r_ENtNtB1f_8plumbing9QueryCtxtKB3r_EB1f_+0x529) [0x7fd1df2b7679]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x3e58e18) [0x7fd1df658e18]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x1e32e6e) [0x7fd1dd632e6e]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x3cd61d7) [0x7fd1df4d61d7]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x3bf3189) [0x7fd1df3f3189]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x3c5046b) [0x7fd1df45046b]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(_RINvNtNtCs84bsPMht6PI_18rustc_query_system5query8plumbing17try_execute_queryINtCslI3kgiXDuPK_16rustc_query_impl13DynamicConfigINtNtB4_6caches10DefIdCacheINtNtNtCshTBOVh5DaSH_12rustc_middle5query5erase6ErasedAhj8_EEKb0_KB3r_KB3r_ENtNtB1f_8plumbing9QueryCtxtKB3r_EB1f_+0x529) [0x7fd1df2b7679]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x3e58d18) [0x7fd1df658d18]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x361e74c) [0x7fd1dee1e74c]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(_RNvCs9WLi4WdaW8R_13rustc_privacy22effective_visibilities+0x44c) [0x7fd1dee2424c]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x3cc64c3) [0x7fd1df4c64c3]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x3bd35a1) [0x7fd1df3d35a1]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x3c507c0) [0x7fd1df4507c0]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(_RINvNtNtCs84bsPMht6PI_18rustc_query_system5query8plumbing17try_execute_queryINtCslI3kgiXDuPK_16rustc_query_impl13DynamicConfigINtNtB4_6caches11SingleCacheINtNtNtCshTBOVh5DaSH_12rustc_middle5query5erase6ErasedAhj8_EEKb0_KB3s_KB3s_ENtNtB1f_8plumbing9QueryCtxtKB3s_EB1f_+0x3a7) [0x7fd1df2c5e07]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x3ea42fb) [0x7fd1df6a42fb]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(_RNvNtCs8jPhfDDijYv_12rustc_passes9stability31check_unused_or_stable_features+0x85) [0x7fd1deb6cf25]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x1024ecf) [0x7fd1dc824ecf]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(_RNvNtCs865Hh9hHOvG_15rustc_interface6passes8analysis+0xce) [0x7fd1dc92d6de]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x3cd63f3) [0x7fd1df4d63f3]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x3bf35c1) [0x7fd1df3f35c1]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x3c50540) [0x7fd1df450540]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(_RINvNtNtCs84bsPMht6PI_18rustc_query_system5query8plumbing17try_execute_queryINtCslI3kgiXDuPK_16rustc_query_impl13DynamicConfigINtNtB4_6caches11SingleCacheINtNtNtCshTBOVh5DaSH_12rustc_middle5query5erase6ErasedAhj0_EEKb0_KB3s_KB3s_ENtNtB1f_8plumbing9QueryCtxtKB3s_EB1f_+0x3d0) [0x7fd1df2bb5e0]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x3ed7dce) [0x7fd1df6d7dce]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0xd1db4d) [0x7fd1dc51db4d]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0xd8e0c2) [0x7fd1dc58e0c2]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0xdc7121) [0x7fd1dc5c7121]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0xd57b1d) [0x7fd1dc557b1d]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0xda949a) [0x7fd1dc5a949a]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0xd0ead9) [0x7fd1dc50ead9]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0xd313ee) [0x7fd1dc5313ee]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0xd48e28) [0x7fd1dc548e28]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0xd4226f) [0x7fd1dc54226f]
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-59149f1fb6149a78.so(+0x5b43da5) [0x7fd1e1343da5]
/lib/x86_64-linux-gnu/libc.so.6(+0xa1e2e) [0x7fd1db681e2e]
/lib/x86_64-linux-gnu/libc.so.6(+0x133a4c) [0x7fd1db713a4c]

note: we would appreciate a report at https://github.com/rust-lang/rust
help: you can increase rustc's stack size by setting RUST_MIN_STACK=16777216
note: backtrace dumped due to SIGSEGV! resuming signal
[RUSTC-TIMING] core test:false 8.735
rustc exited with signal: 11 (SIGSEGV) (core dumped)
error: could not compile `core` (lib)

Caused by:
  process didn't exit successfully: `/checkout/obj/build/bootstrap/debug/rustc /checkout/obj/build/bootstrap/debug/rustc --crate-name core --edition=2024 library/core/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata -C opt-level=3 -C embed-bitcode=no -C codegen-units=1 --warn=unexpected_cfgs --check-cfg 'cfg(target_arch, values("loongarch32"))' --check-cfg 'cfg(no_fp_fmt_parse)' --check-cfg 'cfg(feature, values(any()))' --check-cfg 'cfg(target_has_reliable_f16)' --check-cfg 'cfg(target_has_reliable_f16_math)' --check-cfg 'cfg(target_has_reliable_f128)' --check-cfg 'cfg(target_has_reliable_f128_math)' -C debug-assertions=on --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values("debug_refcell", "debug_typeid", "optimize_for_size", "panic_immediate_abort"))' -C metadata=c37a4967ef3aecd0 -C extra-filename=-ba9ee9ab704865c3 --out-dir /checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps --target i686-unknown-linux-gnu -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/release/deps -Csymbol-mangling-version=v0 -Zrandomize-layout '--check-cfg=cfg(feature,values(any()))' -Zunstable-options -Zmacro-backtrace -Csplit-debuginfo=off -Cprefer-dynamic -Cllvm-args=-import-instr-limit=10 --cfg=randomized_layouts -Zinline-mir -Zinline-mir-preserve-debug -Zmir_strip_debuginfo=locals-in-tiny-functions -Zalways-encode-mir -Z binary-dep-depinfo` (exit status: 254)
Build completed unsuccessfully in 0:32:22
  local time: Sat Jun 21 15:15:50 UTC 2025
  network time: Sat, 21 Jun 2025 15:15:50 GMT
##[error]Process completed with exit code 1.
Post job cleanup.

@ohadravid
Copy link
Contributor Author

Why use MaybeUninitializedLocals and not MaybeStorageDead?

It seems simpler than modifying SsaVisitor, and also it avoids the extra storage checks for debug builds.

Let me know what do you think is preferable 😄

@cjgillot
Copy link
Contributor

@ohadravid
Copy link
Contributor Author

I mean this MaybeStorageDead: https://doc.rust-lang.org/beta/nightly-rustc/rustc_mir_dataflow/impls/struct.MaybeStorageDead.html

This is what I used in the original impl, but requires the StorageLive-dominates-assignment check (if I understood correctly).

And I think that MaybeUninitializedLocals should be as simple/fast, but without needing to add that check.

Again - I might be totally missing something 😅

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.

7 participants