Skip to content

Assert that there are no unused remappings. #7650

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 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ use crate::{
///
/// The list of call statements that can be moved is currently hardcoded.
///
/// Removing unnecessary remapping before this optimization will result in better code.
/// Unused remapping should be removed before running this optimization (using
/// `optimize_remappings`).
pub fn reorder_statements(db: &dyn LoweringGroup, lowered: &mut FlatLowered) {
if lowered.blocks.is_empty() {
return;
Expand Down Expand Up @@ -152,8 +153,12 @@ impl Analyzer<'_> for ReorderStatementsContext<'_> {
_target_block_id: BlockId,
remapping: &VarRemapping,
) {
for VarUsage { var_id, .. } in remapping.values() {
info.next_use.insert(*var_id, statement_location);
for (dst, src) in remapping.iter() {
assert!(
info.next_use.contains_key(dst),
"Unused remappings should be removed before running this optimization."
);
info.next_use.insert(src.var_id, statement_location);
}
}

Expand Down
Loading