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

Rollup of 6 pull requests #70878

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d730bf9
link with "libssp" on *-sun-solaris systems
jclulow Mar 31, 2020
2c9d857
Miri leak_report: do not report leaks of allocations that are reachab…
RalfJung Apr 4, 2020
fbdff51
avoid printing allocations twice
RalfJung Apr 4, 2020
aecaeab
share more alloc printing code between Miri and MIR dumping
RalfJung Apr 4, 2020
1f3e247
indicate better which kind of memory got leaked
RalfJung Apr 4, 2020
c8b83ba
Keep codegen units unmerged when building compiler builtins
tmiasko Apr 6, 2020
e1a36e8
Bump nomicon submodule
faern Apr 6, 2020
d0a78ea
Bump rust-by-example submodule
faern Apr 6, 2020
01b3293
Bump stdarch submodule
faern Apr 6, 2020
65e10e3
Use assoc const f32::NAN in liballoc
faern Apr 6, 2020
cf1c7ed
Use assoc float consts in libcore
faern Apr 6, 2020
ebcf1e7
Stop importing float module in libserialize
faern Apr 6, 2020
09b5d66
Stop importing float module in libtest
faern Apr 6, 2020
e4fc04b
Use usize::MAX as assoc const in liballoc
faern Apr 6, 2020
3e4396b
Use integer assoc consts in libcore
faern Apr 6, 2020
68b1af6
Don't import integer module in libstd
faern Apr 6, 2020
cf8df01
Use assoc integer constants in libserialize
faern Apr 6, 2020
f7778d3
Use assoc integer constants in librustc_*
faern Apr 6, 2020
e8339e8
Use split_at in slice's ToOwned::clone_into
cuviper Mar 20, 2020
b80fa76
Implement ToOwned::clone_into for CStr
cuviper Mar 20, 2020
f854070
Forward OsStr::clone_into to the inner Vec
cuviper Mar 20, 2020
c966511
Rollup merge of #70201 - cuviper:clone_into, r=dtolnay
Centril Apr 7, 2020
94d4c0e
Rollup merge of #70682 - jclulow:illumos-libssp, r=nagisa
Centril Apr 7, 2020
5b7a874
Rollup merge of #70762 - RalfJung:miri-leak-check, r=oli-obk
Centril Apr 7, 2020
ea29e7b
Rollup merge of #70846 - tmiasko:compiler-builtins-codegen-units, r=a…
Centril Apr 7, 2020
61cd420
Rollup merge of #70854 - faern:use-assoc-int-submodules, r=dtolnay
Centril Apr 7, 2020
17c5a81
Rollup merge of #70857 - faern:use-assoc-int-float-consts, r=dtolnay
Centril Apr 7, 2020
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
avoid printing allocations twice
  • Loading branch information
RalfJung committed Apr 4, 2020
commit fbdff5145ac3f6ecfe7bde656cfa41f5a77c8f10
2 changes: 1 addition & 1 deletion src/librustc_mir/interpret/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub trait AllocMap<K: Hash + Eq, V> {
where
K: Borrow<Q>;

/// Returns data based the keys and values in the map.
/// Returns data based on the keys and values in the map.
fn filter_map_collect<T>(&self, f: impl FnMut(&K, &V) -> Option<T>) -> Vec<T>;

/// Returns a reference to entry `k`. If no such entry exists, call
Expand Down
18 changes: 10 additions & 8 deletions src/librustc_mir/interpret/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -646,14 +646,11 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {

fn dump_alloc_helper<Tag, Extra>(
&self,
allocs_seen: &mut FxHashSet<AllocId>,
allocs_to_print: &mut VecDeque<AllocId>,
alloc: &Allocation<Tag, Extra>,
) {
for &(_, target_id) in alloc.relocations().values() {
if allocs_seen.insert(target_id) {
allocs_to_print.push_back(target_id);
}
allocs_to_print.push_back(target_id);
}
crate::util::pretty::write_allocation(self.tcx.tcx, alloc, &mut std::io::stderr(), "")
.unwrap();
Expand All @@ -666,9 +663,14 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
allocs.sort();
allocs.dedup();
let mut allocs_to_print = VecDeque::from(allocs);
let mut allocs_seen = FxHashSet::default();
// `allocs_printed` contains all allocations that we have already printed.
let mut allocs_printed = FxHashSet::default();

while let Some(id) = allocs_to_print.pop_front() {
if !allocs_printed.insert(id) {
// Already printed, so skip this.
continue;
}
eprint!("Alloc {:<5}: ", id);
fn msg<Tag, Extra>(alloc: &Allocation<Tag, Extra>, extra: &str) {
eprintln!(
Expand All @@ -688,14 +690,14 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
MemoryKind::CallerLocation => msg(alloc, " (caller_location)"),
MemoryKind::Machine(m) => msg(alloc, &format!(" ({:?})", m)),
};
self.dump_alloc_helper(&mut allocs_seen, &mut allocs_to_print, alloc);
self.dump_alloc_helper(&mut allocs_to_print, alloc);
}
Err(()) => {
// global alloc?
match self.tcx.alloc_map.lock().get(id) {
Some(GlobalAlloc::Memory(alloc)) => {
msg(alloc, " (immutable)");
self.dump_alloc_helper(&mut allocs_seen, &mut allocs_to_print, alloc);
self.dump_alloc_helper(&mut allocs_to_print, alloc);
}
Some(GlobalAlloc::Function(func)) => {
eprintln!("{}", func);
Expand All @@ -722,8 +724,8 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
});
while let Some(id) = todo.pop() {
if reachable.insert(id) {
// This is a new allocation, add its relocations to `todo`.
if let Some((_, alloc)) = self.alloc_map.get(id) {
// This is a new allocation, add its relocations to `todo`.
todo.extend(alloc.relocations().values().map(|&(_, target_id)| target_id));
}
}
Expand Down