phase29aa(p7): deterministic ReleaseStrong values ordering
This commit is contained in:
@ -429,13 +429,8 @@ fn plan_rc_insertion_for_block(
|
||||
}
|
||||
|
||||
if matches!(terminator, Some(MirInstruction::Return { .. })) && !ptr_to_value.is_empty() {
|
||||
let release_values: Vec<ValueId> = {
|
||||
let mut set = HashSet::new();
|
||||
for v in ptr_to_value.values() {
|
||||
set.insert(*v);
|
||||
}
|
||||
set.into_iter().collect()
|
||||
};
|
||||
// P7: HashSet 削除、sort+dedup は apply 側のヘルパーで処理される
|
||||
let release_values: Vec<ValueId> = ptr_to_value.values().copied().collect();
|
||||
if !release_values.is_empty() {
|
||||
plan.drops.push(DropSite {
|
||||
at: DropPoint::BeforeTerminator,
|
||||
@ -448,6 +443,14 @@ fn plan_rc_insertion_for_block(
|
||||
(plan, ptr_to_value)
|
||||
}
|
||||
|
||||
/// P7: ReleaseStrong の values を決定的順序(ValueId 昇順)にする
|
||||
#[cfg(feature = "rc-insertion-minimal")]
|
||||
fn sorted_release_values(mut values: Vec<ValueId>) -> Vec<ValueId> {
|
||||
values.sort_unstable();
|
||||
values.dedup();
|
||||
values
|
||||
}
|
||||
|
||||
#[cfg(feature = "rc-insertion-minimal")]
|
||||
fn apply_rc_plan(
|
||||
insts: Vec<MirInstruction>,
|
||||
@ -490,7 +493,7 @@ fn apply_rc_plan(
|
||||
for drop_site in drops_before_instr[idx].drain(..) {
|
||||
let _ = drop_site.reason;
|
||||
new_insts.push(MirInstruction::ReleaseStrong {
|
||||
values: drop_site.values,
|
||||
values: sorted_release_values(drop_site.values),
|
||||
});
|
||||
new_spans.push(span.clone());
|
||||
stats.release_inserted += 1;
|
||||
@ -510,7 +513,7 @@ fn apply_rc_plan(
|
||||
for drop_site in drops_before_terminator {
|
||||
let _ = drop_site.reason;
|
||||
new_insts.push(MirInstruction::ReleaseStrong {
|
||||
values: drop_site.values,
|
||||
values: sorted_release_values(drop_site.values),
|
||||
});
|
||||
new_spans.push(span.clone());
|
||||
stats.release_inserted += 1;
|
||||
|
||||
Reference in New Issue
Block a user