Skip to content
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

mir-opt: Ignore the dead store statements in MatchBranchSimplification #129931

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

Conversation

dianqk
Copy link
Member

@dianqk dianqk commented Sep 3, 2024

#128299 simplified

bb0: {
    _2 = discriminant((*_1));
    switchInt(move _2) -> [0: bb4, 1: bb3, otherwise: bb2];
}
bb3: {
    _5 = &(((*_1) as B).0: NestCopy);
    _7 = copy ((((*_1) as B).0: NestCopy).0: i32);
    _9 = &((((*_1) as B).0: NestCopy).1: AllCopy);
    _11 = copy (((((*_1) as B).0: NestCopy).1: AllCopy).0: i32);
    _12 = copy (((((*_1) as B).0: NestCopy).1: AllCopy).1: u64);
    _13 = copy (((((*_1) as B).0: NestCopy).1: AllCopy).2: [i8; 3]);
    _8 = AllCopy { a: move _11, b: move _12, c: move _13 };
    _10 = copy ((((*_1) as B).0: NestCopy).2: [i8; 3]);
    _6 = NestCopy { a: move _7, b: move _8, c: move _10 };
    _0 = Enum1::B(move _6);
    goto -> bb1;
}
bb4: {
    _3 = &(((*_1) as A).0: AllCopy);
    _14 = copy ((((*_1) as A).0: AllCopy).0: i32);
    _15 = copy ((((*_1) as A).0: AllCopy).1: u64);
    _16 = copy ((((*_1) as A).0: AllCopy).2: [i8; 3]);
    _4 = AllCopy { a: move _14, b: move _15, c: move _16 };
    _0 = Enum1::A(move _4);
    StorageDead(_4);
    goto -> bb1;
}

to

bb0: {
    _2 = discriminant((*_1));
    switchInt(move _2) -> [0: bb1, 1: bb2, otherwise: bb4];
}
bb1: {
    _3 = &(((*_1) as A).0: AllCopy);
    _0 = copy (*_1);
    goto -> bb3;
}
bb2: {
    _4 = &(((*_1) as B).0: NestCopy);
    StorageLive(_5);
    _5 = &((((*_1) as B).0: NestCopy).1: AllCopy);
    StorageDead(_5);
    _0 = copy (*_1);
    goto -> bb3;
}

Since all of these are dead store statements, we can simplify and merge them into a single copy statement.

@rustbot
Copy link
Collaborator

rustbot commented Sep 3, 2024

r? @nnethercote

rustbot has assigned @nnethercote.
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 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 3, 2024
@dianqk
Copy link
Member Author

dianqk commented Sep 3, 2024

r? ghost

@rustbot
Copy link
Collaborator

rustbot commented Sep 3, 2024

Failed to set assignee to ghost: invalid assignee

Note: Only org members with at least the repository "read" role, users with write permissions, or people who have commented on the PR may be assigned.

@dianqk
Copy link
Member Author

dianqk commented Sep 3, 2024

r? cjgillot

@rustbot rustbot assigned cjgillot and unassigned nnethercote Sep 3, 2024
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Sep 14, 2024

