about summary refs log tree commit diff
path: root/src/librustc_codegen_ssa/mir/block.rs
AgeCommit message (Collapse)AuthorLines
2020-08-30mv compiler to compiler/mark-1416/+0
2020-08-24hir: consistent use and naming of lang itemsDavid Wood-5/+4
This commit adjusts the naming of various lang items so that they are consistent and don't include prefixes containing the target or "LangItem". In addition, lang item variants are no longer exported from the `lang_items` module. Signed-off-by: David Wood <david@davidtw.co>
2020-08-18Moved coverage counter injection from BasicBlock to Statement.Rich Kadel-12/+0
2020-08-17rust_ast::ast => rustc_astUjjwal Sharma-1/+1
2020-07-26Auto merge of #74664 - pnadon:Miri-rename-undef-uninit, r=RalfJungbors-1/+1
Miri rename undef uninit Renamed parts of code within the `librustc_middle/mir/interpret/` directory. Related issue [#71193](https://github.com/rust-lang/rust/issues/71193)
2020-07-23replace miri_start_panic intrinsic by 'extern fn'Ralf Jung-5/+0
2020-07-22renamed ScalarMaybeUninit::not_undef to check_initPhilippe Nadon-1/+1
Renamed the function ScalarMaybeUninit::not_undef to ScalarMaybeUninit::check_init in the file src/librustc_middle/mir/interpret/value.rs, to reflect changes in terminology used. Related issue rust-lang#71193
2020-07-20mir: `unused_generic_params` queryDavid Wood-1/+2
This commit implements the `unused_generic_params` query, an initial version of polymorphization which detects when an item does not use generic parameters and is being needlessly monomorphized as a result. Signed-off-by: David Wood <david@davidtw.co>
2020-07-15Add and use more static symbols.Nicholas Nethercote-13/+12
Note that the output of `unpretty-debug.stdout` has changed. In that test the hash values are normalized from a symbol numbers to small numbers like "0#0" and "0#1". The increase in the number of static symbols must have caused the original numbers to contain more digits, resulting in different pretty-printing prior to normalization.
2020-06-29add spans to injected coverage countersRich Kadel-1/+13
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-26Show the values and computation that would overflow a const evaluation or ↵Oliver Scherer-1/+1
propagation
2020-06-21remove switch_ty reliance in codegenRalf Jung-0/+2
2020-06-19Rollup merge of #73011 - richkadel:llvm-count-from-mir-pass, r=tmandryRalf Jung-0/+1
first stage of implementing LLVM code coverage This PR replaces #70680 (WIP toward LLVM Code Coverage for Rust) since I am re-implementing the Rust LLVM code coverage feature in a different part of the compiler (in MIR pass(es) vs AST). This PR updates rustc with `-Zinstrument-coverage` option that injects the llvm intrinsic `instrprof.increment()` for code generation. This initial version only injects counters at the top of each function, and does not yet implement the required coverage map. Upcoming PRs will add the coverage map, and add more counters and/or counter expressions for each conditional code branch. Rust compiler MCP https://github.com/rust-lang/compiler-team/issues/278 Relevant issue: #34701 - Implement support for LLVMs code coverage instrumentation ***[I put together some development notes here, under a separate branch.](https://github.com/richkadel/rust/blob/cfa0b21d34ee64e4ebee226101bd2ef0c6757865/src/test/codegen/coverage-experiments/README-THIS-IS-TEMPORARY.md)***
2020-06-16rename location field of Drop terminators to placeRalf Jung-2/+2
2020-06-15Add case for count_code_region() extern lang_itemRich Kadel-4/+1
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-15[WIP] injects llvm intrinsic instrprof.increment for coverage reportsRich Kadel-1/+5
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-12Rollup merge of #73033 - Amanieu:asm-tls, r=oli-obkDylan DPC-6/+2
Fix #[thread_local] statics as asm! sym operands The `asm!` RFC specifies that `#[thread_local]` statics may be used as `sym` operands for inline assembly. This also fixes a regression in the handling of `#[thread_local]` during monomorphization which caused link-time errors with multiple codegen units, most likely introduced by #71192. r? @oli-obk
2020-06-10Track span of function in method calls, and use this in #[track_caller]Aaron Hill-2/+10
Fixes #69977 When we parse a chain of method calls like `foo.a().b().c()`, each `MethodCallExpr` gets assigned a span that starts at the beginning of the call chain (`foo`). While this is useful for diagnostics, it means that `Location::caller` will return the same location for every call in a call chain. This PR makes us separately record the span of the function name and arguments for a method call (e.g. `b()` in `foo.a().b().c()`). This `Span` is passed through HIR lowering and MIR building to `TerminatorKind::Call`, where it is used in preference to `Terminator.source_info.span` when determining `Location::caller`. This new span is also useful for diagnostics where we want to emphasize a particular method call - for an example, see https://github.com/rust-lang/rust/pull/72389#discussion_r436035990
2020-06-07rename FalseEdges -> FalseEdgeRalf Jung-1/+1
2020-06-06Fix #[thread_local] statics as asm! sym operandsAmanieu d'Antras-6/+2
2020-05-30Rollup merge of #72625 - Amanieu:asm-srcloc, r=petrochenkovRalf Jung-2/+10
Improve inline asm error diagnostics Previously we were just using the raw LLVM error output (with line, caret, etc) as the diagnostic message, which ends up looking rather out of place with our existing diagnostics. The new diagnostics properly format the diagnostics and also take advantage of LLVM's per-line `srcloc` attribute to map an error in inline assembly directly to the relevant line of source code. Incidentally also fixes #71639 by disabling `srcloc` metadata during LTO builds since we don't know what crate it might have come from. We can only resolve `srcloc`s from the currently crate since it indexes into the source map for the current crate. Fixes #72664 Fixes #71639 r? @petrochenkov ### Old style ```rust #![feature(llvm_asm)] fn main() { unsafe { let _x: i32; llvm_asm!( "mov $0, $1 invalid_instruction $0, $1 mov $0, $1" : "=&r" (_x) : "r" (0) :: "intel" ); } } ``` ``` error: <inline asm>:3:14: error: invalid instruction mnemonic 'invalid_instruction' invalid_instruction ecx, eax ^~~~~~~~~~~~~~~~~~~ --> src/main.rs:6:9 | 6 | / llvm_asm!( 7 | | "mov $0, $1 8 | | invalid_instruction $0, $1 9 | | mov $0, $1" ... | 12 | | :: "intel" 13 | | ); | |__________^ ``` ### New style ```rust #![feature(asm)] fn main() { unsafe { asm!( "mov {0}, {1} invalid_instruction {0}, {1} mov {0}, {1}", out(reg) _, in(reg) 0i64, ); } } ``` ``` error: invalid instruction mnemonic 'invalid_instruction' --> test.rs:7:14 | 7 | invalid_instruction {0}, {1} | ^ | note: instantiated into assembly here --> <inline asm>:3:14 | 3 | invalid_instruction rax, rcx | ^^^^^^^^^^^^^^^^^^^ ```
2020-05-29Improve inline asm error diagnosticsAmanieu d'Antras-2/+10
2020-05-24Properly handle InlineAsmOperand::SymFn when collecting monomorphized itemsAmanieu d'Antras-2/+1
Fixes #72484
2020-05-18Fix const handling and add tests for const operandsAmanieu d'Antras-91/+128
2020-05-18Minor fixesAmanieu d'Antras-1/+2
2020-05-18Implement asm! codegenAmanieu d'Antras-0/+93
2020-04-22Use `Body` everywhereDylan MacKenzie-1/+1
2020-04-22Don't use `*` for deref-coercionDylan MacKenzie-2/+2
2020-04-18Detect mistyped associated consts in `Instance::resolve`.Eduard-Mihai Burtescu-0/+1
2020-04-15Use `call` instead of `invoke` for functions that cannot unwindWesley Wiser-1/+3
The `FnAbi` now knows if the function is allowed to unwind. If a function isn't allowed to unwind, we can use a `call` instead of an `invoke`. This resolves an issue when calling LLVM intrinsics which cannot unwind LLVM will generate an error if you attempt to invoke them so we need to ignore cleanup blocks in codegen and generate a call instead.
2020-04-02direct imports for langitem stuffMazdak Farrokhzad-1/+1
2020-04-02nix rustc_target::abi::* reexport in ty::layoutMazdak Farrokhzad-3/+4
2020-03-31Use Place directly in codegen_transmute, it's CopySantiago Pastorino-2/+2
2020-03-31Use Place directly on make_return_dest, it's CopySantiago Pastorino-2/+2
2020-03-31Use Place directly on codegen_drop_terminator, it's CopySantiago Pastorino-2/+2
2020-03-30rustc -> rustc_middle part 3 (rustfmt)Mazdak Farrokhzad-1/+1
2020-03-30rustc -> rustc_middle part 2Mazdak Farrokhzad-5/+5
2020-03-13Auto merge of #67502 - Mark-Simulacrum:opt-catch, r=Mark-Simulacrumbors-9/+4
Optimize catch_unwind to match C++ try/catch This refactors the implementation of catching unwinds to allow LLVM to inline the "try" closure directly into the happy path, avoiding indirection. This means that the catch_unwind implementation is (after this PR) zero-cost unless a panic is thrown. https://rust.godbolt.org/z/cZcUSB is an example of the current codegen in a simple case. Notably, the codegen is *exactly the same* if `-Cpanic=abort` is passed, which is clearly not great. This PR, on the other hand, generates the following assembly: ```asm # -Cpanic=unwind: push rbx mov ebx,0x2a call QWORD PTR [rip+0x1c53c] # <happy> mov eax,ebx pop rbx ret mov rdi,rax call QWORD PTR [rip+0x1c537] # cleanup function call call QWORD PTR [rip+0x1c539] # <unfortunate> mov ebx,0xd mov eax,ebx pop rbx ret # -Cpanic=abort: push rax call QWORD PTR [rip+0x20a1] # <happy> mov eax,0x2a pop rcx ret ``` Fixes #64224, and resolves #64222.
2020-03-13adjust enum namingRalf Jung-12/+12
2020-03-12rename panic_if_ intrinsics to assert_Ralf Jung-4/+4
2020-03-11Rollup merge of #69850 - RalfJung:panic-bounds-check, r=eddybMazdak Farrokhzad-1/+5
panic_bounds_check: use caller_location, like PanicFnLangItem The `PanicFnLangItem` got switched to using `#[caller_location]` at some point, but `PanicBoundsCheckFnLangItem` was kept in the old style. For consistency, switch that one over to use `#[caller_location]` as well. This is also helpful for Miri as it means the `assert_panic` machine hook never needs to know the current `Span`.
2020-03-09Improve readabilityRalf Jung-2/+2
2020-03-09panic_bounds_check: use caller_location, like PanicFnLangItemRalf Jung-1/+5
2020-03-05Remove eh_unwind_resume lang itemAmanieu d'Antras-9/+4
2020-02-29move panic intrinsic codegen to helper functionRalf Jung-66/+92
2020-02-29fmtRalf Jung-6/+10
2020-02-29make it even more conservative, and note some FIXMEsRalf Jung-0/+2
2020-02-29mem::zeroed/uninit: panic on types that do not permit zero-initializationRalf Jung-3/+28
2020-02-24no more codegen for miri_start_panicRalf Jung-5/+2
2020-02-15Change `const_field` and `const_caller_location` to return `ConstValue` ↵Ben Lewis-1/+1
instead of `Const` as the type in the returned const isn't needed.