Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
0d508bb
Introduce and provide a hook for `should_codegen_locally`
momvart Jul 15, 2024
14430e6
Use the hook on tcx instead of the local function
momvart Jul 15, 2024
9b80250
Move compiler_builtin check to the use case
momvart Jul 15, 2024
2b5a982
abstract merge-base commit logic
onur-ozkan Jul 17, 2024
9e354da
unix: Unsafe-wrap stack_overflow::signal_handler
workingjubilee Jul 17, 2024
357ba1f
unix: lift init of sigaltstack before sigaction
workingjubilee Jul 17, 2024
fa628ce
unix: Unsafe-wrap stack_overflow::cleanup
workingjubilee Jul 17, 2024
c1740ee
unix: Unsafe-wrap stack_overflow::{drop,make}_handler
workingjubilee Jul 17, 2024
529fcbc
unix: acquire-load NEED_ALTSTACK
workingjubilee Jul 18, 2024
36ebf7a
run_make_support: skip rustfmt for lib.rs to preserve use ordering
jieyouxu Jul 19, 2024
1d83da8
kmc-solid: forbid(unsafe_op_in_unsafe_fn)
workingjubilee Jul 17, 2024
e9b3e9c
std: forbid unwrapped unsafe in unsupported_backslash
workingjubilee Jul 17, 2024
3b7e4bc
Split out `remove_never_subcandidates`
Zalathar Jul 18, 2024
e091c35
Improve `merge_trivial_subcandidates`
Zalathar Jul 18, 2024
e60c5c1
Split out `test_remaining_match_pairs_after_or`
Zalathar Jul 18, 2024
886668c
Improve `test_remaining_match_pairs_after_or`
Zalathar Jul 18, 2024
239037e
Inline `finalize_or_candidate`
Zalathar Jul 18, 2024
0636293
use precompiled rustdoc with CI rustc
onur-ozkan Jul 7, 2024
3a9bfa3
Rollup merge of #127463 - onur-ozkan:precompiled-rustdoc, r=Kobzol
matthiaskrgr Jul 20, 2024
9a6f8cc
Rollup merge of #127779 - momvart:should_codegen_hook, r=cjgillot
matthiaskrgr Jul 20, 2024
2ee3668
Rollup merge of #127843 - workingjubilee:break-up-big-ass-stack-overf…
matthiaskrgr Jul 20, 2024
6b9982d
Rollup merge of #127873 - workingjubilee:forbid-unsafe-ops-for-kmc-so…
matthiaskrgr Jul 20, 2024
d846e92
Rollup merge of #127917 - Zalathar:after-or, r=Nadrieril
matthiaskrgr Jul 20, 2024
8963855
Rollup merge of #127964 - jieyouxu:rmake-rustfmt-skip, r=nnethercote
matthiaskrgr Jul 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improve merge_trivial_subcandidates
  • Loading branch information
Zalathar committed Jul 20, 2024
commit e091c356fa0e47251f6c7d11cbc7043213df48c6
20 changes: 15 additions & 5 deletions compiler/rustc_mir_build/src/build/matches/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1744,8 +1744,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
/// Try to merge all of the subcandidates of the given candidate into one. This avoids
/// exponentially large CFGs in cases like `(1 | 2, 3 | 4, ...)`. The candidate should have been
/// expanded with `create_or_subcandidates`.
///
/// Note that this takes place _after_ the subcandidates have participated
/// in match tree lowering.
fn merge_trivial_subcandidates(&mut self, candidate: &mut Candidate<'_, 'tcx>) {
if candidate.subcandidates.is_empty() || candidate.has_guard {
assert!(!candidate.subcandidates.is_empty());
if candidate.has_guard {
// FIXME(or_patterns; matthewjasper) Don't give up if we have a guard.
return;
}
Expand All @@ -1759,20 +1763,26 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
}

let mut last_otherwise = None;
let any_matches = self.cfg.start_new_block();
let shared_pre_binding_block = self.cfg.start_new_block();
// This candidate is about to become a leaf, so unset `or_span`.
let or_span = candidate.or_span.take().unwrap();
let source_info = self.source_info(or_span);

if candidate.false_edge_start_block.is_none() {
candidate.false_edge_start_block = candidate.subcandidates[0].false_edge_start_block;
}

// Remove the (known-trivial) subcandidates from the candidate tree,
// so that they aren't visible after match tree lowering, and wire them
// all to join up at a single shared pre-binding block.
// (Note that the subcandidates have already had their part of the match
// tree lowered by this point, which is why we can add a goto to them.)
for subcandidate in mem::take(&mut candidate.subcandidates) {
let or_block = subcandidate.pre_binding_block.unwrap();
self.cfg.goto(or_block, source_info, any_matches);
let subcandidate_block = subcandidate.pre_binding_block.unwrap();
self.cfg.goto(subcandidate_block, source_info, shared_pre_binding_block);
last_otherwise = subcandidate.otherwise_block;
}
candidate.pre_binding_block = Some(any_matches);
candidate.pre_binding_block = Some(shared_pre_binding_block);
assert!(last_otherwise.is_some());
candidate.otherwise_block = last_otherwise;
}
Expand Down