summary refs log tree commit diff
path: root/src/librustc_codegen_ssa/mir/block.rs
AgeCommit message (Collapse)AuthorLines
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.
2020-02-13rename PanicInfo -> AssertKindRalf Jung-3/+3
2020-02-13move PanicInfo to mir moduleRalf Jung-1/+1
2020-02-09rustc_codegen_ssa: use `debug_introduce_local` on Operand call results.Eduard-Mihai Burtescu-0/+3
2020-01-28Local field on PlaceRef and RootPlace is not a reference anymoreSantiago Pastorino-1/+1
2020-01-28codegen_place and related functions can take PlaceRef by valueSantiago Pastorino-5/+5
2020-01-10Add span_bug that notes that shuffle indices must be constantSantiago Pastorino-0/+2
2020-01-10Remove PlaceBase enum and make Place base field be local: LocalSantiago Pastorino-1/+1
2020-01-10Use if let instead of match with one meaningful armSantiago Pastorino-19/+9
2020-01-10Remove StaticKind::PromotedSantiago Pastorino-30/+2
2020-01-02Normalize `syntax::source_map` imports.Mazdak Farrokhzad-9/+8
2019-12-25Run RustFmtjumbatm-1/+4
2019-12-25Pass new instance instead of self.instance to simd_shuffle_indices.jumbatm-3/+3
2019-12-22Format the worldMark Rousskov-237/+216
2019-12-22Add simpler entry points to const eval for common usages.Ben Lewis-6/+1
2019-12-08Rollup merge of #66991 - Nashenas88:body_cache_cleanup, r=eddybMazdak Farrokhzad-1/+1
Cleanup BodyCache After this PR: - `BodyCache` is renamed to `BodyAndCache` - `ReadOnlyBodyCache` is renamed to `ReadOnlyBodyAndCache` - `ReadOnlyBodyAndCache::body` fn is removed and all calls to it are replaced by a deref (possible due to fix of its `Deref` imp in #65947) cc @eddyb @oli-obk
2019-12-08Rollup merge of #66325 - BartMassey:master, r=joshtriplettMazdak Farrokhzad-1/+1
Change unused_labels from allow to warn Fixes #66324, making the unused_labels lint warn instead of allow by default. I'm told @rust-lang/lang will need to review this, and perhaps will want to do a crater run.
2019-12-07Auto merge of #65881 - anp:implicit-caller-location, r=eddyb,oli-obkbors-8/+22
Implement #[track_caller] attribute. (RFC 2091 4/N) Implements the `#[track_caller]` attribute in both const and codegen contexts. The const implementation walks up the stack to find the nearest untracked callsite. The codegen implementation adds an implicit argument to tracked function calls, and populates it with either a call to the previously-landed intrinsic or if the caller has `#[track_caller]` with a copy of the location passed to the current function. Also includes a little cleanup and a few comments in the other caller location areas. [Depends on: 65664](https://github.com/rust-lang/rust/pull/65664) [RFC 2091 text](https://github.com/rust-lang/rfcs/blob/master/text/2091-inline-semantic.md) [Tracking issue](https://github.com/rust-lang/rust/issues/47809) [Tracking doc](https://paper.dropbox.com/doc/track_rfc_2091_impl-notes--Anf1NwnIb0xcRv31YLIadyj0Ag-rwCdRc2fi2yvRZ7syGZ9q#:uid=863513134494965680023183&h2=TODO-actually-pass-location-to)
2019-12-06Address review feedback.Adam Perry-2/+2
2019-12-06Caller location is propagated via immediates rather than memory.Adam Perry-4/+2
2019-12-05Pass a location to #[track_caller] functions in codegen_call_terminator.Adam Perry-0/+12