Skip to content

Commit e3a2779

Browse files
committed
Auto merge of #69440 - Dylan-DPC:rollup-hj4bo9l, r=Dylan-DPC
Rollup of 6 pull requests Successful merges: - #69220 (Add documentation for the `-Zself-profile` flag) - #69391 (Add rustdoc aliases to `ptr::copy` and `ptr::copy_nonoverlapping`) - #69427 (Cleanup e0368 e0369) - #69433 (don't explicitly compare against true or false) - #69435 (Replace uses of Cell::get + Cell::set with Cell::replace.) - #69437 (no more codegen for miri_start_panic) Failed merges: r? @ghost
2 parents e9b9617 + e238eb6 commit e3a2779

File tree

18 files changed

+150
-32
lines changed

18 files changed

+150
-32
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# `self-profile-events`
2+
3+
---------------------
4+
5+
The `-Zself-profile-events` compiler flag controls what events are recorded by the self-profiler when it is enabled via the `-Zself-profile` flag.
6+
7+
This flag takes a comma delimited list of event types to record.
8+
9+
For example:
10+
11+
```console
12+
$ rustc -Zself-profile -Zself-profile-events=default,args
13+
```
14+
15+
## Event types
16+
17+
- `query-provider`
18+
- Traces each query used internally by the compiler.
19+
20+
- `generic-activity`
21+
- Traces other parts of the compiler not covered by the query system.
22+
23+
- `query-cache-hit`
24+
- Adds tracing information that records when the in-memory query cache is "hit" and does not need to re-execute a query which has been cached.
25+
- Disabled by default because this significantly increases the trace file size.
26+
27+
- `query-blocked`
28+
- Tracks time that a query tries to run but is blocked waiting on another thread executing the same query to finish executing.
29+
- Query blocking only occurs when the compiler is built with parallel mode support.
30+
31+
- `incr-cache-load`
32+
- Tracks time that is spent loading and deserializing query results from the incremental compilation on-disk cache.
33+
34+
- `query-keys`
35+
- Adds a serialized representation of each query's query key to the tracing data.
36+
- Disabled by default because this significantly increases the trace file size.
37+
38+
- `function-args`
39+
- Adds additional tracing data to some `generic-activity` events.
40+
- Disabled by default for parity with `query-keys`.
41+
42+
- `llvm`
43+
- Adds tracing information about LLVM passes and codegeneration.
44+
- Disabled by default because this only works when `-Znew-llvm-pass-manager` is enabled.
45+
46+
## Event synonyms
47+
48+
- `none`
49+
- Disables all events.
50+
Equivalent to the self-profiler being disabled.
51+
52+
- `default`
53+
- The default set of events which stikes a balance between providing detailed tracing data and adding additional overhead to the compilation.
54+
55+
- `args`
56+
- Equivalent to `query-keys` and `function-args`.
57+
58+
- `all`
59+
- Enables all events.
60+
61+
## Examples
62+
63+
Enable the profiler and capture the default set of events (both invocations are equivalent):
64+
65+
```console
66+
$ rustc -Zself-profile
67+
$ rustc -Zself-profile -Zself-profile-events=default
68+
```
69+
70+
Enable the profiler and capture the default events and their arguments:
71+
72+
```console
73+
$ rustc -Zself-profile -Zself-profile-events=default,args
74+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# `self-profile`
2+
3+
--------------------
4+
5+
The `-Zself-profile` compiler flag enables rustc's internal profiler.
6+
When enabled, the compiler will output three binary files in the specified directory (or the current working directory if no directory is specified).
7+
These files can be analyzed by using the tools in the [`measureme`] repository.
8+
9+
To control the data recorded in the trace files, use the `-Zself-profile-events` flag.
10+
11+
For example:
12+
13+
First, run a compilation session and provide the `-Zself-profile` flag:
14+
15+
```console
16+
$ rustc --crate-name foo -Zself-profile`
17+
```
18+
19+
This will generate three files in the working directory such as:
20+
21+
- `foo-1234.events`
22+
- `foo-1234.string_data`
23+
- `foo-1234.string_index`
24+
25+
Where `foo` is the name of the crate and `1234` is the process id of the rustc process.
26+
27+
To get a summary of where the compiler is spending its time:
28+
29+
```console
30+
$ ../measureme/target/release/summarize summarize foo-1234
31+
```
32+
33+
To generate a flamegraph of the same data:
34+
35+
```console
36+
$ ../measureme/target/release/inferno foo-1234
37+
```
38+
39+
To dump the event data in a Chromium-profiler compatible format:
40+
41+
```console
42+
$ ../measureme/target/release/crox foo-1234
43+
```
44+
45+
For more information, consult the [`measureme`] documentation.
46+
47+
[`measureme`]: https://github.com/rust-lang/measureme.git