☔ The latest upstream changes (presumably #128299) made this pull request unmergeable. Please resolve the merge conflicts.

@dianqk
Copy link
Member Author

dianqk commented Sep 14, 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 Sep 14, 2024
@bors
Copy link
Collaborator

bors commented Sep 14, 2024

⌛ Trying commit 622247a with merge c324112...

bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 14, 2024
Merge these copy statements that simplified the canonical enum clone method by GVN

This is blocked by rust-lang#128299.
@bors
Copy link
Collaborator

bors commented Sep 14, 2024

☀️ Try build successful - checks-actions
Build commit: c324112 (c3241126e94d7a53a1805ad854686e0bd061b5df)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (c324112): comparison URL.

Overall result: no relevant changes - no 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.

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

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results (primary 0.9%)

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)
4.0% [3.0%, 5.1%] 3
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-3.8% [-5.9%, -1.7%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.9% [-5.9%, 5.1%] 5

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

Results (primary 0.0%, secondary -0.0%)

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.1% [0.0%, 0.2%] 11
Regressions ❌
(secondary)
0.0% [0.0%, 0.1%] 2
Improvements ✅
(primary)
-0.1% [-0.3%, -0.0%] 6
Improvements ✅
(secondary)
-0.0% [-0.0%, -0.0%] 3
All ❌✅ (primary) 0.0% [-0.3%, 0.2%] 17

Bootstrap: 760.71s -> 756.595s (-0.54%)
Artifact size: 341.13 MiB -> 341.17 MiB (0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Sep 15, 2024
Copy link
Contributor

@cjgillot cjgillot left a comment

Choose a reason for hiding this comment

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

My high-level reaction to this PR is that it's both too specific in what it's trying to match (a clone impl) and too general in its implementation (handles storage statements...).

I suggest having two heuristics:

  • for clone impls, use some kind of StructuralClone trait so that we fully replace the derived impls Clone with simpler MIR;
  • for general MIR, lift the restrictions on this pass (bb0 and assignment to _0 namely).

What do you think?

@@ -604,6 +602,7 @@ fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
&dead_store_elimination::DeadStoreElimination::Initial,
&gvn::GVN,
&simplify::SimplifyLocals::AfterGVN,
&match_branches::MatchBranchSimplification,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this run on clone shims too? Or do we want a trait-based solution to detect trivial clone impls?

Copy link
Member Author

Choose a reason for hiding this comment

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

Should this run on clone shims too?

Could you explain more?

Or do we want a trait-based solution to detect trivial clone impls?

It makes sense to me for clone impls.

@dianqk
Copy link
Member Author

dianqk commented Sep 18, 2024

* for clone impls, use some kind of `StructuralClone` trait so that we fully replace the derived impls `Clone` with simpler MIR;

* for general MIR, lift the restrictions on this pass (bb0 and assignment to _0 namely).

What do you think?

It looks like makes sense.
IIUC, the StructuralClone is exact matching clone shims? I expect this can improve compile-time.

@rustbot author

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

@dianqk dianqk left a comment

Choose a reason for hiding this comment

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

I didn't submit all the comments through "Submit review"; there are still some pending comments. o

I am currently modifying the code to move it into a separate pass.

@@ -604,6 +602,7 @@ fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
&dead_store_elimination::DeadStoreElimination::Initial,
&gvn::GVN,
&simplify::SimplifyLocals::AfterGVN,
&match_branches::MatchBranchSimplification,
Copy link
Member Author

Choose a reason for hiding this comment

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

Should this run on clone shims too?

Could you explain more?

Or do we want a trait-based solution to detect trivial clone impls?

It makes sense to me for clone impls.

@dianqk dianqk changed the title Merge these copy statements that simplified the canonical enum clone method by GVN mir-opt: Merge all branch BBs into a single copy statement Oct 5, 2024
@dianqk dianqk added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-blocked Status: Blocked on something else such as an RFC or other implementation work. labels Apr 3, 2025
@dianqk
Copy link
Member Author

dianqk commented Apr 4, 2025

Just rebased. Perhaps I should move the code in MatchBranchSimplification.

@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 Apr 4, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 4, 2025
mir-opt: Merge all branch BBs into a single copy statement

rust-lang#128299 simplified
```rust
match a {
    Foo::A(x) => Foo::A(*x),
    Foo::B => Foo::B
}
```
to
```rust
match a {
    Foo::A(x) => a, // copy a
    Foo::B => Foo::B
}
```

The switch branch can be simplified into a single copy statement. This PR implements a relatively general simplification.
@bors
Copy link
Collaborator

bors commented Apr 4, 2025

⌛ Trying commit f05d4af with merge 27bc686...

@bors
Copy link
Collaborator

bors commented Apr 4, 2025

☀️ Try build successful - checks-actions
Build commit: 27bc686 (27bc686b0d1e864190a5a718151fd4ddcea59971)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (27bc686): comparison URL.

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

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 the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.

mean range count
Regressions ❌
(primary)
0.3% [0.2%, 0.5%] 6
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.4% [-1.4%, -1.4%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.1% [-1.4%, 0.5%] 7

Max RSS (memory usage)

Results (primary -3.8%, secondary -2.2%)

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
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-3.8% [-5.6%, -2.1%] 2
Improvements ✅
(secondary)
-2.2% [-2.2%, -2.2%] 1
All ❌✅ (primary) -3.8% [-5.6%, -2.1%] 2

Cycles

Results (primary 1.8%, secondary 2.3%)

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)
1.8% [1.8%, 1.8%] 1
Regressions ❌
(secondary)
2.3% [2.3%, 2.3%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.8% [1.8%, 1.8%] 1

Binary size

Results (primary -0.1%, secondary -0.1%)

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.1%, 0.6%] 3
Regressions ❌
(secondary)
0.0% [0.0%, 0.0%] 2
Improvements ✅
(primary)
-0.1% [-0.9%, -0.0%] 17
Improvements ✅
(secondary)
-0.1% [-0.1%, -0.1%] 35
All ❌✅ (primary) -0.1% [-0.9%, 0.6%] 20

Bootstrap: 778.988s -> 776.478s (-0.32%)
Artifact size: 365.99 MiB -> 366.08 MiB (0.02%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Apr 4, 2025
Comment on lines 77 to 84
let mut patch = MirPatch::new(body);
patch.add_assign(parent_end, dest_place, Rvalue::Use(Operand::Copy(src_place)));
patch.patch_terminator(switch_bb_idx, first_terminator_kind.clone());
patch.apply(body);
super::simplify::remove_dead_blocks(body);
// After modifying the MIR, the result of `MaybeTransitiveLiveLocals` may become invalid,
// keeping it simple to process only once.
break;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd recommend having a single patch and modify MIR at the end. This allows to catch several instances of the opt in the same body.

Copy link
Member Author

Choose a reason for hiding this comment

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

@@ -609,6 +610,7 @@ fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
&dead_store_elimination::DeadStoreElimination::Initial,
&gvn::GVN,
&simplify::SimplifyLocals::AfterGVN,
&merge_branches::MergeBranchSimplification,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add a dead_store_elimination::DeadStoreElimination::AfterGVN just before it and simplify your pass?

return None;
}
}
Rvalue::Use(Operand::Copy(place)) if *place == src_place => {}
Copy link
Contributor

Choose a reason for hiding this comment

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

What about Operand::Move? Downgrading a move to a copy is fine.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll address it in the next PR or a subsequent update.

@dianqk dianqk changed the title mir-opt: Merge all branch BBs into a single copy statement mir-opt: Ignore the dead store statements in MatchBranchSimplification Apr 6, 2025
@dianqk
Copy link
Member Author

dianqk commented Apr 6, 2025

To better handle dead store statements, I'm cloning basic blocks in MatchBranchSimplification and performing DSE. I think this approach is more generic, and easier to maintain and review.

I haven't transformed match a { Foo::A(_x) => a, Foo::B => Foo::B } to a copy statement yet this weekend, but I think this can be a subsequent PR.

@rustbot 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 Apr 6, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer
Copy link
Collaborator

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

Click to see the possible cause of the failure (guessed by this bot)
Mismatch at tests/source/struct-field-attributes.rs:24:
 // #1462
 struct Foo {
     foo: usize,
-    #[cfg(feature = "include-bar")]
+    #[cfg(feature="include-bar")]
     bar: usize,
 }
 

Mismatch at tests/source/struct-field-attributes.rs:39:
 // #2044
 pub enum State {
     Closure(
-        #[cfg_attr(
-            feature = "serde_derive",
-            serde(state_with = "::serialization::closure")
-        )]
-        GcPtr<ClosureData>,
+        #[cfg_attr(feature = "serde_derive", serde(state_with = "::serialization::closure"))] GcPtr<ClosureData>,
     ),
 }
 

