profile
viewpoint
Wesley Wiser wesleywiser HighGear Maryland @rust-lang Compiler Team

rust-lang/measureme 101

Support crate for rustc's self-profiling feature

wesleywiser/process_path 4

A Rust library to get the path of the currently executing process

JasonKleban/Unbounded 2

F# to T-SQL. Remote command execution and domain invariant enforcement

wesleywiser/Expert-System 1

An example expert system for CS 428

wesleywiser/FSharpSnippets 1

Snippets and modules of F# code.

wesleywiser/IronJS 1

IronJS - A JavaScript implementation for .NET written in F#

wesleywiser/jquery-mobile 1

jQuery Mobile Framework

wesleywiser/Reconnect-wifi-daemon 1

A simple daemon for Ubuntu which causes your computer to automatically reconnect to a specific wifi access point.

push eventwesleywiser/rust

Wesley Wiser

commit sha 7493d7c31444161c05759e332cd5599bbdb71e1b

[mir-opt] Allow debuginfo to be generated for a constant or a Place Prior to this commit, debuginfo was always generated by mapping a name to a Place. This has the side-effect that `SimplifyLocals` cannot remove locals that are only used for debuginfo because their other uses have been const-propagated. To allow these locals to be removed, we now allow debuginfo to point to a constant value. The `ConstProp` pass detects when debuginfo points to a local with a known constant value and replaces it with the value. This allows the later `SimplifyLocals` pass to remove the local.

view details

push time in 11 hours

Pull request review commentrust-lang/rust

[mir-opt] Allow debuginfo to be generated for a constant or a Place

       let mut _2: i32;                     // in scope 0 at $DIR/aggregate.rs:5:13: 5:24       let mut _3: (i32, i32, i32);         // in scope 0 at $DIR/aggregate.rs:5:13: 5:22       scope 1 {-          debug x => _1;                   // in scope 1 at $DIR/aggregate.rs:5:9: 5:10+-         debug x => _1;                   // in scope 1 at $DIR/aggregate.rs:5:9: 5:10++         debug x => const 1_i32;          // in scope 1 at $DIR/aggregate.rs:5:9: 5:10

We have a SimplifyLocal pass that runs right after ConstProp which will remove the _1 local.

wesleywiser

comment created time in 13 hours

Pull request review commentrust-lang/rust