src/libcore/intrinsics.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1515,6 +1515,7 @@ fn overlaps<T>(src: *const T, dst: *const T, count: usize) -> bool {
15151515
/// ```
15161516
///
15171517
/// [`Vec::append`]: ../../std/vec/struct.Vec.html#method.append
1518+
#[doc(alias = "memcpy")]
15181519
#[stable(feature = "rust1", since = "1.0.0")]
15191520
#[inline]
15201521
pub unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize) {
@@ -1579,6 +1580,7 @@ pub unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize) {
15791580
/// dst
15801581
/// }
15811582
/// ```
1583+
#[doc(alias = "memmove")]
15821584
#[stable(feature = "rust1", since = "1.0.0")]
15831585
#[inline]
15841586
pub unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize) {

src/librustc/mir/interpret/allocation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ impl AllocationDefinedness {
598598
pub fn all_bytes_undef(&self) -> bool {
599599
// The `ranges` are run-length encoded and of alternating definedness.
600600
// So if `ranges.len() > 1` then the second block is a range of defined.
601-
self.initial == false && self.ranges.len() == 1
601+
!self.initial && self.ranges.len() == 1
602602
}
603603
}
604604

src/librustc/ty/print/pretty.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ thread_local! {
6464
/// calling the same query.
6565
pub fn with_no_queries<F: FnOnce() -> R, R>(f: F) -> R {
6666
NO_QUERIES.with(|no_queries| {
67-
let old = no_queries.get();
68-
no_queries.set(true);
67+
let old = no_queries.replace(true);
6968
let result = f();
7069
no_queries.set(old);
7170
result
@@ -78,8 +77,7 @@ pub fn with_no_queries<F: FnOnce() -> R, R>(f: F) -> R {
7877
/// so this variable disables that check.
7978
pub fn with_forced_impl_filename_line<F: FnOnce() -> R, R>(f: F) -> R {
8079
FORCE_IMPL_FILENAME_LINE.with(|force| {
81-
let old = force.get();
82-
force.set(true);
80+
let old = force.replace(true);
8381
let result = f();
8482
force.set(old);
8583
result
@@ -89,8 +87,7 @@ pub fn with_forced_impl_filename_line<F: FnOnce() -> R, R>(f: F) -> R {
8987
/// Adds the `crate::` prefix to paths where appropriate.
9088
pub fn with_crate_prefix<F: FnOnce() -> R, R>(f: F) -> R {
9189
SHOULD_PREFIX_WITH_CRATE.with(|flag| {
92-
let old = flag.get();
93-
flag.set(true);
90+
let old = flag.replace(true);
9491
let result = f();
9592
flag.set(old);
9693
result

src/librustc_codegen_ssa/mir/block.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -515,12 +515,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
515515
return;
516516
}
517517

518-
// For normal codegen, this Miri-specific intrinsic is just a NOP.
518+
// For normal codegen, this Miri-specific intrinsic should never occur.
519519
if intrinsic == Some("miri_start_panic") {
520-
let target = destination.as_ref().unwrap().1;
521-
helper.maybe_sideeffect(self.mir, &mut bx, &[target]);
522-
helper.funclet_br(self, &mut bx, target);
523-
return;
520+
bug!("`miri_start_panic` should never end up in compiled code");
524521
}
525522

526523
// Emit a panic or a no-op for `panic_if_uninhabited`.

src/librustc_error_codes/error_codes/E0368.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
This error indicates that a binary assignment operator like `+=` or `^=` was
2-
applied to a type that doesn't support it. For example:
1+
A binary assignment operator like `+=` or `^=` was applied to a type that
2+
doesn't support it.
3+
4+
Erroneous code example:
35

46
```compile_fail,E0368
57
let mut x = 12f32; // error: binary operation `<<` cannot be applied to

src/librustc_error_codes/error_codes/E0369.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
A binary operation was attempted on a type which doesn't support it.
2+
23
Erroneous code example:
34

45
```compile_fail,E0369

src/librustc_infer/infer/mod.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -730,8 +730,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
730730
where
731731
F: FnOnce(&Self) -> R,
732732
{
733-
let flag = self.in_snapshot.get();
734-
self.in_snapshot.set(false);
733+
let flag = self.in_snapshot.replace(false);
735734
let result = func(self);
736735
self.in_snapshot.set(flag);
737736
result
@@ -740,8 +739,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
740739
fn start_snapshot(&self) -> CombinedSnapshot<'a, 'tcx> {
741740
debug!("start_snapshot()");
742741

743-
let in_snapshot = self.in_snapshot.get();
744-
self.in_snapshot.set(true);
742+
let in_snapshot = self.in_snapshot.replace(true);
745743

746744
let mut inner = self.inner.borrow_mut();
747745
CombinedSnapshot {

src/librustc_mir/dataflow/generic/engine.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ where
104104
) -> Self {
105105
let bits_per_block = analysis.bits_per_block(body);
106106

107-
let bottom_value_set = if A::BOTTOM_VALUE == true {
107+
let bottom_value_set = if A::BOTTOM_VALUE {
108108
BitSet::new_filled(bits_per_block)
109109
} else {
110110
BitSet::new_empty(bits_per_block)

src/librustc_mir/dataflow/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,7 @@ where
821821
let bits_per_block = denotation.bits_per_block();
822822
let num_blocks = body.basic_blocks().len();
823823

824-
let on_entry = if D::BOTTOM_VALUE == true {
824+
let on_entry = if D::BOTTOM_VALUE {
825825
vec![BitSet::new_filled(bits_per_block); num_blocks]
826826
} else {
827827
vec![BitSet::new_empty(bits_per_block); num_blocks]

src/librustc_parse/parser/item.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1171,13 +1171,13 @@ impl<'a> Parser<'a> {
11711171
let comma_after_doc_seen = self.eat(&token::Comma);
11721172
// `seen_comma` is always false, because we are inside doc block
11731173
// condition is here to make code more readable
1174-
if seen_comma == false && comma_after_doc_seen == true {
1174+
if !seen_comma && comma_after_doc_seen {
11751175
seen_comma = true;
11761176
}
11771177
if comma_after_doc_seen || self.token == token::CloseDelim(token::Brace) {
11781178
err.emit();
11791179
} else {
1180-
if seen_comma == false {
1180+
if !seen_comma {
11811181
let sp = self.sess.source_map().next_point(previous_span);
11821182
err.span_suggestion(
11831183
sp,

src/librustc_resolve/late/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ impl<'a> LateResolutionVisitor<'a, '_, '_> {
444444
PathSource::Expr(Some(parent)) => {
445445
suggested = path_sep(err, &parent);
446446
}
447-
PathSource::Expr(None) if followed_by_brace == true => {
447+
PathSource::Expr(None) if followed_by_brace => {
448448
if let Some((sp, snippet)) = closing_brace {
449449
err.span_suggestion(
450450
sp,

src/librustc_typeck/check/op.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
495495
Some(hir_id) => hir_id,
496496
None => return false,
497497
};
498-
if self.tcx.has_typeck_tables(def_id) == false {
498+
if !self.tcx.has_typeck_tables(def_id) {
499499
return false;
500500
}
501501
let fn_sig = {
@@ -512,7 +512,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
512512
Some(hir_id) => hir_id,
513513
None => return false,
514514
};
515-
if self.tcx.has_typeck_tables(def_id) == false {
515+
if !self.tcx.has_typeck_tables(def_id) {
516516
return false;
517517
}
518518
match self.tcx.typeck_tables_of(def_id).liberated_fn_sigs().get(hir_id) {

src/librustdoc/html/markdown.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for SummaryLine<'a, I> {
465465
}
466466
_ => true,
467467
};
468-
return if is_allowed_tag == false {
468+
return if !is_allowed_tag {
469469
if is_start {
470470
Some(Event::Start(Tag::Paragraph))
471471
} else {
@@ -671,7 +671,7 @@ impl LangString {
671671
"" => {}
672672
"should_panic" => {
673673
data.should_panic = true;
674-
seen_rust_tags = seen_other_tags == false;
674+
seen_rust_tags = !seen_other_tags;
675675
}
676676
"no_run" => {
677677
data.no_run = true;

src/librustdoc/html/render.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4049,7 +4049,7 @@ fn get_next_url(used_links: &mut FxHashSet<String>, url: String) -> String {
40494049
return url;
40504050
}
40514051
let mut add = 1;
4052-
while used_links.insert(format!("{}-{}", url, add)) == false {
4052+
while !used_links.insert(format!("{}-{}", url, add)) {
40534053
add += 1;
40544054
}
40554055
format!("{}-{}", url, add)

src/librustdoc/passes/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -340,12 +340,12 @@ pub fn look_for_tests<'tcx>(
340340

341341
find_testable_code(&dox, &mut tests, ErrorCodes::No, false);
342342

343-
if check_missing_code == true && tests.found_tests == 0 {
343+
if check_missing_code && tests.found_tests == 0 {
344344
let sp = span_of_attrs(&item.attrs).unwrap_or(item.source.span());
345345
cx.tcx.struct_span_lint_hir(lint::builtin::MISSING_DOC_CODE_EXAMPLES, hir_id, sp, |lint| {
346346
lint.build("missing code example in this documentation").emit()
347347
});
348-
} else if check_missing_code == false
348+
} else if !check_missing_code
349349
&& tests.found_tests > 0
350350
&& !cx.renderinfo.borrow().access_levels.is_public(item.def_id)
351351
{

src/librustdoc/theme.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,9 @@ pub fn get_differences(against: &CssPath, other: &CssPath, v: &mut Vec<String>)
253253
break;
254254
}
255255
}
256-
if found == false {
256+
if !found {
257257
v.push(format!(" Missing \"{}\" rule", child.name));
258-
} else if found_working == false {
258+
} else if !found_working {
259259
v.extend(tmp.iter().cloned());
260260
}
261261
}

0 commit comments

Comments
 (0)