Mismatch at tests/source/struct-field-attributes.rs:50:
 struct Fields(
-    #[cfg_attr(
-        feature = "serde_derive",
-        serde(state_with = "::base::serialization::shared")
-    )]
-    Arc<Vec<InternedStr>>,
+    #[cfg_attr(feature = "serde_derive", serde(state_with = "::base::serialization::shared"))] Arc<Vec<InternedStr>>,
 );
 
 // #2309

Mismatch at tests/source/struct-field-attributes.rs:59:
 pub struct A {
-    #[doc = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"]
-    pub foos: Vec<bool>,
+    #[doc="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"]
+pub foos:Vec<bool>,
 }
 

Mismatch at tests/source/unions.rs:32:
 // #410
 #[allow(missing_docs)]
 pub union Writebatch<K: Key> {
-    #[allow(dead_code)] // only used for holding the internal pointer
+    #[allow(dead_code)] //only used for holding the internal pointer
     writebatch: RawWritebatch,
     marker: PhantomData<K>,
 }

Mismatch at tests/source/unions.rs:91:
 }
 
 union Palette {
-    /// A map of indices in the palette to a count of pixels in approximately
-    /// that color
-    foo: i32,
+    /// A map of indices in the palette to a count of pixels in approximately that color
+                    foo: i32,
 }
 
 // Splitting a single line comment into a block previously had a misalignment

Mismatch at tests/source/unions.rs:104:
                                        * BBBBBBBBBBBBBBBB BBBBBBBBBBBBBBBBB BBBBBBBBBBB */
     // Another pre comment
     #[attr1]
