about summary refs log tree commit diff
path: root/compiler/rustc_codegen_cranelift/src
AgeCommit message (Collapse)AuthorLines
2024-04-23Rollup merge of #124003 - WaffleLapkin:dellvmization, r=scottmcm,RalfJung,antoyoMatthias Krüger-3/+7
Dellvmize some intrinsics (use `u32` instead of `Self` in some integer intrinsics) This implements https://github.com/rust-lang/compiler-team/issues/693 minus what was implemented in #123226. Note: I decided to _not_ change `shl`/... builder methods, as it just doesn't seem worth it. r? ``@scottmcm``
2024-04-23Fix broken subtree syncbjorn3-17/+0
2024-04-23Merge commit 'de5d6523738fd44a0521b6abf3e73ae1df210741' into ↵bjorn3-28/+68
sync_cg_clif-2024-04-23
2024-04-21Also handle AggregateKind::RawPtr in cg_craneliftScott McMurray-0/+30
2024-04-19Do intrinsic changes in `rustc_codegen_cranelift`Maybe Waffle-3/+7
2024-04-19Show files produced by --emit foo in json artifact notificationsMichael Baikov-0/+23
2024-04-19ScalarInt: add methods to assert being a (u)int of given sizeRalf Jung-24/+21
2024-04-11Merge commit '89f54caacf90e99fc8ba0d60a28bdadea3cfdf1e' into ↵bjorn3-1/+18
sync_cg_clif-2024-04-11
2024-04-07Only traverse mono-reachable blocks in cg_clifBen Kimock-1/+1
2024-04-07Auto merge of #123221 - pacak:cache_emit, r=fmease,jieyouxubors-1/+17
Save/restore more items in cache with incremental compilation Right now they don't play very well together, consider a simple example: ``` $ export RUSTFLAGS="--emit asm" $ cargo new --lib foo Created library `foo` package $ cargo build -q $ touch src/lib.rs $ cargo build error: could not copy "/path/to/foo/target/debug/deps/foo-e307cc7fa7b6d64f.4qbzn9k8mosu50a5.rcgu.s" to "/path/to/foo/target/debug/deps/foo-e307cc7fa7b6d64f.s": No such file or directory (os error 2) ``` Touch triggers the rebuild, incremental compilation detects no changes (yay) and everything explodes while trying to copy files were they should go. This pull request fixes it by copying and restoring more files in the incremental compilation cache Fixes https://github.com/rust-lang/rust/issues/89149 Fixes https://github.com/rust-lang/rust/issues/88829 Related: https://internals.rust-lang.org/t/interaction-between-incremental-compilation-and-emit/20551
2024-04-06Put checks that detect UB under their own flag below debug_assertionsBen Kimock-1/+1
2024-04-06Save/restore more items in cache with incremental compilationMichael Baikov-1/+17
2024-04-05Merge commit 'fbda869b4e230c788b6bce426038ba8419956f2d' into ↵bjorn3-1/+1
sync_cg_clif-2024-04-05
2024-04-03Rollup merge of #123419 - petrochenkov:zeroindex, r=compiler-errorsMatthias Krüger-2/+2
rustc_index: Add a `ZERO` constant to index types It is commonly used.
2024-04-03rustc_index: Add a `ZERO` constant to index typesVadim Petrochenkov-2/+2
It is commonly used.
2024-04-03rename `expose_addr` to `expose_provenance`joboet-2/+2
2024-04-02Rollup merge of #122935 - RalfJung:with-exposed-provenance, r=AmanieuJacob Pratt-2/+2
rename ptr::from_exposed_addr -> ptr::with_exposed_provenance As discussed on [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/136281-t-opsem/topic/To.20expose.20or.20not.20to.20expose/near/427757066). The old name, `from_exposed_addr`, makes little sense as it's not the address that is exposed, it's the provenance. (`ptr.expose_addr()` stays unchanged as we haven't found a better option yet. The intended interpretation is "expose the provenance and return the address".) The new name nicely matches `ptr::without_provenance`.
2024-04-02Auto merge of #118310 - scottmcm:three-way-compare, r=davidtwcobors-3/+24
Add `Ord::cmp` for primitives as a `BinOp` in MIR Update: most of this OP was written months ago. See https://github.com/rust-lang/rust/pull/118310#issuecomment-2016940014 below for where we got to recently that made it ready for review. --- There are dozens of reasonable ways to implement `Ord::cmp` for integers using comparison, bit-ops, and branches. Those differences are irrelevant at the rust level, however, so we can make things better by adding `BinOp::Cmp` at the MIR level: 1. Exactly how to implement it is left up to the backends, so LLVM can use whatever pattern its optimizer best recognizes and cranelift can use whichever pattern codegens the fastest. 2. By not inlining those details for every use of `cmp`, we drastically reduce the amount of MIR generated for `derive`d `PartialOrd`, while also making it more amenable to MIR-level optimizations. Having extremely careful `if` ordering to μoptimize resource usage on broadwell (#63767) is great, but it really feels to me like libcore is the wrong place to put that logic. Similarly, using subtraction [tricks](https://graphics.stanford.edu/~seander/bithacks.html#CopyIntegerSign) (#105840) is arguably even nicer, but depends on the optimizer understanding it (https://github.com/llvm/llvm-project/issues/73417) to be practical. Or maybe [bitor is better than add](https://discourse.llvm.org/t/representing-in-ir/67369/2?u=scottmcm)? But maybe only on a future version that [has `or disjoint` support](https://discourse.llvm.org/t/rfc-add-or-disjoint-flag/75036?u=scottmcm)? And just because one of those forms happens to be good for LLVM, there's no guarantee that it'd be the same form that GCC or Cranelift would rather see -- especially given their very different optimizers. Not to mention that if LLVM gets a spaceship intrinsic -- [which it should](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Suboptimal.20inlining.20in.20std.20function.20.60binary_search.60/near/404250586) -- we'll need at least a rustc intrinsic to be able to call it. As for simplifying it in Rust, we now regularly inline `{integer}::partial_cmp`, but it's quite a large amount of IR. The best way to see that is with https://github.com/rust-lang/rust/commit/8811efa88b25b5e41d63850e6047e8257c677858#diff-d134c32d028fbe2bf835fef2df9aca9d13332dd82284ff21ee7ebf717bfa4765R113 -- I added a new pre-codegen MIR test for a simple 3-tuple struct, and this PR change it from 36 locals and 26 basic blocks down to 24 locals and 8 basic blocks. Even better, as soon as the construct-`Some`-then-match-it-in-same-BB noise is cleaned up, this'll expose the `Cmp == 0` branches clearly in MIR, so that an InstCombine (#105808) can simplify that to just a `BinOp::Eq` and thus fix some of our generated code perf issues. (Tracking that through today's `if a < b { Less } else if a == b { Equal } else { Greater }` would be *much* harder.) --- r? `@ghost` But first I should check that perf is ok with this ~~...and my true nemesis, tidy.~~
2024-03-29Auto merge of #122450 - Urgau:simplify-trim-paths-feature, r=michaelwoeristerbors-27/+12
Simplify trim-paths feature by merging all debuginfo options together This PR simplifies the trim-paths feature by merging all debuginfo options together, as described in https://github.com/rust-lang/rust/issues/111540#issuecomment-1994010274. And also do some correctness fixes found during the review. cc `@weihanglo` r? `@michaelwoerister`
2024-03-29Auto merge of #122671 - Mark-Simulacrum:const-panic-msg, r=Nilstriebbors-16/+8
Codegen const panic messages as function calls This skips emitting extra arguments at every callsite (of which there can be many). For a librustc_driver build with overflow checks enabled, this cuts 0.7MB from the resulting shared library (see [perf]). A sample improvement from nightly: ``` leaq str.0(%rip), %rdi leaq .Lalloc_d6aeb8e2aa19de39a7f0e861c998af13(%rip), %rdx movl $25, %esi callq *_ZN4core9panicking5panic17h17cabb89c5bcc999E@GOTPCREL(%rip) ``` to this PR: ``` leaq .Lalloc_d6aeb8e2aa19de39a7f0e861c998af13(%rip), %rdi callq *_RNvNtNtCsduqIKoij8JB_4core9panicking11panic_const23panic_const_div_by_zero@GOTPCREL(%rip) ``` [perf]: https://perf.rust-lang.org/compare.html?start=a7e4de13c1785819f4d61da41f6704ed69d5f203&end=64fbb4f0b2d621ff46d559d1e9f5ad89a8d7789b&stat=instructions:u
2024-03-28Replace Session should_remap_filepaths with filename_display_preferenceUrgau-29/+9
2024-03-28Introduce `FileNameMapping::to_real_filename` and use it everywhereUrgau-12/+8
2024-03-28Make local_crate_source_file return a RealFileNameUrgau-1/+8
so it can be remapped (or not) by callers
2024-03-28Replace `RemapFileNameExt::for_codegen` with explicit callsUrgau-1/+3
2024-03-28Merge commit '09fae60a86b848a2fc0ad219ecc4e438dc1eef86' into ↵bjorn3-222/+766
sync_cg_clif-2024-03-28
2024-03-23Add+Use `mir::BinOp::Cmp`Scott McMurray-3/+24
2024-03-23also rename the SIMD intrinsicRalf Jung-1/+1
2024-03-23move assert_unsafe_preconditions to its own fileRalf Jung-1/+1
These macros and functions are not intrinsics, after all.
2024-03-23rename MIR int2ptr casts to match library nameRalf Jung-1/+1
2024-03-22Auto merge of #122852 - compiler-errors:raw-ptr, r=lcnrbors-18/+7
Remove `TypeAndMut` from `ty::RawPtr` variant, make it take `Ty` and `Mutability` Pretty much mechanically converting `ty::RawPtr(ty::TypeAndMut { ty, mutbl })` to `ty::RawPtr(ty, mutbl)` and its fallout. r? lcnr cc rust-lang/types-team#124
2024-03-22Auto merge of #122580 - saethlin:compiler-builtins-can-panic, r=pnkfelixbors-0/+22
"Handle" calls to upstream monomorphizations in compiler_builtins This is pretty cooked, but I think it works. compiler-builtins has a long-standing problem that at link time, its rlib cannot contain any calls to `core`. And yet, in codegen we _love_ inserting calls to symbols in `core`, generally from various panic entrypoints. I intend this PR to attack that problem as completely as possible. When we generate a function call, we now check if we are generating a function call from `compiler_builtins` and whether the callee is a function which was not lowered in the current crate, meaning we will have to link to it. If those conditions are met, actually generating the call is asking for a linker error. So we don't. If the callee diverges, we lower to an abort with the same behavior as `core::intrinsics::abort`. If the callee does not diverge, we produce an error. This means that compiler-builtins can contain panics, but they'll SIGILL instead of panicking. I made non-diverging calls a compile error because I'm guessing that they'd mostly get into compiler-builtins by someone making a mistake while working on the crate, and compile errors are better than linker errors. We could turn such calls into aborts as well if that's preferred.
2024-03-22Programmatically convert some of the pat ctorsMichael Goulet-13/+6
2024-03-22Eagerly convert some ctors to use their specialized ctorsMichael Goulet-5/+1
2024-03-22Codegen const panic messages as function callsMark Rousskov-16/+8
This skips emitting extra arguments at every callsite (of which there can be many). For a librustc_driver build with overflow checks enabled, this cuts 0.7MB from the resulting binary.
2024-03-19Make ptr_guaranteed_cmp a rustc_intrinsic and favor its body over backends ↵Oli Scherer-7/+0
implementing it
2024-03-18Avoid various uses of `Option<Span>` in favor of using `DUMMY_SP` in the few ↵Oli Scherer-4/+6
cases that used `None`
2024-03-16Handle calls to upstream monomorphizations in compiler_builtinsBen Kimock-0/+22
2024-03-16Merge commit '4cf4ffc6ba514f171b3f52d1c731063e4fc45be3' into ↵bjorn3-13/+29
sync_cg_clif-2024-03-16
2024-03-14Rollup merge of #122287 - RalfJung:simd-static-assert, r=pnkfelixMatthias Krüger-1/+1
add test ensuring simd codegen checks don't run when a static assertion failed stdarch relies on this to ensure that SIMD indices are in bounds. I would love to know why this works, but I can't figure out where codegen decides to not codegen a function if a required-const does not evaluate. `@oli-obk` `@bjorn3` do you have any idea?
2024-03-10add comments explaining where post-mono const eval errors abort compilationRalf Jung-1/+1
2024-03-10use Instance::expect_resolve() instead of unwraping Instance::resolve()Ralf Jung-6/+2
2024-03-10Auto merge of #121662 - saethlin:precondition-unification, r=RalfJungbors-1/+1
Distinguish between library and lang UB in assert_unsafe_precondition As described in https://github.com/rust-lang/rust/pull/121583#issuecomment-1963168186, `assert_unsafe_precondition` now explicitly distinguishes between language UB (conditions we explicitly optimize on) and library UB (things we document you shouldn't do, and maybe some library internals assume you don't do). `debug_assert_nounwind` was originally added to avoid the "only at runtime" aspect of `assert_unsafe_precondition`. Since then the difference between the macros has gotten muddied. This totally revamps the situation. Now _all_ preconditions shall be checked with `assert_unsafe_precondition`. If you have a precondition that's only checkable at runtime, do a `const_eval_select` hack, as done in this PR. r? RalfJung
2024-03-08Distinguish between library and lang UB in assert_unsafe_preconditionBen Kimock-1/+1
2024-03-08Merge commit '54cbb6e7531f95e086d5c3dd0d5e73bfbe3545ba' into ↵bjorn3-8/+205
sync_cg_clif-2024-03-08
2024-03-08Rollup merge of #119365 - nbdd0121:asm-goto, r=AmanieuMatthias Krüger-3/+19
Add asm goto support to `asm!` Tracking issue: #119364 This PR implements asm-goto support, using the syntax described in "future possibilities" section of [RFC2873](https://rust-lang.github.io/rfcs/2873-inline-asm.html#asm-goto). Currently I have only implemented the `label` part, not the `fallthrough` part (i.e. fallthrough is implicit). This doesn't reduce the expressive though, since you can use label-break to get arbitrary control flow or simply set a value and rely on jump threading optimisation to get the desired control flow. I can add that later if deemed necessary. r? ``@Amanieu`` cc ``@ojeda``
2024-03-05only set noalias on Box with the global allocatorRalf Jung-4/+0
2024-03-04Add a scheme for moving away from `extern "rust-intrinsic"` entirelyOli Scherer-1/+11
2024-02-28Add `f16` and `f128` to `rustc_type_ir::FloatTy` and `rustc_abi::Primitive`Trevor Gross-0/+4
Make changes necessary to support these types in the compiler.
2024-02-27Auto merge of #121635 - 823984418:remove_archive_builder_lifetime_a, ↵bors-1/+1
r=nnethercote Remove useless lifetime of ArchiveBuilder `trait ArchiveBuilder<'a>` has a seemingly useless lifetime a, so I remove it. If this is intentional, please reject this PR. ```rust pub trait ArchiveBuilder<'a> { fn add_file(&mut self, path: &Path); fn add_archive( &mut self, archive: &Path, skip: Box<dyn FnMut(&str) -> bool + 'static>, ) -> io::Result<()>; fn build(self: Box<Self>, output: &Path) -> bool; } ```
2024-02-26remove useless lifetime of ArchiveBuilder823984418-1/+1