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
Lines changed: 74 additions & 0 deletions
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+
```
Lines changed: 47 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 6 deletions
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

Lines changed: 2 additions & 5 deletions
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

Lines changed: 4 additions & 2 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 2 additions & 4 deletions
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

Lines changed: 1 addition & 1 deletion
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)

0 commit comments

Comments
 (0)