[mir-opt] Allow debuginfo to be generated for a constant or a Place

  fn main() -> () {     let mut _0: ();                      // return place in scope 0 at $DIR/optimizes_into_variable.rs:11:11: 11:11-    let _1: i32;                         // in scope 0 at $DIR/optimizes_into_variable.rs:12:9: 12:10     scope 1 {-        debug x => _1;                   // in scope 1 at $DIR/optimizes_into_variable.rs:12:9: 12:10-        let _2: i32;                     // in scope 1 at $DIR/optimizes_into_variable.rs:13:9: 13:10+        debug x => const 4_i32;          // in scope 1 at $DIR/optimizes_into_variable.rs:12:9: 12:10         scope 2 {-            debug y => _2;               // in scope 2 at $DIR/optimizes_into_variable.rs:13:9: 13:10-            let _3: u32;                 // in scope 2 at $DIR/optimizes_into_variable.rs:14:9: 14:10+            debug y => const 3_i32;      // in scope 2 at $DIR/optimizes_into_variable.rs:13:9: 13:10             scope 3 {-                debug z => _3;           // in scope 3 at $DIR/optimizes_into_variable.rs:14:9: 14:10+                debug z => const 42_u32; // in scope 3 at $DIR/optimizes_into_variable.rs:14:9: 14:10

Yep, this test inspired me to work on this 🙂

wesleywiser

comment created time in 13 hours

Pull request review commentrust-lang/rust

[mir-opt] Allow debuginfo to be generated for a constant or a Place

 macro_rules! make_mir_visitor {                 let VarDebugInfo {                     name: _,                     source_info,-                    place,+                    value,                 } = var_debug_info;                  self.visit_source_info(source_info);                 let location = START_BLOCK.start_location();-                self.visit_place(-                    place,-                    PlaceContext::NonUse(NonUseContext::VarDebugInfo),-                    location,-                );+                match value {+                    VarDebugInfoContents::Const(c) => self.visit_const(c, location),+                    VarDebugInfoContents::Place(place) => self.visit_place(place, PlaceContext::NonUse(NonUseContext::VarDebugInfo), location),

Hmm maybe rustfmt doesn't know what to do since it's in a macro definition? I'm not familiar with rustfmt internals so I'll just wrap it manually.

wesleywiser

comment created time in 13 hours

issue commentrust-lang/rust

1.46.0-nightly panics on a particular proc macro invocation

I have a minimal repro:

pub struct Fixed64(i64);

pub fn div(f: Fixed64) {
    f.0 / 0;
}

playground

drahnr

comment created time in 3 days

pull request commentrust-lang/rust

[mir-opt] Fix mis-optimization and other issues with the SimplifyArmIdentity pass

Sounds good. Thanks @Manishearth!

wesleywiser

comment created time in 3 days

issue commentrust-lang/rust

1.46.0-nightly panics on a particular proc macro invocation

Here's a smaller repro (at least in terms of how much code is built: 33 crates instead of a few hundred):

git clone https://github.com/hicommonwealth/substrate.git
cd substrate
git checkout 00a400f82539e2f78e8ddbcd98aea512c87c5f3c
cd ..
mkdir smaller_repo
cd smaller_repo
mkdir primitives
cp ../substrate/Cargo.lock .
cp -r ../substrate/primitives/arithmetic/ ./primitives/ 
cp -r ../substrate/primitives/debug-derive/ ./primitives/ 
cp -r ../substrate/primitives/std/ ./primitives/ 
cd primitives/arithmetic
cargo +nightly build --release --target=wasm32-unknown-unknown
drahnr

comment created time in 3 days

pull request commentrust-lang/rust

[mir-opt] Fix mis-optimization and other issues with the SimplifyArmIdentity pass

@Manishearth More out of an abundance of caution although, since this pass is disabled, it shouldn't have any effect (performance or correctness).

wesleywiser

comment created time in 3 days

issue commentrust-lang/rust

1.46.0-nightly panics on a particular proc macro invocation

That did it! Thank you 🙂

drahnr

comment created time in 3 days

issue commentrust-lang/rust

1.46.0-nightly panics on a particular proc macro invocation

I'm getting this when I try to repro:

wesley@endurance:~/code/rust/edgeware-node> cargo +nightly build --release -p edgeware-runtime
    Updating git repository `https://github.com/hicommonwealth/substrate.git`
error: failed to get `frame-support` as a dependency of package `edge-signaling v1.0.0 (/home/wesley/code/rust/edgeware-node/modules/edge-signaling)`

Caused by:
  failed to load source for dependency `frame-support`

Caused by:
  Unable to update https://github.com/hicommonwealth/substrate.git#1164dec0

Caused by:
  object not found - no match for id (1164dec08a2829de54e09ae4d8554a952d05b9a8); class=Odb (9); code=NotFound (-3)

On a side note, are there any cargo feature flags I can pass to cut down on how much stuff is being compiled? Compiling 900 crates to get a repo is quite a lot 🙂

drahnr

comment created time in 3 days

pull request commentrust-lang/rust

[mir-opt] Fix mis-optimization and other issues with the SimplifyArmIdentity pass

Since this messes with mir-opt stuff, I'm going to say

@bors rollup=never

Just in case 🙂

wesleywiser

comment created time in 3 days

Pull request review commentrust-lang/rust

[mir-opt] Fix mis-optimization and other issues with the SimplifyArmIdentity pass

 impl LocalUseCounter {  impl<'tcx> Visitor<'tcx> for LocalUseCounter {     fn visit_local(&mut self, local: &Local, context: PlaceContext, _location: Location) {-        if context.is_storage_marker() {+        if context.is_storage_marker()+            || context == PlaceContext::NonUse(NonUseContext::VarDebugInfo)

Hmm I guess those are unused after NLL runs right? Maybe we should have a separate pass that runs at the beginning of the optimization phase and removes all of those?

wesleywiser

comment created time in 3 days

pull request commentrust-lang/rust

Use exhaustive match in const_prop.rs

Looks like a networking issue or something?

error: failed to get `cc` as a dependency of package `bootstrap v0.0.0 (/checkout/src/bootstrap)`

Caused by:
  failed to fetch `https://github.com/rust-lang/crates.io-index`

Caused by:
  error inflating zlib stream; class=Zlib (5)
failed to run: /checkout/obj/build/i686-unknown-linux-gnu/stage0/bin/cargo build --manifest-path /checkout/src/bootstrap/Cargo.toml --locked
Build completed unsuccessfully in 0:00:26

@bors r=oli-obk

wesleywiser

comment created time in 3 days

pull request commentrust-lang/rust

Use exhaustive match in const_prop.rs

@bors rollup

wesleywiser

comment created time in 3 days

pull request commentrust-lang/rust

[mir-opt] Fix mis-optimization and other issues with the SimplifyArmIdentity pass

@oli-obk I think I forgot to re-bless the mir-opt tests after splitting this into different commits so that's probably part of the issue. I've implemented your suggestion and blessed each commit so you can see the changes.

wesleywiser

comment created time in 3 days

push eventwesleywiser/rust

Wesley Wiser

commit sha e3f599c15cceb38159a5690a21befbe7f36f5914

Add test for simplify-try misoptimization

view details

Wesley Wiser

commit sha 9248d90d20601e9d489a4a1c21df9de686b9fd82

[mir-opt] Prevent mis-optimization when SimplifyArmIdentity runs If temporaries are used beyond just the temporary chain, then we can't optimize out the reads and writes.

view details

Wesley Wiser

commit sha 24bfdc98e9f02ff7974328f92a0e7ef67eab5f46

Fix debuginfo so that it points to the correct local

view details

Wesley Wiser

commit sha e16d6a6c6465d19c6d7091e5b59eb4b4528aa9f8

Fix missing return in `optimization_applies()`

view details

push time in 3 days

pull request commentrust-lang/rust

[mir-opt] Allow debuginfo to be generated for a constant or a Place

Rebased and CI is passing.

wesleywiser

comment created time in 4 days

pull request commentrust-lang/rust

Use exhaustive match in const_prop.rs

Rebased and add a comment.

wesleywiser

comment created time in 4 days

push eventwesleywiser/rust

pankajchaudhary5

commit sha 46bfc48272ba5312c439557e2901e1a4778e9487

Added proper explanation of ErrorCode-E0687

view details

Matthias Krüger

commit sha 1d0378c454de72ddcfc08bcc105744923ef2d4d4

impl From<char> for String This allows us to write fn char_to_string() -> String { 'a'.into() } which was not possible before.

view details

Tomasz Miąsko

commit sha 5c20ef433b48fce78c07208710bcc8b53965eeb1

bootstrap: Configurable musl libdir Make it possible to customize the location of musl libdir using musl-libdir in config.toml, e.g., to use lib64 instead of lib.

view details

Matthias Krüger

commit sha 2cde4932c7e8bd6000378af41029299ccf6eea69

add test for char into string

view details

Anirban

commit sha 886f81e1d0883f67fbc81b8ece61b1c33f6923d2

Fix sentence structure Fixed grammar and sentence structure on appropriate instances.

view details

Dylan McKay

commit sha 50f20ec576ae72ceff6bf5a50c940cf574990e56

[AVR] Update the rust-lang/llvm-project submodule to include AVR fixes recently merged This commit updates rustc's LLVM submodule to include new AVR-specific fixes recently merged on the Rust LLVM 'rustc/10.0-2020-05-05' branch. All of these cherry-picked commits exist in upstream LLVM and were cherry-picked into Rust's LLVM fork in commit 6c040dd86ed. |- 6c040dd86ed Merge pull request #66 from dylanmckay/avr-pick-upstream-llvm-fixes |- 12dfdd3aed7 [AVR] Rewrite the function calling convention. |- 118ac53f12b [AVR] Don't adjust for instruction size |- bc27c282e13 [AVR] Fix miscompilation of zext + add |- cfbe205a7e8 [AVR] Remove faulty stack pushing behavior |- 143e1469e96 [AVR] Fix stack size in functions with a frame pointer |- 6b2445d841e [LLVM][AVR] Support for R_AVR_6 fixup |- 93ee4da19cf [AVR] Fix I/O instructions on XMEGA |- 962c2415ffb [AVR] Do not place functions in .progmem.data |- 65b8b170aef [AVR] Do not use divmod calls for bigger integers |- 93a3b595d1c [AVR] Generalize the previous interrupt bugfix to signal |- handlers too |- cc4286349b4 [AVR] Respect the 'interrupt' function attribute |- 954d0a92205 [AVR] Fix reads of uninitialized variables from constructor of AVRSubtarget |- 1c0ddae73c9 [AVR] Fix read of uninitialized variable AVRSubtarget:::ELFArch |- 0ed0823fe60 [AVR] Fix incorrect register state for LDRdPtr |- 96075fc433d [AVR] Don't adjust addresses by 2 for absolute values |- 6dfc55ba53b [AVR] Use correct register class for mul instructions These changes include both correctness fixes and LLVM assertion error fixes. Once all of these commits have been cherry-picked, all of the LLVM plumbing for rust-lang/master to compile the AVR blink program will be in place. Once this commit is merged, only PR rust-lang/rust#73270 will be blocking successful compilation and emission of the AVR LED blink program.

view details

Keno Fischer

commit sha 0c88dd663a7095ccc405a2036047a90981137a51

Update Box::from_raw example to generalize better I know very little about rust, so I saw this example and tried to generalize it by writing, ``` let layout = Layout::new::<T>(); let new_obj = unsafe { let ptr = alloc(layout) as *mut T; *ptr = obj; Box::from_raw(ptr) }; ``` for some more complicated `T`, which ended up crashing with SIGSEGV, because it tried to `drop_in_place` the previous object in `ptr` which is of course garbage. I also added a comment that explains why `.write` is used, but I think adding that comment is optional and may be too verbose here. I do however think that changing this example is a good idea to suggest the correct generalization. `.write` is also used in most of the rest of the documentation here, even if the example is `i32`, so it would additionally be more consistent.

view details

Anirban

commit sha 3b5d7f8cf66c6704d36b021f7173241d6351ad32

Minor correction to sentence structure

view details

Anirban

commit sha d6cf8fc63ee24269bd4df20ad9fe19a219b5c9f5

Update README.md

view details

Alexis Bourget

commit sha 2bbc2b3de42f3b14ccc8b62c2acffc8840177777

Document the static keyword

view details

Anirban

commit sha 22fc18f1776ab05688d2f57ed92e14830a44d1ee

Commit suggestion Co-authored-by: Niko Matsakis <niko@alum.mit.edu>

view details

Anirban

commit sha 8edcc6d00d329c4cbe51b483bb82a1b365a073b4

Add alternate text for rust logo image

view details

Anirban

commit sha 3a1ac2823167e6254066758a7487ad384d32d7da

Added clickable-link Linked the logo/svg to https://www.rust-lang.org/ (change if required)

view details

Anirban

commit sha 4c33b7c8d69648edcc7f4f3d2edbf96c00060d1e

Add responsiveness to logo Added responsiveness to image logo based on device width (set at 90% of device width, which can be changed as per requirement)

view details

Tyler Ruckinger

commit sha 00ef46169e2b2631d41d6aa1b7c55b8abf006e50

Merge pull request #2 from rust-lang/master update master

view details

Tyler Ruckinger

commit sha b71a3e1e3a20e7db3b8167d19002c372ffe69c54

Map ERROR_INVALID_PARAMETER to InvalidInput

view details

root

commit sha 15e81beb474235d100995f3bcc72d15086a8e29e

moves terminator types to sub module

view details

root

commit sha cf398a33ebff501a01c9c91fe5615992c936d292

removes unnecessary tidy ignore

view details

Gary Guo

commit sha 224bc052564117abfb8716772779ade221133395

Fix allow_internal_unstable with rustc_const_unstable

view details

Gary Guo

commit sha fc239e82fe1ef91632dfa858487d89141aaab7a7

Make `likely` and `unlikely` const They are gated by internal feature gate const_likely

view details

push time in 4 days

issue commentrust-lang/rust

Slice index becomes wrong (beta regression)

@JohnTitor All good! The PR you're looking for is #73949 🙂

djc

comment created time in 4 days

PR opened rust-lang/rust

[mir-opt] Fix mis-optimization and other issues with the SimplifyArmIdentity pass

This does not yet attempt re-enabling the pass, but it does resolve a number of issues with the pass.

r? @oli-obk

+154 -35

0 comment

8 changed files

pr created time in 4 days

create barnchwesleywiser/rust

branch : simplify_try_fixes

created branch time in 4 days

issue commentrust-lang/rust

Slice index becomes wrong (beta regression)

@JohnTitor Did you mean to link a different PR? I don't think that one is related to this issue.

djc

comment created time in 5 days

pull request commentrust-lang/rust

Move terminator to new module

Thanks!

r? @wesleywiser

@bors r+ rollup

aszenz

comment created time in 6 days

push eventwesleywiser/rust

Carsten Andrich

commit sha c88e6a75f5f681610142aaba351cdd6e30deed95

add Windows system error codes that map to io::ErrorKind::TimedOut

view details

Carsten Andrich

commit sha 86679967e3cc895d2b5ab4bb974664ff283fe043

use or pattern to match error codes that map to ErrorKind::TimedOut

view details

Carsten Andrich

commit sha c69d6c84c7042d767e55f69ff544de0098a6042f

fix formatting issues that fail tidy test

view details

Eduardo Sánchez Muñoz

commit sha f03cf9916a1932f47b788a9de9256269cc172fe9

Add a fast path for `std::thread::panicking`. This is done by adding a global atomic variable (non-TLS) that counts how many threads are panicking. In order to check if the current thread is panicking, this variable is read and, if it is zero, no thread (including the one where `panicking` is being called) is panicking and `panicking` can return `false` immediately without needing to access TLS. If the global counter is not zero, the local counter is accessed from TLS to check if the current thread is panicking.

view details

Tomasz Miąsko

commit sha e4b7d2c5071d1066159702d8176c6d87d843403e

Omit DW_AT_linkage_name when it is the same as DW_AT_name The DWARF standard suggests that it might be useful to include `DW_AT_linkage_name` when it is *distinct* from the identifier name.

view details

Nathan West

commit sha 358dc1d8c2e10eceaf3c04d532bbde73b0dd4bb7

Added io forwarding methods to the stdio structs

view details

Alexis Bourget

commit sha 2031e99d772091854d716df5bdf227f8be9b6397

Added implementations for TryFrom<{int}> for NonZero{int}

view details

Alexis Bourget

commit sha d8b51f180a9c6ced4397ce5568fa8ab553a7143e

Added tests for the implementations

view details

Guillaume Gomez

commit sha b97487bad8608afe05f34f07016aa6276c1a291d

Add check for doc alias attribute format

view details

Guillaume Gomez

commit sha 2d6267a7a8ae0399f2d363b6ac667fee0b53a1a0

Add test for doc alias attribute validation

view details

Vadim Petrochenkov

commit sha 69b2179afe695d1a93b792cfd7c4197ca63ce658

Print accessed env vars as special comments into depinfo files

view details

TrolledWoods

commit sha 0c5c644c91edf6ed949cfa5ffc524f43369df604

Mention that BTreeMap::new() doesn't allocate I think it would be nice to mention this, so you don't have to dig through the src to look at the definition of new().

view details

Carol (Nichols || Goulding)

commit sha e85df08bdec792f512c1f92dbdb126c49ac57d0c

Don't move cursor in search box when using arrows to navigate search results

view details

Yoshua Wuyts

commit sha 2764e54c29d0f19242e794d5eecd00cc5470f530

impl ToSocketAddrs for (String, u16)

view details

Yoshua Wuyts

commit sha 8bc6b5b45c9f9710852e2b9c57eb3d44d08ad245

stabilize leading_trailing_ones

view details

Alexis Bourget

commit sha 0dcb392e9889ab6976973a2f7140d18a80178202

Added implementations for NonZero(U|I)size

view details

Alexis Bourget

commit sha 2b8e2f836f59db23630a06554b8e1a33f6c502f5

Correctly format the tests and import TryFrom

view details

Alexis Bourget

commit sha 6c8d8d6a6055d19dc33cc8b33b082d17583a0e47

Fix test call for error case

view details

Devin R

commit sha a4b8bb88f210de7fa2d82fe64b48331126eb7462

warn on macro_use attr cargo dev update lints use if_chain clean up alot, span_lint_and_sugg find imported macros for sugg

view details

Devin R

commit sha ede366be637657280ca506c5bad0f41f96c47340

collected all the imports and names how to compare macro to import path add more imports to test

view details

push time in 6 days

push eventwesleywiser/rust

Tom Eccles

commit sha 086eaf8f69b736a7f4b6b8ee232540993d0c255d

tools: remote-test-client: fix typo Thanks to jfrimmel for pointing this out Co-authored-by: J. Frimmel <31166235+jfrimmel@users.noreply.github.com>

view details

Manish Goregaokar

commit sha 27dcb4aab534741f747354c6a72ff29d0ccce329

Avoid collisions between traits and their derive macros

view details

Manish Goregaokar

commit sha 178465516ef7571cc25a1d243902d3ea8fa220e0

Don't print bang diagnostics for derives

view details

Matthew Jasper

commit sha 88ea7e5234bff0c4fcf5859aa6d5dd8d0608b853

Use min_specialization in the remaining rustc crates

view details

Dylan DPC

commit sha a70fb70c1f64198263e949f23aee643005f44cea

Rollup merge of #72706 - spastorino:add-windows-group, r=nikomatsakis Add windows group to triagebot r? @nikomatsakis

view details

Dylan DPC

commit sha 78d08a2269e359aa54f997a0fefe1eb828899a5c

Rollup merge of #72789 - petrochenkov:impcand, r=davidtwco resolve: Do not suggest imports from the same module in which we are resolving Based on the idea from https://github.com/rust-lang/rust/pull/72623.

view details

Dylan DPC

commit sha fda594e6ae5c430475120944b8a0e92fe8f206a5

Rollup merge of #72890 - davidtwco:issue-66202-normalize-and-transparent-improper-ctypes, r=varkor improper ctypes: normalize return types and transparent structs Fixes #66202. See each commit individually (except the first which adds a test) for more detailed explanations on the changes made. In summary, this PR ensures that return types are normalized before being checked for FFI-safety, and that transparent newtype wrappers are FFI-safe if the type being wrapped is FFI-safe (often true previously, but not if, after substitution, all types in a transparent newtype were zero sized).

view details

Dylan DPC

commit sha 8addb2e684dfbe0cd2e16a769485a093f9b2de32

Rollup merge of #72897 - lcnr:structurally-match-normalize, r=pnkfelix normalize adt fields during structural match checking fixes #72896 currently only fixes the issue itself and compiles stage 1 libs. I believe we have to use something else to normalize the adt fields here, as I expect some partially resolved adts to cause problems :thinking: stage 1 libs and the test itself pass, not sure about the rest... Will spend some more time looking into it tomorrow. r? @pnkfelix cc @eddyb

view details

Dylan DPC

commit sha 024f025934a40056364be4a4da4f7e078b419f68

Rollup merge of #73005 - Aaron1011:fix/error-overflow, r=estebank Don't create impl candidates when obligation contains errors Fixes #72839 In PR #72621, trait selection was modified to no longer bail out early when an error type was encountered. This allowed us treat `ty::Error` as `Sized`, causing us to avoid emitting a spurious "not sized" error after a type error had already occured. However, this means that we may now try to match an impl candidate against the error type. Since the error type will unify with almost anything, this can cause us to infinitely recurse (eventually triggering an overflow) when trying to verify certain `where` clauses. This commit causes us to skip generating any impl candidates when an error type is involved.

view details

Dylan DPC

commit sha e1cd8c41a559276a2a8ff62085ded220cccb88f3

Rollup merge of #73023 - ayushmishra2005:remove_noisy_suggestion, r=davidtwco Remove noisy suggestion of hash_map Remove noisy suggestion of hash_map #72642 fixes #72642

view details

Dylan DPC

commit sha 0a77c8c2956259eb6811b51fac095c8ed21e6760

Rollup merge of #73070 - ayazhafiz:i/72819, r=nikomatsakis Add regression test for const generic ICE in #72819 Closes #72819

view details

Dylan DPC

commit sha e04e3c89cc08546c5c762ea915cb72d4069a733e

Rollup merge of #73157 - Aaron1011:where-oh-where-has-my-little-span-gone, r=ecstatic-morse Don't lose empty `where` clause when pretty-printing Previously, we would parse `struct Foo where;` and `struct Foo;` identically, leading to an 'empty' `where` clause being omitted during pretty printing. This will cause us to lose spans when proc-macros involved, since we will have a collected `where` token that does not appear in the pretty-printed item. We now explicitly track the presence of a `where` token during parsing, so that we can distinguish between `struct Foo where;` and `struct Foo;` during pretty-printing

view details

Dylan DPC

commit sha 2b8f1eccaa138a2a4af61356231c33d7d93ed993

Rollup merge of #73184 - mati865:fix-mingw-libs-order, r=petrochenkov Reoder order in which MinGW libs are linked to fix recent breakage Recent upstream mingw-w64 changes made libmsvcrt depend on libmingwex breaking compilation in some cases when using **external** MinGW. Applying this change to the master fixes nightly and stage{1,2} build. For stage0 one has to export `RUSTFLAGS_BOOTSTRAP='-C link-arg=-lmsvcrt'` until this PR lands in bootstrap compiler. Therefore I'm humbly asking to also backport it to the beta and update bootstrap compiler.

view details

Guillaume Gomez

commit sha dc230c06b226947a5a9980d2947118fd4a8ece9e

Clean up E0648 explanation

view details

Guillaume Gomez

commit sha 50a42fe5134fd8dbd5bc6df110654a31ee059a62

Create new error code E0762 for unterminated char literals

view details

Guillaume Gomez

commit sha 7bd87cfac2ca4c2c19b04018774b1fb1a9b39e48

Add tests for E0762

view details

Mihail Malo

commit sha 5859f6e4f792afb663ac2dc98191cca08ac9b4ae

Fix doctest template `saturating_add` example was not parameterized, but passed because the `u8` would saturate successfully

view details

Eric Huss

commit sha cd02052ad083ae0927a08483035b5dca214bdd0d

Fix emcc failure for wasm32.

view details

Manish Goregaokar

commit sha 34c6b38e68f2e88bcc6c943494a7c05d35a71f17

Add tests for macro@ and derive@

view details

Ralf Jung

commit sha f507748ce49f8e9ce5dc76bb7811a374c814923f

x.py: with --json-output, forward cargo's JSON

view details

push time in 6 days

PR closed rust-lang/rust

[wip] Tweak cgu partitioning S-waiting-on-author

r? @ghost

+88 -12

24 comments

3 changed files

wesleywiser

pr closed time in 7 days

pull request commentrust-lang/rust

add spans to injected coverage counters, extract with CoverageData query

Yes, this looks great!

@bors r+ rollup

richkadel

comment created time in 7 days

pull request commentrust-lang/rust

add spans to injected coverage counters, extract with CoverageData query

@richkadel I have a similar workflow but I have pull.rebase set to true so that git pull always does git pull --rebase which does not introduce merge commits (see git-pull). Without the merge commits to deal with, you can simplify your workflow a bit:

$ git checkout <dev-branch-for-current-rust-lang-PR>
$ git fetch origin # make the latest upstream changes available in your local repo
$ git rebase origin/master # Rebase your changes on top of upstream. NOTE: origin/branch means use branch as it is on origin, not your local repo. Therefore, you don't have to checkout master and pull it before rebasing. 
$ git push -f   # will try --force-with-lease next time
richkadel

comment created time in 7 days

Pull request review commentrust-lang/rust

add spans to injected coverage counters, extract with CoverageData query

 impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {                 self.copy_op(self.operand_index(args[0], index)?, dest)?;             }             // FIXME(#73156): Handle source code coverage in const eval-            sym::count_code_region => (),+            sym::count_code_region+            | sym::coverage_counter_add+            | sym::coverage_counter_subtract+            | sym::coverage_unreachable => (),

I think that's a fair characterization. The intrinsics are injected via a MIR pass enabled by the -Zinstrument-coverage flag.

richkadel

comment created time in 7 days

delete branch wesleywiser/team

delete branch : patch-1

delete time in 7 days

Pull request review commentrust-lang/rust

add spans to injected coverage counters, extract with CoverageData query

 impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {                 self.copy_op(self.operand_index(args[0], index)?, dest)?;             }             // FIXME(#73156): Handle source code coverage in const eval-            sym::count_code_region => (),+            sym::count_code_region+            | sym::coverage_counter_add+            | sym::coverage_counter_subtract+            | sym::coverage_unreachable => (),

Also cc @rust-lang/lang. This PR adds a few new intrinsics which are being used by the LLVM code coverage feature @richkadel is adding. Currently, these intrinsics are no-ops when evaluated at compile time (see https://github.com/rust-lang/rust/issues/73156 for possible future extensions where these could measure code coverage when run by the const eval machinery).

richkadel

comment created time in 7 days

pull request commentrust-lang/rust

add spans to injected coverage counters, extract with CoverageData query

@richkadel This looks mostly right to me although there's still 3 merge commits in addition to the actual changes.

What I usually do is this (assuming you have the remote origin which points to this repo and fork which points to your fork of the repo):

$ git fetch origin # grab the latest upstream changes
$ # assuming you're already on the latest commit of your branch with changes
$ git rebase -i origin/master # take the commits in your branch and replay them on top of origin/master
$ # this is the point where you can edit the git todo file and squash the commits together
$ git push fork -f # If you don't have a matching branch set up, then use `git push fork -f HEAD:{branch_name}`
richkadel

comment created time in 7 days

pull request commentrust-lang/rust

add spans to injected coverage counters, extract with CoverageData query

Would you mind squashing the commits together?

richkadel

comment created time in 7 days

Pull request review commentrust-lang/rust

add spans to injected coverage counters, extract with CoverageData query

 impl<'tcx> Instrumentor<'tcx> {             new_block,             TerminatorKind::Call {                 func: count_code_region_fn,-                args: vec![counter_index],+                args,                 // new_block will swapped with the next_block, after applying patch                 destination: Some((Place::from(temp), new_block)),

The mir-opt working group has also discussed optimizing out StorageLive and StorageDead for ZSTs like () before. I wouldn't worry about the performance of this yet since we can optimize this later if need be.

richkadel

comment created time in 8 days

Pull request review commentrust-lang/rust

add spans to injected coverage counters, extract with CoverageData query

+use rustc_data_structures::fx::FxHashMap;+use std::collections::hash_map;+use std::slice;++#[derive(Copy, Clone, Debug)]+pub enum CounterOp {+    Add,+    Subtract,+}++pub enum CoverageKind {+    Counter,+    CounterExpression(u32, CounterOp, u32),+}++pub struct CoverageSpan {+    pub start_byte_pos: u32,+    pub end_byte_pos: u32,+}++pub struct CoverageRegion {+    pub kind: CoverageKind,+    pub coverage_span: CoverageSpan,+}++/// Collects all of the coverage regions associated with (a) injected counters, (b) counter+/// expressions (additions or subtraction), and (c) unreachable regions (always counted as zero),+/// for a given Function. Counters and counter expressions are indexed because they can be operands+/// in an expression.+///+/// Note, it's important to distinguish the `unreachable` region type from what LLVM's refers to as+/// a "gap region" (or "gap area"). A gap region is a code region within a counted region (either+/// counter or expression), but the line or lines in the gap region are not executable (such as+/// lines with only whitespace or comments). According to LLVM Code Coverage Mapping documentation,+/// "A count for a gap area is only used as the line execution count if there are no other regions+/// on a line."+pub struct FunctionCoverageRegions {+    indexed: FxHashMap<u32, CoverageRegion>,+    unreachable: Vec<CoverageSpan>,+}++impl FunctionCoverageRegions {+    pub fn new() -> Self {+        Self { indexed: FxHashMap::default(), unreachable: Default::default() }+    }++    pub fn new_counter(&mut self, index: u32, start_byte_pos: u32, end_byte_pos: u32) {

Nit: I would call this add_counter. new_counter makes me think this will return a value.

richkadel

comment created time in 8 days

Pull request review commentrust-lang/rust

add spans to injected coverage counters, extract with CoverageData query

+use crate::coverageinfo::CounterOp;+//use crate::coverageinfo::map::FunctionCoverageRegions;

Nit: There's some commented out code in this file.

richkadel

comment created time in 8 days

Pull request review commentrust-lang/rust

add spans to injected coverage counters, extract with CoverageData query

 impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {                 self.copy_op(self.operand_index(args[0], index)?, dest)?;             }             // FIXME(#73156): Handle source code coverage in const eval-            sym::count_code_region => (),+            sym::count_code_region+            | sym::coverage_counter_add+            | sym::coverage_counter_subtract+            | sym::coverage_unreachable => (),

Heads up @rust-lang/wg-const-eval, this PR is adding some new stub intrinsics which are used by the LLVM code coverage feature @richkadel is adding.

richkadel

comment created time in 8 days

Pull request review commentrust-lang/rust

add spans to injected coverage counters, extract with CoverageData query

 impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {         }          if intrinsic.is_some() && intrinsic != Some("drop_in_place") {+            let intrinsic = intrinsic.unwrap();++            if !bx.is_codegen_intrinsic(intrinsic, &args, self.instance) {

Maybe add a short comment explaining what this is checking for?

richkadel

comment created time in 8 days

Pull request review commentrust-lang/rust

add spans to injected coverage counters, extract with CoverageData query

 pub trait IntrinsicCallMethods<'tcx>: BackendTypes {         caller_instance: ty::Instance<'tcx>,     ); +    /// Intrinsic-specific pre-codegen processing, if any. Returns true if codegen is also required.

Maybe expand this a bit?

    /// Intrinsic-specific pre-codegen processing, if any is required. Some intrinsics are handled at compile time and do not generate code. Returns true if codegen is required or false if the intrinsic does not need code generation.
richkadel

comment created time in 8 days

Pull request review commentrust-lang/rust

add spans to injected coverage counters, extract with CoverageData query

+use rustc_data_structures::fx::FxHashMap;+use std::collections::hash_map;+use std::slice;++#[derive(Copy, Clone, Debug)]+pub enum CounterOp {+    Add,+    Subtract,+}++pub enum CoverageKind {+    Counter,+    CounterExpression(u32, CounterOp, u32),+}++pub struct CoverageSpan {+    pub start_byte_pos: u32,+    pub end_byte_pos: u32,+}++pub struct CoverageRegion {+    pub kind: CoverageKind,+    pub coverage_span: CoverageSpan,+}++/// Collects all of the coverage regions associated with (a) injected counters, (b) counter+/// expressions (additions or subtraction), and (c) unreachable regions (always counted as zero),+/// for a given Function. Counters and counter expressions are indexed because they can be operands+/// in an expression.+///+/// Note, it's important to distinguish the `unreachable` region type from what LLVM's refers to as+/// a "gap region" (or "gap area"). A gap region is a code region within a counted region (either+/// counter or expression), but the line or lines in the gap region are not executable (such as+/// lines with only whitespace or comments). According to LLVM Code Coverage Mapping documentation,+/// "A count for a gap area is only used as the line execution count if there are no other regions+/// on a line."+pub struct FunctionCoverageRegions {+    indexed: FxHashMap<u32, CoverageRegion>,+    unreachable: Vec<CoverageSpan>,+}++impl FunctionCoverageRegions {+    pub fn new() -> Self {+        Self { indexed: FxHashMap::default(), unreachable: Default::default() }+    }++    pub fn new_counter(&mut self, index: u32, start_byte_pos: u32, end_byte_pos: u32) {+        self.indexed.insert(+            index,+            CoverageRegion {+                kind: CoverageKind::Counter,+                coverage_span: CoverageSpan { start_byte_pos, end_byte_pos },+            },+        );+    }++    pub fn new_counter_expression(+        &mut self,+        index: u32,+        lhs: u32,+        op: CounterOp,+        rhs: u32,+        start_byte_pos: u32,+        end_byte_pos: u32,+    ) {+        self.indexed.insert(+            index,+            CoverageRegion {+                kind: CoverageKind::CounterExpression(lhs, op, rhs),+                coverage_span: CoverageSpan { start_byte_pos, end_byte_pos },+            },+        );+    }++    pub fn new_unreachable(&mut self, start_byte_pos: u32, end_byte_pos: u32) {

Nit: Similarly add_unreachable

richkadel

comment created time in 8 days

Pull request review commentrust-lang/rust

add spans to injected coverage counters, extract with CoverageData query

+//! Metadata from source code coverage analysis and instrumentation.++/// Positional arguments to `libcore::count_code_region()`+pub mod count_code_region_args {+    pub const COUNTER_INDEX: usize = 0;+    pub const START_BYTE_POS: usize = 1;+    pub const END_BYTE_POS: usize = 2;+}++/// Positional arguments to `libcore::coverage_counter_add()` and+/// `libcore::coverage_counter_subtract()`+pub mod coverage_counter_expression_args {

I almost wonder if these should be enums and cast to the appropriate integer size at use sites. This is probably fine though.

richkadel

comment created time in 8 days

Pull request review commentrust-lang/rust

add spans to injected coverage counters, extract with CoverageData query

+use crate::builder::Builder;+use crate::common::CodegenCx;+use log::debug;+use rustc_codegen_ssa::coverageinfo::map::*;+use rustc_codegen_ssa::traits::{CoverageInfoBuilderMethods, CoverageInfoMethods};+use rustc_data_structures::fx::FxHashMap;+use rustc_middle::ty::Instance;++use std::cell::RefCell;++/// A context object for maintaining all state needed by the coverageinfo module.+pub struct CrateCoverageContext<'tcx> {+    // Coverage region data for each instrumented function identified by DefId.+    pub(crate) coverage_regions: RefCell<FxHashMap<Instance<'tcx>, FunctionCoverageRegions>>,+}++impl<'tcx> CrateCoverageContext<'tcx> {+    pub fn new() -> Self {+        Self { coverage_regions: Default::default() }+    }+}++/// Generates and exports the Coverage Map.+// FIXME(richkadel): Actually generate and export the coverage map to LLVM.+// The current implementation is actually just debug messages to show the data is available.+pub fn finalize(cx: &CodegenCx<'_, '_>) {+    let coverage_regions = &*cx.coverage_context().coverage_regions.borrow();+    for instance in coverage_regions.keys() {+        let coverageinfo = cx.tcx.coverageinfo(instance.def_id());+        debug_assert!(coverageinfo.num_counters > 0);+        debug!(+            "Generate coverage map for: {:?}, hash: {}, num_counters: {}",+            instance, coverageinfo.hash, coverageinfo.num_counters+        );+        let function_coverage_regions = &coverage_regions[instance];+        for (index, region) in function_coverage_regions.indexed_regions() {+            match region.kind {+                CoverageKind::Counter => debug!(+                    "  Counter {}, for {}..{}",+                    index, region.coverage_span.start_byte_pos, region.coverage_span.end_byte_pos+                ),+                CoverageKind::CounterExpression(lhs, op, rhs) => debug!(+                    "  CounterExpression {} = {} {:?} {}, for {}..{}",+                    index,+                    lhs,+                    op,+                    rhs,+                    region.coverage_span.start_byte_pos,+                    region.coverage_span.end_byte_pos+                ),+            }+        }+        for unreachable in function_coverage_regions.unreachable_regions() {+            debug!(+                "  Unreachable code region: {}..{}",+                unreachable.start_byte_pos, unreachable.end_byte_pos+            );+        }+    }+}++impl CoverageInfoMethods for CodegenCx<'ll, 'tcx> {+    fn coverageinfo_finalize(&self) {+        finalize(self)+    }+}++impl CoverageInfoBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> {+    fn new_counter_region(+        &mut self,+        instance: Instance<'tcx>,+        index: u32,+        start_byte_pos: u32,+        end_byte_pos: u32,+    ) {+        debug!(+            "adding counter to coverage map: instance={:?}, index={}, byte range {}..{}",+            instance, index, start_byte_pos, end_byte_pos,+        );+        let mut coverage_regions = self.coverage_context().coverage_regions.borrow_mut();+        coverage_regions+            .entry(instance)+            .or_insert_with(|| FunctionCoverageRegions::new())

You can then do .or_default() here

richkadel

comment created time in 8 days

Pull request review commentrust-lang/rust

add spans to injected coverage counters, extract with CoverageData query

+use rustc_data_structures::fx::FxHashMap;+use std::collections::hash_map;+use std::slice;++#[derive(Copy, Clone, Debug)]+pub enum CounterOp {+    Add,+    Subtract,+}++pub enum CoverageKind {+    Counter,+    CounterExpression(u32, CounterOp, u32),+}++pub struct CoverageSpan {+    pub start_byte_pos: u32,+    pub end_byte_pos: u32,+}++pub struct CoverageRegion {+    pub kind: CoverageKind,+    pub coverage_span: CoverageSpan,+}++/// Collects all of the coverage regions associated with (a) injected counters, (b) counter+/// expressions (additions or subtraction), and (c) unreachable regions (always counted as zero),+/// for a given Function. Counters and counter expressions are indexed because they can be operands+/// in an expression.+///+/// Note, it's important to distinguish the `unreachable` region type from what LLVM's refers to as+/// a "gap region" (or "gap area"). A gap region is a code region within a counted region (either+/// counter or expression), but the line or lines in the gap region are not executable (such as+/// lines with only whitespace or comments). According to LLVM Code Coverage Mapping documentation,+/// "A count for a gap area is only used as the line execution count if there are no other regions+/// on a line."+pub struct FunctionCoverageRegions {+    indexed: FxHashMap<u32, CoverageRegion>,+    unreachable: Vec<CoverageSpan>,+}++impl FunctionCoverageRegions {+    pub fn new() -> Self {+        Self { indexed: FxHashMap::default(), unreachable: Default::default() }+    }++    pub fn new_counter(&mut self, index: u32, start_byte_pos: u32, end_byte_pos: u32) {+        self.indexed.insert(+            index,+            CoverageRegion {+                kind: CoverageKind::Counter,+                coverage_span: CoverageSpan { start_byte_pos, end_byte_pos },+            },+        );+    }++    pub fn new_counter_expression(

Nit: Similarly add_counter_expression

richkadel

comment created time in 8 days

Pull request review commentrust-lang/rust

add spans to injected coverage counters, extract with CoverageData query

+use crate::builder::Builder;+use crate::common::CodegenCx;+use log::debug;+use rustc_codegen_ssa::coverageinfo::map::*;+use rustc_codegen_ssa::traits::{CoverageInfoBuilderMethods, CoverageInfoMethods};+use rustc_data_structures::fx::FxHashMap;+use rustc_middle::ty::Instance;++use std::cell::RefCell;++/// A context object for maintaining all state needed by the coverageinfo module.+pub struct CrateCoverageContext<'tcx> {+    // Coverage region data for each instrumented function identified by DefId.+    pub(crate) coverage_regions: RefCell<FxHashMap<Instance<'tcx>, FunctionCoverageRegions>>,+}++impl<'tcx> CrateCoverageContext<'tcx> {+    pub fn new() -> Self {+        Self { coverage_regions: Default::default() }+    }+}++/// Generates and exports the Coverage Map.+// FIXME(richkadel): Actually generate and export the coverage map to LLVM.+// The current implementation is actually just debug messages to show the data is available.+pub fn finalize(cx: &CodegenCx<'_, '_>) {+    let coverage_regions = &*cx.coverage_context().coverage_regions.borrow();+    for instance in coverage_regions.keys() {+        let coverageinfo = cx.tcx.coverageinfo(instance.def_id());+        debug_assert!(coverageinfo.num_counters > 0);+        debug!(+            "Generate coverage map for: {:?}, hash: {}, num_counters: {}",+            instance, coverageinfo.hash, coverageinfo.num_counters+        );+        let function_coverage_regions = &coverage_regions[instance];+        for (index, region) in function_coverage_regions.indexed_regions() {+            match region.kind {+                CoverageKind::Counter => debug!(+                    "  Counter {}, for {}..{}",+                    index, region.coverage_span.start_byte_pos, region.coverage_span.end_byte_pos+                ),+                CoverageKind::CounterExpression(lhs, op, rhs) => debug!(+                    "  CounterExpression {} = {} {:?} {}, for {}..{}",+                    index,+                    lhs,+                    op,+                    rhs,+                    region.coverage_span.start_byte_pos,+                    region.coverage_span.end_byte_pos+                ),+            }+        }+        for unreachable in function_coverage_regions.unreachable_regions() {+            debug!(+                "  Unreachable code region: {}..{}",+                unreachable.start_byte_pos, unreachable.end_byte_pos+            );+        }+    }+}++impl CoverageInfoMethods for CodegenCx<'ll, 'tcx> {+    fn coverageinfo_finalize(&self) {+        finalize(self)+    }+}++impl CoverageInfoBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> {+    fn new_counter_region(+        &mut self,+        instance: Instance<'tcx>,+        index: u32,+        start_byte_pos: u32,+        end_byte_pos: u32,+    ) {+        debug!(+            "adding counter to coverage map: instance={:?}, index={}, byte range {}..{}",+            instance, index, start_byte_pos, end_byte_pos,+        );+        let mut coverage_regions = self.coverage_context().coverage_regions.borrow_mut();+        coverage_regions+            .entry(instance)+            .or_insert_with(|| FunctionCoverageRegions::new())+            .new_counter(index, start_byte_pos, end_byte_pos);+    }++    fn new_counter_expression_region(+        &mut self,+        instance: Instance<'tcx>,+        index: u32,+        lhs: u32,+        op: CounterOp,+        rhs: u32,+        start_byte_pos: u32,+        end_byte_pos: u32,+    ) {+        debug!(+            "adding counter expression to coverage map: instance={:?}, index={}, {} {:?} {}, byte range {}..{}",+            instance, index, lhs, op, rhs, start_byte_pos, end_byte_pos,+        );+        let mut coverage_regions = self.coverage_context().coverage_regions.borrow_mut();+        coverage_regions+            .entry(instance)+            .or_insert_with(|| FunctionCoverageRegions::new())+            .new_counter_expression(index, lhs, op, rhs, start_byte_pos, end_byte_pos);+    }++    fn new_unreachable_region(+        &mut self,+        instance: Instance<'tcx>,+        start_byte_pos: u32,+        end_byte_pos: u32,+    ) {+        debug!(+            "adding unreachable code to coverage map: instance={:?}, byte range {}..{}",+            instance, start_byte_pos, end_byte_pos,+        );+        let mut coverage_regions = self.coverage_context().coverage_regions.borrow_mut();+        coverage_regions+            .entry(instance)+            .or_insert_with(|| FunctionCoverageRegions::new())

and here

richkadel

comment created time in 8 days

Pull request review commentrust-lang/rust

add spans to injected coverage counters, extract with CoverageData query

+use rustc_data_structures::fx::FxHashMap;+use std::collections::hash_map;+use std::slice;++#[derive(Copy, Clone, Debug)]+pub enum CounterOp {+    Add,+    Subtract,+}++pub enum CoverageKind {+    Counter,+    CounterExpression(u32, CounterOp, u32),+}++pub struct CoverageSpan {+    pub start_byte_pos: u32,+    pub end_byte_pos: u32,+}++pub struct CoverageRegion {+    pub kind: CoverageKind,+    pub coverage_span: CoverageSpan,+}++/// Collects all of the coverage regions associated with (a) injected counters, (b) counter+/// expressions (additions or subtraction), and (c) unreachable regions (always counted as zero),+/// for a given Function. Counters and counter expressions are indexed because they can be operands+/// in an expression.+///+/// Note, it's important to distinguish the `unreachable` region type from what LLVM's refers to as+/// a "gap region" (or "gap area"). A gap region is a code region within a counted region (either+/// counter or expression), but the line or lines in the gap region are not executable (such as+/// lines with only whitespace or comments). According to LLVM Code Coverage Mapping documentation,+/// "A count for a gap area is only used as the line execution count if there are no other regions+/// on a line."+pub struct FunctionCoverageRegions {+    indexed: FxHashMap<u32, CoverageRegion>,+    unreachable: Vec<CoverageSpan>,+}++impl FunctionCoverageRegions {+    pub fn new() -> Self {+        Self { indexed: FxHashMap::default(), unreachable: Default::default() }+    }

You might want to just impl Default instead of adding this constructor.

richkadel

comment created time in 8 days

Pull request review commentrust-lang/rust

add spans to injected coverage counters, extract with CoverageData query

 pub struct InstrumentCoverage; /// The `query` provider for `CoverageData`, requested by `codegen_intrinsic_call()` when /// constructing the arguments for `llvm.instrprof.increment`. pub(crate) fn provide(providers: &mut Providers<'_>) {-    providers.coverage_data = |tcx, def_id| {-        let mir_body = tcx.optimized_mir(def_id);-        // FIXME(richkadel): The current implementation assumes the MIR for the given DefId-        // represents a single function. Validate and/or correct if inlining and/or monomorphization-        // invalidates these assumptions.-        let count_code_region_fn =-            tcx.require_lang_item(lang_items::CountCodeRegionFnLangItem, None);-        let mut num_counters: u32 = 0;-        // The `num_counters` argument to `llvm.instrprof.increment` is the number of injected-        // counters, with each counter having an index from `0..num_counters-1`. MIR optimization-        // may split and duplicate some BasicBlock sequences. Simply counting the calls may not-        // not work; but computing the num_counters by adding `1` to the highest index (for a given-        // instrumented function) is valid.-        for (_, data) in traversal::preorder(mir_body) {-            if let Some(terminator) = &data.terminator {-                if let TerminatorKind::Call { func: Operand::Constant(func), args, .. } =-                    &terminator.kind-                {-                    if let FnDef(called_fn_def_id, _) = func.literal.ty.kind {-                        if called_fn_def_id == count_code_region_fn {-                            if let Operand::Constant(constant) =-                                args.get(0).expect("count_code_region has at least one arg")-                            {-                                if let ConstKind::Value(ConstValue::Scalar(value)) =-                                    constant.literal.val-                                {-                                    let index = value-                                        .to_u32()-                                        .expect("count_code_region index at arg0 is u32");-                                    num_counters = std::cmp::max(num_counters, index + 1);-                                }-                            }-                        }-                    }+    providers.coverage_data = |tcx, def_id| coverage_data_from_mir(tcx, def_id);+}++fn coverage_data_from_mir<'tcx>(tcx: TyCtxt<'tcx>, mir_def_id: DefId) -> &'tcx CoverageData {+    let mir_body = tcx.optimized_mir(mir_def_id);+    // FIXME(richkadel): The current implementation assumes the MIR for the given DefId+    // represents a single function. Validate and/or correct if inlining and/or monomorphization+    // invalidates these assumptions.+    let count_code_region_fn = tcx.require_lang_item(lang_items::CountCodeRegionFnLangItem, None);++    // The `num_counters` argument to `llvm.instrprof.increment` is the number of injected+    // counters, with each counter having an index from `0..num_counters-1`. MIR optimization+    // may split and duplicate some BasicBlock sequences. Simply counting the calls may not+    // not work; but computing the num_counters by adding `1` to the highest index (for a given+    // instrumented function) is valid.+    let mut indexed_regions = vec![];+    let mut num_counters: u32 = 0;+    //for terminator in count_code_region_terminators(tcx, mir_body) {+    for terminator in traversal::preorder(mir_body)+        .map(|(_, data)| (data, count_code_region_fn))+        .filter_map(count_code_region_terminator_filter)+    {+        // FIXME(richkadel): When analyzing the MIR and identifying CodeRegions to count by LLVM+        // counter_expressions, inject (and here, filter for) an additional call, such as:+        //+        //     code_region_counter_expression(+        //         left_counter: i32, signed_right_counter: i64,+        //         start_byte_pos, end_byte_pos+        //     )+        //+        // `abs(signed_right_counter)` (perhaps there's a better name?) is the index of the counter's+        // count to be added to or subtracted from (depending on the sign) the `left_counter`+        // index.+        //+        // Then store the expressions in a different IndexVec.+        // We may also want to consider "GapRegions" (clang had them... do we need them too?)+        if let TerminatorKind::Call { args, .. } = &terminator.kind {+            let (index, start_byte_pos, end_byte_pos) = count_code_region_args(&args);+            indexed_regions.push((index, CoverageRegion { start_byte_pos, end_byte_pos }));+            num_counters = std::cmp::max(num_counters, index + 1);+        }+    }+    let hash = if num_counters > 0 { hash_mir_source(tcx, mir_def_id) } else { 0 };+    let mut coverage_regions = IndexVec::<u32, CoverageRegion>::from_elem_n(+        CoverageRegion { start_byte_pos: 0, end_byte_pos: 0 },+        indexed_regions.len(),+    );+    for (index, region) in indexed_regions {+        coverage_regions[index] = region;+    }

Thank you!

richkadel

comment created time in 8 days

Pull request review commentrust-lang/rust

Const prop: erase all block-only locals at the end of every block

 impl<'tcx> MirPass<'tcx> for ConstProp { struct ConstPropMachine<'mir, 'tcx> {     /// The virtual call stack.     stack: Vec<Frame<'mir, 'tcx, (), ()>>,+    /// `OnlyInsideOwnBlock` locals that were written in the current block get erased at the end.+    written_only_inside_own_block_locals: FxHashSet<Local>,

I was going to suggest making this a bitset but I guess that won't work with the std::mem::take since it doesn't impl Default.

oli-obk

comment created time in 9 days

push eventwesleywiser/team

Wesley Wiser

commit sha 1577a6511198492ff28c911eeb4dde5025f70b16

Create wg-incr-comp.toml

view details

push time in 9 days

PR opened rust-lang/team

Create wg-incr-comp

cc @pnkfelix @spastorino

+15 -0

0 comment

1 changed file

pr created time in 9 days

push eventwesleywiser/team

Wesley Wiser

commit sha 9c5fe53c83129c5b1cb7b969eee185933e0da684

Create wg-incr-comp.toml

view details

push time in 9 days

fork wesleywiser/team

Rust teams structure

fork in 9 days

pull request commentrust-lang/rust

add spans to injected coverage counters, extract with CoverageData query

Thoughts?

That seems reasonable to me as well so I would be interested to see a version of the code that uses that approach!

richkadel

comment created time in 9 days

Pull request review commentrust-lang/rust

add spans to injected coverage counters, extract with CoverageData query

 pub struct InstrumentCoverage; /// The `query` provider for `CoverageData`, requested by `codegen_intrinsic_call()` when /// constructing the arguments for `llvm.instrprof.increment`. pub(crate) fn provide(providers: &mut Providers<'_>) {-    providers.coverage_data = |tcx, def_id| {-        let mir_body = tcx.optimized_mir(def_id);-        // FIXME(richkadel): The current implementation assumes the MIR for the given DefId-        // represents a single function. Validate and/or correct if inlining and/or monomorphization-        // invalidates these assumptions.-        let count_code_region_fn =-            tcx.require_lang_item(lang_items::CountCodeRegionFnLangItem, None);-        let mut num_counters: u32 = 0;-        // The `num_counters` argument to `llvm.instrprof.increment` is the number of injected-        // counters, with each counter having an index from `0..num_counters-1`. MIR optimization-        // may split and duplicate some BasicBlock sequences. Simply counting the calls may not-        // not work; but computing the num_counters by adding `1` to the highest index (for a given-        // instrumented function) is valid.-        for (_, data) in traversal::preorder(mir_body) {-            if let Some(terminator) = &data.terminator {-                if let TerminatorKind::Call { func: Operand::Constant(func), args, .. } =-                    &terminator.kind-                {-                    if let FnDef(called_fn_def_id, _) = func.literal.ty.kind {-                        if called_fn_def_id == count_code_region_fn {-                            if let Operand::Constant(constant) =-                                args.get(0).expect("count_code_region has at least one arg")-                            {-                                if let ConstKind::Value(ConstValue::Scalar(value)) =-                                    constant.literal.val-                                {-                                    let index = value-                                        .to_u32()-                                        .expect("count_code_region index at arg0 is u32");-                                    num_counters = std::cmp::max(num_counters, index + 1);-                                }-                            }-                        }-                    }+    providers.coverage_data = |tcx, def_id| coverage_data_from_mir(tcx, def_id);+}++fn coverage_data_from_mir<'tcx>(tcx: TyCtxt<'tcx>, mir_def_id: DefId) -> &'tcx CoverageData {+    let mir_body = tcx.optimized_mir(mir_def_id);+    // FIXME(richkadel): The current implementation assumes the MIR for the given DefId+    // represents a single function. Validate and/or correct if inlining and/or monomorphization+    // invalidates these assumptions.+    let count_code_region_fn = tcx.require_lang_item(lang_items::CountCodeRegionFnLangItem, None);++    // The `num_counters` argument to `llvm.instrprof.increment` is the number of injected+    // counters, with each counter having an index from `0..num_counters-1`. MIR optimization+    // may split and duplicate some BasicBlock sequences. Simply counting the calls may not+    // not work; but computing the num_counters by adding `1` to the highest index (for a given+    // instrumented function) is valid.+    let mut indexed_regions = vec![];+    let mut num_counters: u32 = 0;+    //for terminator in count_code_region_terminators(tcx, mir_body) {+    for terminator in traversal::preorder(mir_body)+        .map(|(_, data)| (data, count_code_region_fn))+        .filter_map(count_code_region_terminator_filter)+    {+        // FIXME(richkadel): When analyzing the MIR and identifying CodeRegions to count by LLVM+        // counter_expressions, inject (and here, filter for) an additional call, such as:+        //+        //     code_region_counter_expression(+        //         left_counter: i32, signed_right_counter: i64,+        //         start_byte_pos, end_byte_pos+        //     )+        //+        // `abs(signed_right_counter)` (perhaps there's a better name?) is the index of the counter's+        // count to be added to or subtracted from (depending on the sign) the `left_counter`+        // index.+        //+        // Then store the expressions in a different IndexVec.+        // We may also want to consider "GapRegions" (clang had them... do we need them too?)+        if let TerminatorKind::Call { args, .. } = &terminator.kind {+            let (index, start_byte_pos, end_byte_pos) = count_code_region_args(&args);+            indexed_regions.push((index, CoverageRegion { start_byte_pos, end_byte_pos }));+            num_counters = std::cmp::max(num_counters, index + 1);+        }+    }+    let hash = if num_counters > 0 { hash_mir_source(tcx, mir_def_id) } else { 0 };+    let mut coverage_regions = IndexVec::<u32, CoverageRegion>::from_elem_n(+        CoverageRegion { start_byte_pos: 0, end_byte_pos: 0 },+        indexed_regions.len(),+    );+    for (index, region) in indexed_regions {+        coverage_regions[index] = region;+    }

I believe this would work the same:

    let coverage_regions = IndexVec::from_fn_n(
        |index| coverage_region[index as usize],
        indexed_regions.len(),
    );
richkadel

comment created time in 9 days

Pull request review commentrust-lang/rust

first stage of implementing LLVM code coverage

 impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {                 );                 self.copy_op(self.operand_index(args[0], index)?, dest)?;             }+            // FIXME(#73156): Handle source code coverage in const eval+            sym::count_code_region => (),

Sorry about that @RalfJung! That was my fault; I didn't realize we should be pinging that group.

Do you think we still need to get the lang team involved? This intrinsic is used by an unstable -Z compiler flag which generates code coverage data using LLVM features. The compiler team already signed off on this approach via an MCP.

richkadel

comment created time in 9 days

pull request commentrust-lang/rust

fix typo in self-profile.md

Thanks @atetubou!

atetubou

comment created time in 9 days

pull request commentrust-lang/rust

Const prop: erase all block-only locals at the end of every block

Looks like we're ready for another round of benchmarks

@bors try @rust-timer queue

oli-obk

comment created time in 9 days

pull request commentrust-lang/rust

Const prop: erase all block-only locals at the end of every block

@bors try @rust-timer queue

oli-obk

comment created time in 9 days

Pull request review commentrust-lang/rust

Const prop: erase all block-only locals at the end of every block

 impl<'mir, 'tcx> MutVisitor<'tcx> for ConstPropagator<'mir, 'tcx> {             }         }         // We remove all Locals which are restricted in propagation to their containing blocks.-        for local in self.locals_of_current_block.iter() {-            Self::remove_const(&mut self.ecx, local);+        for (local, mode) in self.can_const_prop.iter_enumerated() {+            if let ConstPropMode::OnlyInsideOwnBlock = mode {

Good idea @felix91gr! I've pushed a change to do that so we can try running the benchmarks again.

oli-obk

comment created time in 9 days

push eventoli-obk/rust

Wesley Wiser

commit sha 94b17b74fe809430c5d34f0859a16de474272d8d

Try using a BitSet instead of iterating locals every time

view details

push time in 9 days

pull request commentrust-lang/rust

Document some invariants correctly/more

@bors r+ rollup

oli-obk

comment created time in 10 days

Pull request review commentrust-lang/rust

move Deaggregate pass to post_borrowck_cleanup

 impl<'mir, 'tcx> MutVisitor<'tcx> for ConstPropagator<'mir, 'tcx> {             }         } else {             match statement.kind {+                StatementKind::SetDiscriminant { ref place, .. } => {+                    match self.can_const_prop[place.local] {+                        ConstPropMode::FullConstProp | ConstPropMode::OnlyInsideOwnBlock => {+                            if self.use_ecx(|this| this.ecx.statement(statement)).is_some() {+                                trace!(+                                    "propped discriminant into {:?}",+                                    place,+                                );+                                trace!(+                                    "propped into local {:?} which is restricted to its block. \+                                    Will remove it from const-prop after block is finished.",+                                    place.local+                                );+                                self.locals_of_current_block.insert(place.local);

Right but if this local is ConstPropMode::FullConstProp, then we don't want to schedule it for removal at the end of this block. But I guess this doesn't really matter because #73757 removes locals_of_current_block anyway.

oli-obk

comment created time in 10 days

pull request commentrust-lang/rust

Const prop: erase all block-only locals at the end of every block

r=me if the perf looks ok

oli-obk

comment created time in 10 days

Pull request review commentrust-lang/rust

move Deaggregate pass to post_borrowck_cleanup

 impl<'mir, 'tcx> MutVisitor<'tcx> for ConstPropagator<'mir, 'tcx> {             }         } else {             match statement.kind {+                StatementKind::SetDiscriminant { ref place, .. } => {+                    match self.can_const_prop[place.local] {+                        ConstPropMode::FullConstProp | ConstPropMode::OnlyInsideOwnBlock => {+                            if self.use_ecx(|this| this.ecx.statement(statement)).is_some() {+                                trace!(+                                    "propped discriminant into {:?}",+                                    place,+                                );+                                trace!(+                                    "propped into local {:?} which is restricted to its block. \+                                    Will remove it from const-prop after block is finished.",+                                    place.local+                                );+                                self.locals_of_current_block.insert(place.local);

Don't we only want this for ConstPropMode::OnlyInsideOwnBlock?

oli-obk

comment created time in 10 days

pull request commentrust-lang/rust

Const prop: erase all block-only locals at the end of every block

Oh, I see. It only triggers with the deaggregator move up. That's fine then.

oli-obk

comment created time in 10 days

pull request commentrust-lang/rust

Const prop: erase all block-only locals at the end of every block

Can we add a regression test for this?

oli-obk

comment created time in 10 days

pull request commentrust-lang/rust

add spans to injected coverage counters, extract with CoverageData query

Sorry, this notification fell off my radar. I will schedule some time tonight and tomorrow to review this.

richkadel

comment created time in 11 days

issue commentrust-lang/measureme

`summarize` shouldn't show columns that don't apply to the profile

This was also closed by #116.

wesleywiser

comment created time in 12 days

issue closedrust-lang/measureme

`summarize` shouldn't show columns that don't apply to the profile

For example, most people do not enable query cache hit events or use a parallel compiler so the "Cache Hits" and "Blocked time" columns never have values. We should hide those columns in this case.

closed time in 12 days

wesleywiser

pull request commentrust-lang/rust

Add procedure for prioritization notifications on Zulip

@bors r+

spastorino

comment created time in 12 days

issue closedrust-lang/measureme

Possible integration of stabilizer

Hi, I came across a very interesting talk by Prof Emery Berger on how the placement of functions in assembly and even the choice of memory layout might influence the time measurements. I have been benchmarking some parallel sorts using criterion as of now. I do see up to 50-70ms difference (on a scale of 300ms) in the wall-time of the exact same code when I have different set of benchmarking functions in the same group with it.

I would be very interested in a time-measurement crate that would randomize the instructions layout and the memory layout of objects. Here is a link to the project that does this for C/C++ (as mentioned in the talk) https://github.com/ccurtsinger/stabilizer.

Also, some quick thoughts on possible implementations would be helpful.

closed time in 12 days

smr97

issue commentrust-lang/measureme

Possible integration of stabilizer

It seems like a cool idea @smr97! I think this is pretty far outside the scope of this project though which is focused primary on source-based tracing annotations.

smr97

comment created time in 12 days

issue commentrust-lang/measureme

summarize doesn't work if you specify your own event kinds

Closed by #116.

jasonwilliams

comment created time in 12 days

issue closedrust-lang/measureme

summarize doesn't work if you specify your own event kinds

In Boa we are working with measureme to measure performance, our main use case is the Chrome Profiler, but we were interested in using summarize also.

The solution seems to be to use the generic eventKind but that would mean having to remove our own kinds and on Chrome it would all be one colour, this would not be ideal for us.

Our output when using:

Ignoring event with unknown event kind `value`
Unexpectedly enountered event `Event { event_kind: "value", label: "set_field", additional_data: [], timestamp: Interval { start: SystemTime { intervals: 132353512591167719 }, end: SystemTime { intervals: 132353512591168006 } }, thread_id: 1 }`, while top of stack was `Event { event_kind: "init", label: "make_builtin_fn: toString", additional_data: [], timestamp: Interval { start: SystemTime { intervals: 132353512591167595 }, end: SystemTime { intervals: 132353512591168321 } }, thread_id: 1 }`. Ignoring.
Ignoring event with unknown event kind `value`
Unexpectedly enountered event `Event { event_kind: "object", label: "Object::set", additional_data: [], timestamp: Interval { start: SystemTime { intervals: 132353512591167802 }, end: SystemTime { intervals: 132353512591167977 } }, thread_id: 1 }`, while top of stack was `Event { event_kind: "value", label: "set_field", additional_data: [], timestamp: Interval { start: SystemTime { intervals: 132353512591167719 }, end: SystemTime { intervals: 132353512591168006 } }, thread_id: 1 }`. Ignoring.
Ignoring event with unknown event kind `object`
Unexpectedly enountered event `Event { event_kind: "object", label: "Object::get_internal_slot", additional_data: [], timestamp: Interval { start: SystemTime { intervals: 132353512591167920 }, end: SystemTime { intervals: 132353512591167934 } }, thread_id: 1 }`, while top of stack was `Event { event_kind: "object", label: "Object::set", additional_data: [], timestamp: Interval { start: SystemTime { intervals: 132353512591167802 }, end: SystemTime { intervals: 132353512591167977 } }, thread_id: 1 }`. Ignoring.
Ignoring event with unknown event kind `object`
Unexpectedly enountered event `Event { event_kind: "object", label: "Object::get_own_property", additional_data: [], timestamp: Interval { start: SystemTime { intervals: 132353512591167897 }, end: SystemTime { intervals: 132353512591167908 } }, thread_id: 1 }`, while top of stack was `Event { event_kind: "object", label: "Object::set", additional_data: [], timestamp: Interval { start: SystemTime { intervals: 132353512591167802 }, end: SystemTime { intervals: 132353512591167977 } }, thread_id: 1 }`. Ignoring.
Ignoring event with unknown event kind `object`
Unexpectedly enountered event `Event { event_kind: "value", label: "From<String>", additional_data: [], timestamp: Interval { start: SystemTime { intervals: 132353512591167881 }

Issue: https://github.com/boa-dev/boa/pull/317

closed time in 12 days

jasonwilliams

pull request commentrust-lang/measureme

Make summarize useful to data producers other than rustc

Oh, good call. Thanks @andjo403!

wesleywiser

comment created time in 12 days

Pull request review commentrust-lang/rust

Use exhaustive match in const_prop.rs

 impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {                  return None;             }+            Rvalue::ThreadLocalRef(def_id) => {+                trace!("skipping ThreadLocalRef({:?})", def_id); -            _ => {}+                return None;

So I think this used to be covered by the Ref(..) case before we split thread locals into their own Rvalue. I could be wrong about that.

wesleywiser

comment created time in 12 days

PR opened rust-lang/rust

Use exhaustive match in const_prop.rs

Addresses a comment left by @RalfJung on #73613

r? @RalfJung

+13 -1

0 comment

1 changed file

pr created time in 12 days

create barnchwesleywiser/rust

branch : const_prop_exhaustive_match

created branch time in 12 days

delete branch wesleywiser/measureme

delete branch : upgrade

delete time in 12 days

push eventrust-lang/measureme

Wesley Wiser

commit sha 7cf445054b2e7ea296fae5e743d02cf54ef1ae94

Upgrade to structopt 0.3 This removes duplicate crates from the build

view details

Wesley Wiser

commit sha af394d89ab7c95325ad0992ff2e144a19e72c0bf

Merge pull request #117 from wesleywiser/upgrade Upgrade to structopt 0.3

view details

push time in 12 days

PR merged rust-lang/measureme

Upgrade to structopt 0.3

This removes duplicate crates from the build

+5 -5

0 comment

5 changed files

wesleywiser

pr closed time in 12 days

PR opened rust-lang/measureme

Upgrade to structopt 0.3

This removes duplicate crates from the build

+5 -5

0 comment

5 changed files

pr created time in 12 days

create barnchwesleywiser/measureme

branch : upgrade

created branch time in 12 days

delete branch wesleywiser/measureme

delete branch : two_small_features

delete time in 12 days

push eventrust-lang/measureme

Wesley Wiser

commit sha add9de4f19fc15c8610aac531ab87b6b08ec0905

Allow summarize to be used with data sources other than rustc

view details

Wesley Wiser

commit sha c936e893c6aa58f30f44be1c3b3aceee248d7fad

Hide optional columns without values

view details

Wesley Wiser

commit sha 263931dde47ed47a6a9e6ee2626475f6c472574f

Merge pull request #116 from wesleywiser/two_small_features Make summarize useful to data producers other than rustc

view details

push time in 12 days

PR merged rust-lang/measureme

Make summarize useful to data producers other than rustc

The boa project is using measureme to trace their own performance. This lets them use the summarize tool which was previously only useful to rustc because it cared about very specific event kinds.

+79 -32

0 comment

2 changed files

wesleywiser

pr closed time in 12 days

PR opened rust-lang/measureme

Make summarize useful to data producers other than rustc

The boa project is using measureme to trace their own performance. This lets them use the summarize tool which was previously only useful to rustc because it cared about very specific event kinds.

+79 -32

0 comment

2 changed files

pr created time in 12 days

create barnchwesleywiser/measureme

branch : two_small_features

created branch time in 12 days

pull request commentrust-lang/rust

The const propagator cannot trace references.

@bors retry

oli-obk

comment created time in 13 days

Pull request review commentrust-lang/rust

Disable the `SimplifyArmIdentity` pass

 fn optimization_applies<'tcx>( }  impl<'tcx> MirPass<'tcx> for SimplifyArmIdentity {-    fn run_pass(&self, _: TyCtxt<'tcx>, source: MirSource<'tcx>, body: &mut Body<'tcx>) {+    fn run_pass(&self, tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, body: &mut Body<'tcx>) {+        if tcx.sess.opts.debugging_opts.mir_opt_level < 2 {

@RalfJung I opened a related MCP: https://github.com/rust-lang/compiler-team/issues/319

If you have thoughts about it, please leave a comment there. Thanks!

wesleywiser

comment created time in 13 days

issue openedrust-lang/compiler-team

-Zmir-opt-level Reform

-Zmir-opt-level Reform

Summary

Change the -Zmir-opt-level unstable flag to have the following possible values and associated behaviors:

  • 0 - MIR optimizations are disabled.
  • 1 - Some MIR optimizations are enabled.
    • This would be the default if -Zmir-opt-level is not specified.
    • Optimizations ran at this level would be selected based on their ability to improve compilation performance.
    • Optimizations ran should not hurt the debug-ability of programs.
  • 2 - Many (most?) MIR optimizations are enabled.
    • Optimizations ran at this level would include any passes that improve or have no significant adverse effect on compilation performance.
    • Optimizations ran would not be required to maintain the debug-ability of programs.
  • 3 - All sound MIR optimizations are enabled.
    • Optimizations ran at this level may have negative impacts on compilation performance provided there is some run-time benefit.
    • As with mir-opt-level=2, optimizations would not be required to maintain the debug-ability of programs.

In addition, a new permanently unstable compiler flag is added: -Zunsound-mir-optimizations. MIR optimizations with known unsound behavior are gated under this flag which allows them to still be maintained in-tree and participate in the mir-opt testing framework.

Rationale

Currently, -Zmir-opt-level is kind of a mess.

By changing -Zmir-opt-level so that we do not run unsound/broken MIR optimizations, we can eventually allow --release builds to use mir-opt-level=2 and even potentially stablize the flag, allowing stable users to opt-in to mir-opt-level=3 for cases where run-time performance is the highest priority. This MCP does not propose doing that at this time, but notes that it would be reasonable to consider those possibilities in the future if this MCP were accepted.

Mentors or Reviewers

@oli-obk has volunteered to review.

Process

The main points of the Major Change Process is as follows:

  • [x] File an issue describing the proposal.
  • [ ] A compiler team member or contributor who is knowledgeable in the area can second by writing @rustbot second.
    • Finding a "second" suffices for internal changes. If however you are proposing a new public-facing feature, such as a -C flag, then full team check-off is required.
    • Compiler team members can initiate a check-off via @rfcbot fcp merge on either the MCP or the PR.
  • [ ] Once an MCP is seconded, the Final Comment Period begins. If no objections are raised after 10 days, the MCP is considered approved.

You can read more about Major Change Proposals on forge.

Comments

This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.

created time in 13 days

Pull request review commentrust-lang/rust

code coverage foundation for hash and num_counters

 impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {                 self.call(llfn, &[], None)             }             "count_code_region" => {-                if let ty::InstanceDef::Item(fn_def_id) = caller_instance.def {-                    let caller_fn_path = tcx.def_path_str(fn_def_id);-                    debug!(-                        "count_code_region to llvm.instrprof.increment(fn_name={})",-                        caller_fn_path-                    );--                    // FIXME(richkadel): (1) Replace raw function name with mangled function name;-                    // (2) Replace hardcoded `1234` in `hash` with a computed hash (as discussed in)-                    // the MCP (compiler-team/issues/278); and replace the hardcoded `1` for-                    // `num_counters` with the actual number of counters per function (when the-                    // changes are made to inject more than one counter per function).-                    let (fn_name, _len_val) = self.const_str(Symbol::intern(&caller_fn_path));-                    let index = args[0].immediate();-                    let hash = self.const_u64(1234);-                    let num_counters = self.const_u32(1);-                    self.instrprof_increment(fn_name, hash, num_counters, index)-                } else {-                    bug!("intrinsic count_code_region: no src.instance");-                }+                let coverage_data = fx.mir.coverage_data.as_ref().unwrap();

This looks great to me. Thank you!

richkadel

comment created time in 13 days

Pull request review commentrust-lang/rust

code coverage foundation for hash and num_counters

 rustc_queries! {             cache_on_disk_if { key.is_local() }         } +        query coverage_data(key: DefId) -> Option<mir::CoverageData> {

When you make this query operate by walking the Body MIR, I think it would be reasonable to change the return type to just mir::CoverageData. The query should be able to operate on any Body even ones that aren't instrumented since it will just return zero num_counters.

richkadel

comment created time in 14 days

Pull request review commentrust-lang/rust

code coverage foundation for hash and num_counters

 impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {                 self.call(llfn, &[], None)             }             "count_code_region" => {-                if let ty::InstanceDef::Item(fn_def_id) = caller_instance.def {-                    let caller_fn_path = tcx.def_path_str(fn_def_id);-                    debug!(-                        "count_code_region to llvm.instrprof.increment(fn_name={})",-                        caller_fn_path-                    );--                    // FIXME(richkadel): (1) Replace raw function name with mangled function name;-                    // (2) Replace hardcoded `1234` in `hash` with a computed hash (as discussed in)-                    // the MCP (compiler-team/issues/278); and replace the hardcoded `1` for-                    // `num_counters` with the actual number of counters per function (when the-                    // changes are made to inject more than one counter per function).-                    let (fn_name, _len_val) = self.const_str(Symbol::intern(&caller_fn_path));-                    let index = args[0].immediate();-                    let hash = self.const_u64(1234);-                    let num_counters = self.const_u32(1);-                    self.instrprof_increment(fn_name, hash, num_counters, index)-                } else {-                    bug!("intrinsic count_code_region: no src.instance");-                }+                let coverage_data = fx.mir.coverage_data.as_ref().unwrap();

Thanks for being flexible about this @richkadel! I talked a bit about this with @oli-obk and we think for now not storing the CoverageData in the Body and instead re-walking the MIR is the better architecture. If we discover that causes performance issues, we'd certainly be open to a different approach to improve performance but at this time, we don't think there will be much of a performance hit and it integrated better with the rest of the compiler.

richkadel

comment created time in 14 days

Pull request review commentrust-lang/rust

code coverage foundation for hash and num_counters

 impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {                 self.call(llfn, &[], None)             }             "count_code_region" => {-                if let ty::InstanceDef::Item(fn_def_id) = caller_instance.def {-                    let caller_fn_path = tcx.def_path_str(fn_def_id);-                    debug!(-                        "count_code_region to llvm.instrprof.increment(fn_name={})",-                        caller_fn_path-                    );--                    // FIXME(richkadel): (1) Replace raw function name with mangled function name;-                    // (2) Replace hardcoded `1234` in `hash` with a computed hash (as discussed in)-                    // the MCP (compiler-team/issues/278); and replace the hardcoded `1` for-                    // `num_counters` with the actual number of counters per function (when the-                    // changes are made to inject more than one counter per function).-                    let (fn_name, _len_val) = self.const_str(Symbol::intern(&caller_fn_path));-                    let index = args[0].immediate();-                    let hash = self.const_u64(1234);-                    let num_counters = self.const_u32(1);-                    self.instrprof_increment(fn_name, hash, num_counters, index)-                } else {-                    bug!("intrinsic count_code_region: no src.instance");-                }+                let coverage_data = fx.mir.coverage_data.as_ref().unwrap();

So, what I was envisioning was a two-step approach where

  • the InstrumentCoverage MIR pass would only inject counters and nothing else

  • the coverage_data query would get the MIR, count how many counters are in the MIR and hash the HIR body

The result of the coverage_data query would then be automatically persisted for you in the compiler session context. If you ever need that data cross-crate in the future, this would also set you up to be able to do that quite easily.

richkadel

comment created time in 14 days

issue commentrust-lang/rust

ConstProp miscompilation around references

Why is this regression-from-stable-to-beta when the offending PR only merged last night?

RalfJung

comment created time in 14 days

pull request commentrust-lang/rust

The const propagator cannot trace references.

Now the 32-bit MIR tests need to be blessed. r=me with that.

oli-obk

comment created time in 14 days

pull request commentrust-lang/rust

The const propagator cannot trace references.

Looks like ui tests just need to be blessed.

oli-obk

comment created time in 14 days

Pull request review commentrust-lang/rust

The const propagator cannot trace references.

+// run-pass

There is a mir folder https://github.com/rust-lang/rust/tree/master/src/test/ui/mir

oli-obk

comment created time in 14 days

more