Skip to content

Commit 8b5a70c

Browse files
committed
Improved wording in comments and logs
1 parent 06bcdeb commit 8b5a70c

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

compiler/rustc_mir_transform/src/copy_prop.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,10 @@ impl<'tcx> crate::MirPass<'tcx> for CopyProp {
5252
let fully_moved = fully_moved_locals(&ssa, body);
5353
debug!(?fully_moved);
5454

55-
// We can determine if we can keep the head's storage statements (which enables better optimizations).
56-
// For every local's usage location, we'll to remove it's storage statements only if the head is maybe-uninitialized,
57-
// or if the local is borrowed (since we cannot easily identify when it is used).
55+
// When emitting storage statements, we want to retain the head locals' storage statements,
56+
// as this enables better optimizations. For each local use location, we mark the head for storage removal
57+
// only if the head might be uninitialized at that point, or if the local is borrowed
58+
// (since we cannot easily determine when it's used).
5859
let storage_to_remove = if tcx.sess.emit_lifetime_markers() {
5960
storage_to_remove.clear();
6061

@@ -75,7 +76,7 @@ impl<'tcx> crate::MirPass<'tcx> for CopyProp {
7576

7677
storage_checker.storage_to_remove
7778
} else {
78-
// Conservatively remove all storage statements for the head locals.
79+
// Remove the storage statements of all the head locals.
7980
storage_to_remove
8081
};
8182

@@ -233,7 +234,7 @@ impl<'a, 'tcx> Visitor<'tcx> for StorageChecker<'a, 'tcx> {
233234
?context,
234235
?local,
235236
?head,
236-
"found a head at a location in which it is maybe uninit, marking head for storage statement removal"
237+
"local's head is maybe uninit at this location, marking head for storage statement removal"
237238
);
238239
self.storage_to_remove.insert(head);
239240
}

compiler/rustc_mir_transform/src/gvn.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,9 @@ impl<'tcx> crate::MirPass<'tcx> for GVN {
140140
state.visit_basic_block_data(bb, data);
141141
}
142142

143-
// If we emit storage annotations, use `MaybeStorageDead` to check which reused locals
144-
// require storage removal (making them alive for the duration of the function).
143+
// When emitting storage statements, we want to retain the reused locals' storage statements,
144+
// as this enables better optimizations. For each local use location, we mark it for storage removal
145+
// only if it might be uninitialized at that point.
145146
let storage_to_remove = if tcx.sess.emit_lifetime_markers() {
146147
let maybe_uninit = MaybeUninitializedLocals::new()
147148
.iterate_to_fixpoint(tcx, body, Some("mir_opt::gvn"))
@@ -159,7 +160,7 @@ impl<'tcx> crate::MirPass<'tcx> for GVN {
159160

160161
storage_checker.storage_to_remove
161162
} else {
162-
// Conservatively remove all storage statements for reused locals.
163+
// Remove the storage statements of all the reused locals.
163164
state.reused_locals.clone()
164165
};
165166

@@ -1864,7 +1865,11 @@ impl<'a, 'tcx> Visitor<'tcx> for StorageChecker<'a, 'tcx> {
18641865
self.maybe_uninit.seek_before_primary_effect(location);
18651866

18661867
if self.maybe_uninit.get().contains(local) {
1867-
debug!(?location, ?local, "local is maybe uninit in this location, removing storage");
1868+
debug!(
1869+
?location,
1870+
?local,
1871+
"local is reused and is maybe uninit at this location, marking it for storage statement removal"
1872+
);
18681873
self.storage_to_remove.insert(local);
18691874
}
18701875
}

0 commit comments

Comments
 (0)