-    #[attr2]
-    pub id: usize, /* CCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCC
-                    * CCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCC CCCCCCCCCCCC */
+    #[attr2] pub id: usize, /* CCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCC
+                             * CCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCC CCCCCCCCCCCC */
 }
 
 union Deep {

Mismatch at tests/source/unions.rs:113:
-    deeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeep:
-        node::Handle<IdRef<'id, Node<K, V>>, Type, NodeType>,
+    deeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeep: node::Handle<IdRef<'id, Node<K, V>>,
+                                                     Type,
+                                                     NodeType>,
 }
 
 mod m {

Mismatch at tests/source/unions.rs:125:
 
 union Issue677 {
     pub ptr: *const libc::c_void,
-    pub trace: fn(obj: *const libc::c_void, tracer: *mut JSTracer),
+    pub trace: fn(  obj: 
+          *const libc::c_void, tracer   : *mut   JSTracer   ),
 }
 
 union Foo {}

Mismatch at tests/source/unions.rs:142:
 
 union LongUnion {
     a: A,
-    the_quick_brown_fox_jumps_over_the_lazy_dog:
-        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
+    the_quick_brown_fox_jumps_over_the_lazy_dog:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
 }
 
 union Deep {

Mismatch at tests/source/unions.rs:150:
-    deeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeep:
-        node::Handle<IdRef<'id, Node<Key, Value>>, Type, NodeType>,
+    deeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeep: node::Handle<IdRef<'id, Node<Key, Value>>,
+                                                                         Type,
+                                                                         NodeType>,
 }
 
 // #1364

Mismatch at tests/source/issue_5686.rs:34:
     #[hell{world}]
     Cobra {/* struct variant close in leading attribute */} = 6,
     Eagle {
-        /* struct variant closer on associated field attribute */
-        #[hell{world}]
-        value: Sting,
+        /* struct variant closer on associated field attribute */ #[hell{world}]value: Sting,
     } = 7,
     Koala {/* struct variant closer on macro call */} = some_macro! {},
 }

Mismatch at tests/source/multiple.rs:105:
 pub struct Foo {
     #[rustfmt::skip]
     f :   SomeType, // Comment beside a field
-    f: SomeType, // Comment beside a field
+    f :   SomeType, // Comment beside a field
     // Comment on a field
     g: SomeOtherType,
     /// A doc comment on a field

Mismatch at tests/source/issue-2869.rs:3:
 #[derive(Serialize, Deserialize, Debug)]
 #[serde(rename_all = "PascalCase")]
---
-    result_status:                     Option<String>,
+    creation_time: String,
+    id: String,
+    operation: String,
+    organization_id: String,
+    record_type: u32,
+    result_status: Option<String>,
     #[serde(rename = "ClientIP")]
-    client_ip:                         Option<IpAddr>,
-    object_id:                         String,
-    actor:                             Option<Vec<IDType>>,
-    actor_context_id:                  Option<String>,
-    actor_ip_address:                  Option<IpAddr>,
+    client_ip: Option<IpAddr>,
+    object_id: String,
+    actor: Option<Vec<IDType>>,
+    actor_context_id: Option<String>,
+    actor_ip_address: Option<IpAddr>,
     azure_active_directory_event_type: Option<u8>,
 
     #[serde(rename = "very")]

Mismatch at tests/source/issue-2869.rs:21:
     aaaaa: String,
---
 struct AuditLog2 {
-    creation_time:                     String,
-    id:                                String,
-    operation:                         String,
-    organization_id:                   String,
-    record_type:                       u32,
-    result_status:                     Option<String>,
-    client_ip:                         Option<IpAddr>,
-    object_id:                         String,
-    actor:                             Option<Vec<IDType>>,
-    actor_context_id:                  Option<String>,
-    actor_ip_address:                  Option<IpAddr>,
+    creation_time: String,
+    id: String,
+    operation: String,
+    organization_id: String,
+    record_type: u32,
+    result_status: Option<String>,
+    client_ip: Option<IpAddr>,
+    object_id: String,
+    actor: Option<Vec<IDType>>,
+    actor_context_id: Option<String>,
+    actor_ip_address: Option<IpAddr>,
     azure_active_directory_event_type: Option<u8>,
 }
 

Mismatch at tests/source/issue-2164.rs:2:
 #[repr(C)]
 #[derive(Debug, Copy, Clone)]
 pub struct emacs_env_25 {
-    pub size: isize,
-    pub private_members: *mut emacs_env_private,
-    pub make_global_ref: ::std::option::Option<

@dianqk
Copy link
Member Author

dianqk commented Apr 7, 2025

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

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

@rustbot author

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

rustbot commented Apr 7, 2025

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@dianqk
Copy link
Member Author

dianqk commented Apr 8, 2025

I should drop other dead store statements or not merging this match:

pub fn foo(b: bool) {
    let _b = (if b { " " } else { "" },);
}

fn foo(_1: bool) -> () {
    debug b => _1;
    let mut _0: ();
    let _2: (&str,);
    let mut _3: &str;
    scope 1 {
        debug _b => _2;
    }

    bb0: {
        switchInt(copy _1) -> [0: bb2, otherwise: bb1];
    }

    bb1: {
        _3 = const " ";
        goto -> bb3;
    }

    bb2: {
        _3 = const "";
        goto -> bb3;
    }

    bb3: {
        _2 = (move _3,);
        return;
    }
}

I'm considering not merging this match.

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-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

9 participants