about summary refs log tree commit diff
path: root/src/libcore/intrinsics.rs
AgeCommit message (Collapse)AuthorLines
2020-07-27mv std libs to library/mark-2284/+0
2020-07-23replace miri_start_panic intrinsic by 'extern fn'Ralf Jung-8/+0
2020-07-23Rollup merge of #74141 - euclio:typos, r=steveklabnikManish Goregaokar-4/+4
libstd/libcore: fix various typos
2020-07-19Auto merge of #74091 - richkadel:llvm-coverage-map-gen-4, r=tmandrybors-1/+11
Generating the coverage map @tmandry @wesleywiser rustc now generates the coverage map and can support (limited) coverage report generation, at the function level. Example commands to generate a coverage report: ```shell $ BUILD=$HOME/rust/build/x86_64-unknown-linux-gnu $ $BUILD/stage1/bin/rustc -Zinstrument-coverage \ $HOME/rust/src/test/run-make-fulldeps/instrument-coverage/main.rs $ LLVM_PROFILE_FILE="main.profraw" ./main called $ $BUILD/llvm/bin/llvm-profdata merge -sparse main.profraw -o main.profdata $ $BUILD/llvm/bin/llvm-cov show --instr-profile=main.profdata main ``` ![rust coverage report only 20200706](https://user-images.githubusercontent.com/3827298/86697299-1cbe8f80-bfc3-11ea-8955-451b48626991.png) r? @wesleywiser Rust compiler MCP rust-lang/compiler-team#278 Relevant issue: #34701 - Implement support for LLVMs code coverage instrumentation
2020-07-17Make unreachable_unchecked a const fnNazım Can Altınova-0/+1
2020-07-17Generating the coverage mapRich Kadel-1/+11
rustc now generates the coverage map and can support (limited) coverage report generation, at the function level. Example: $ BUILD=$HOME/rust/build/x86_64-unknown-linux-gnu $ $BUILD/stage1/bin/rustc -Zinstrument-coverage \ $HOME/rust/src/test/run-make-fulldeps/instrument-coverage/main.rs $ LLVM_PROFILE_FILE="main.profraw" ./main called $ $BUILD/llvm/bin/llvm-profdata merge -sparse main.profraw -o main.profdata $ $BUILD/llvm/bin/llvm-cov show --instr-profile=main.profdata main 1| 1|pub fn will_be_called() { 2| 1| println!("called"); 3| 1|} 4| | 5| 0|pub fn will_not_be_called() { 6| 0| println!("should not have been called"); 7| 0|} 8| | 9| 1|fn main() { 10| 1| let less = 1; 11| 1| let more = 100; 12| 1| 13| 1| if less < more { 14| 1| will_be_called(); 15| 1| } else { 16| 1| will_not_be_called(); 17| 1| } 18| 1|}
2020-07-17Auto merge of #74395 - Mark-Simulacrum:stage0-next, r=pietroalbinibors-7/+0
Bump version to 1.47 This also bumps to a more recent rustfmt version, just to keep us relatively up to date (though almost nothing has changed in rustfmt we use beyond bumps to the parser infra). No formatting changes as a result of this. r? @pietroalbini
2020-07-16apply bootstrap cfgsMark Rousskov-7/+0
2020-07-16Fix typo in std::mem::transmute documentationColoredCarrot-1/+1
u32::from_ge_bytes method does not exist; replace with u32::from_be_bytes
2020-07-11Stabilize `transmute` in constants and statics but not const fnOliver Scherer-1/+3
2020-07-09libstd/libcore: fix various typosAndy Russell-4/+4
2020-07-05variant_count: avoid incorrect dummy implementationRalf Jung-6/+0
2020-07-02Rollup merge of #73684 - richkadel:llvm-coverage-map-gen-2, r=wesleywiserManish Goregaokar-1/+34
add spans to injected coverage counters, extract with CoverageData query This is the next iteration on the Rust Coverage implementation, and follows PR #73488 @tmandry @wesleywiser I came up with an approach for coverage spans, pushing them through the Call terminator as additional args so they can be extracted by the CoverageData query. I'm using an IndexVec to store them in CoverageData such that there can be only one per index (even if parts of the MIR get duplicated during optimization). If this approach works for you, I can quickly expand on this to build a separate IndexVec for counter expressions, using a separate call that will be ignored during code generation, but from which I can extract the counter expression values. Let me know your thoughts. Thanks! r? @tmandry Rust compiler MCP rust-lang/compiler-team#278 Relevant issue: #34701 - Implement support for LLVMs code coverage instrumentation
2020-07-02Rollup merge of #73622 - LeSeulArtichaut:unsafe-libcore, r=nikomatsakisManish Goregaokar-3/+10
Deny unsafe ops in unsafe fns in libcore After `liballoc`, It's time for `libcore` :D I planned to do this bit by bit to avoid having a big chunk of diffs, so to make reviews easier, and to make the unsafe blocks narrower and take the time to document them properly. r? @nikomatsakis cc @RalfJung
2020-07-01Rollup merge of #73778 - nbdd0121:const_likely, r=oli-obkManish Goregaokar-0/+2
Make `likely` and `unlikely` const, gated by feature `const_unlikely` This PR also contains a fix to allow `#[allow_internal_unstable]` to work properly with `#[rustc_const_unstable]`. cc @RalfJung @nagisa r? @oli-obk
2020-06-30Deny unsafe ops in unsafe fns, part 6LeSeulArtichaut-1/+0
And final part!!!
2020-06-30Deny unsafe ops in unsafe fns, part 1LeSeulArtichaut-3/+11
2020-06-29add spans to injected coverage countersRich Kadel-1/+34
added regions with counter expressions and counters. Added codegen_llvm/coverageinfo mod for upcoming coverage map Move coverage region collection to CodegenCx finalization Moved from `query coverageinfo` (renamed from `query coverage_data`), as discussed in the PR at: https://github.com/rust-lang/rust/pull/73684#issuecomment-649882503 Address merge conflict in MIR instrument_coverage test The MIR test output format changed for int types. moved debug messages out of block.rs This makes the block.rs calls to add coverage mapping data to the CodegenCx much more concise and readable. move coverage intrinsic handling into llvm impl I realized that having half of the coverage intrinsic handling in `rustc_codegen_ssa` and half in `rustc_codegen_llvm` meant that any non-llvm backend would be bound to the same decisions about how the coverage-related MIR terminators should be handled. To fix this, I moved the non-codegen portion of coverage intrinsic handling into its own trait, and implemented it in `rustc_codegen_llvm` alongside `codegen_intrinsic_call`. I also added the (required?) stubs for the new intrinsics to `IntrepretCx::emulate_intrinsic()`, to ensure calls to this function do not fail if called with these new but known intrinsics. address PR Feedback on 28 June 2020 2:48pm PDT
2020-06-26Make `likely` and `unlikely` constGary Guo-0/+2
They are gated by internal feature gate const_likely
2020-06-25Rollup merge of #73418 - doctorn:variants-intrinsic, r=kennytmManish Goregaokar-0/+15
Add unstable `core::mem::variant_count` intrinsic Adds a new `const fn` intrinsic which can be used to determine the number of variants in an `enum`. I've shown this to a couple of people and they invariably ask 'why on earth?', but there's actually a very neat use case: At the moment, if you want to create an opaque array type that's indexed by an `enum` with one element for each variant, you either have to hard-code the number of variants, add a `LENGTH` variant or use a `Vec`, none of which are suitable in general (number of variants could change; pattern matching `LENGTH` becomes frustrating; might not have `alloc`). By including this intrinsic, it becomes possible to write the following: ```rust #[derive(Copy, Clone)] enum OpaqueIndex { A = 0, B, C, } struct OpaqueVec<T>(Box<[T; std::mem::num_variants::<OpaqueIndex>()]>); impl<T> std::ops::Index<OpaqueIndex> for OpaqueVec<T> { type Output = T; fn index(&self, idx: OpaqueIndex) -> &Self::Output { &self.0[idx as usize] } } ``` (We even have a use cases for this in `rustc` and I plan to use it to re-implement the lang-items table.)
2020-06-24Implement intrinsicNathan Corbyn-0/+15
2020-06-23Rollup merge of #73614 - lcnr:patch-4, r=Dylan-DPCManish Goregaokar-1/+1
fix `intrinsics::needs_drop` docs
2020-06-22fix `intrinsics::needs_drop` docsBastian Kauschke-1/+1
2020-06-20Satisfy tidyOliver Scherer-1/+1
2020-06-19Tidy got confused on `rustc_const_unstable` `issue`sOliver Scherer-4/+4
2020-06-19Add fuzzy pointer comparison intrinsicsOliver Scherer-0/+10
2020-06-19Rollup merge of #73054 - RalfJung:dont-panic, r=Mark-SimulacrumRalf Jung-5/+12
memory access sanity checks: abort instead of panic Suggested by @Mark-Simulacrum, this should help reduce the performance impact of these checks.
2020-06-17Update src/libcore/intrinsics.rsRich Kadel-1/+1
Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com>
2020-06-16memory access sanity checks: abort instead of panicRalf Jung-5/+12
2020-06-15Update src/libcore/intrinsics.rsRich Kadel-1/+1
Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com>
2020-06-15Add case for count_code_region() extern lang_itemRich Kadel-15/+6
As suggested in PR feedback: https://github.com/rust-lang/rust/pull/73011#discussion_r435728923 This allows count_code_region() to be handled like a normal intrinsic so the InstanceDef::InjectedCode variant is no longer needed.
2020-06-15removed experiments for cleaner github PRRich Kadel-8/+9
2020-06-15explained lang_item function body (count_code_region)Rich Kadel-0/+6
2020-06-15[WIP] injects llvm intrinsic instrprof.increment for coverage reportsRich Kadel-0/+9
This initial version only injects counters at the top of each function. Rust Coverage will require injecting additional counters at each conditional code branch.
2020-06-03Bump to 1.46Mark Rousskov-5/+0
2020-05-25core: Make pointer offset methods "const fn"Joe Richey-0/+2
Signed-off-by: Joe Richey <joerichey@google.com>
2020-05-19update libcore, add `discriminant_kind` lang-itemBastian Kauschke-0/+6
2020-05-18Rollup merge of #72143 - rust-lang:steveklabnik-must-use, r=sfacklerRalf Jung-0/+2
make offset must_use https://djugei.github.io/bad-at-unsafe/ describes an error a user had when trying to use offset: > At first I just assumed that the .add() and .offset() methods on pointers would mutate the pointer. They do not. Instead they return a new pointer, which gets dropped silently if you don't use it. Unlike for example Result, which is must_use annotated. This PR only adds `offset`, because I wanted to float the idea; I'm imagining that there's more than just `add` and `offset` that could use this. I am also very open to re-wording the warning. r? @rust-lang/libs
2020-05-17make many ptr functions must_useSteve Klabnik-0/+2
https://djugei.github.io/bad-at-unsafe/ describes an error a user had when trying to use offset: > At first I just assumed that the .add() and .offset() methods on pointers would mutate the pointer. They do not. Instead they return a new pointer, which gets dropped silently if you don't use it. Unlike for example Result, which is must_use annotated.
2020-05-17make abort intrinsic safe, and correct its documentationRalf Jung-1/+1
2020-04-29document stable counterparts of intrinsicsBastian Kauschke-12/+84
2020-04-25Bump bootstrap compilerMark Rousskov-33/+0
2020-04-18Add example in the alternative in std::mem::transmute docshuangjiahua-0/+18
It is safer to use `from_ne_bytes` to convert raw bytes to type like u32.
2020-04-03Replace max/min_value() with MAX/MIN assoc constsLinus Färnstrand-6/+6
2020-03-29Stabilize float::to_int_uncheckedMark Rousskov-0/+8
This renames and stabilizes unsafe floating point to integer casts, which are intended to be the substitute for the currently unsound `as` behavior, once that changes to safe-but-slower saturating casts.
2020-03-29Rollup merge of #70101 - tmiasko:intrinsics-copy, r=eddybMazdak Farrokhzad-112/+112
Add copy bound to atomic & numeric intrinsics
2020-03-22Auto merge of #69079 - CAD97:layout-of-ptr, r=RalfJungbors-0/+11
Allow calculating the layout behind a pointer There was some discussion around allowing this previously. This does make the requirement for raw pointers to have valid metadata exposed as part of the std API (as a safety invariant, not validity invariant), though I think this is not strictly necessarily required as of current. cc @rust-lang/wg-unsafe-code-guidelines Naming is hard; I picked the best "obvious" name I could come up with. If it's agreed that this is actually a desired API surface, I'll file a tracking issue and update the attributes.
2020-03-21Allow calculating the layout behind a pointerCAD97-0/+11
Let align/size_of_of_val intrinsics work on ptrs
2020-03-19Add copy bound to numeric intrinsicsTomasz Miąsko-31/+31
2020-03-19Add copy bound to atomic intrinsicsTomasz Miąsko-81/+81