Commit Graph

487 Commits

Author SHA1 Message Date
Antoni Boucher 62867dc29f LTO implementation 2023-08-30 20:29:24 -04:00
Guillaume Gomez c83e5679b3 Don't generate __restrict__ attribute for ByValue arguments 2023-08-29 15:45:48 +02:00
Guillaume Gomez 5ac2530d3c Add support for noalias function parameters 2023-08-25 22:39:22 +02:00
Guillaume Gomez 033dc1f208 Regenerate intrinsics 2023-08-16 13:54:10 +02:00
Antoni Boucher 542c82ec37 Fix for libgccjit 12 2023-08-15 11:25:38 -04:00
Antoni Boucher e3deac5c71 Fix tests 2023-08-15 11:11:57 -04:00
Antoni Boucher 607ec893e7 Merge branch 'master' into sync_from_rust_2023_08_12 2023-08-13 09:59:34 -04:00
Antoni Boucher 43431e4db4 Update to nightly-2023-08-12 2023-08-13 09:37:32 -04:00
Matthias Krüger 8a160d6fcd Rollup merge of #114382 - scottmcm:compare-bytes-intrinsic, r=cjgillot
Add a new `compare_bytes` intrinsic instead of calling `memcmp` directly

As discussed in #113435, this lets the backends be the place that can have the "don't call the function if n == 0" logic, if it's needed for the target.  (I didn't actually *add* those checks, though, since as I understood it we didn't actually need them on known targets?)

Doing this also let me make it `const` (unstable), which I don't think `extern "C" fn memcmp` can be.

cc `@RalfJung` `@Amanieu`
2023-08-07 05:29:12 +02:00
scottmcm b132a7e6d4 Apply suggestions from code review
Co-authored-by: Ralf Jung <post@ralfj.de>
2023-08-06 15:47:40 -07:00
Scott McMurray 9c8ae2f153 Add a new compare_bytes intrinsic instead of calling memcmp directly 2023-08-06 15:47:40 -07:00
David Tolnay fe6a4773a1 Generate better function argument names in global_allocator expansion 2023-08-06 07:36:05 -07:00
Matthias Krüger 7ebcd4d5de Rollup merge of #114450 - chenyukang:yukang-fix-114435, r=compiler-errors
Fix ICE failed to get layout for ReferencesError

Fixes #114435

r? `@compiler-errors`
2023-08-04 21:31:57 +02:00
yukang 46062cd68d Fix ICE failed to get layout for ReferencesError 2023-08-05 01:38:14 +08:00
Oli Scherer de69c67ffa Forbid old-style simd_shuffleN intrinsics 2023-08-03 09:29:00 +00:00
bors 3cde1943af Auto merge of #105545 - erikdesjardins:ptrclean, r=bjorn3
cleanup: remove pointee types

This can't be merged until the oldest LLVM version we support uses opaque pointers, which will be the case after #114148. (Also note `-Cllvm-args="-opaque-pointers=0"` can technically be used in LLVM 15, though I don't think we should support that configuration.)

I initially hoped this would provide some minor perf win, but in https://github.com/rust-lang/rust/pull/105412#issuecomment-1341224450 it had very little impact, so this is only valuable as a cleanup.

As a followup, this will enable #96242 to be resolved.

r? `@ghost`

`@rustbot` label S-blocked
2023-08-01 19:44:17 +00:00
Nicholas Nethercote e94abcdf3d Use standard Rust capitalization rules for names containing "LTO". 2023-07-31 16:21:02 +10:00
Erik Desjardins bc4a65d47f cg_ssa: remove pointee types and pointercast/bitcast-of-ptr 2023-07-29 13:18:20 -04:00
bors 9e58bacf90 Auto merge of #113877 - JhonnyBillM:reuse-codegen-ssa-monomorphization-errors-in-gcc, r=davidtwco
Reuse `codegen_ssa` monomorphization errors in `codegen_gcc`

Removes monomorphization errors duplication by reusing the ones defined in `codegen_ssa`.

Also updates `expected_simd` errors usage in `codegen_gcc` by assuming we want to treat those parameters as translatable. See https://github.com/rust-lang/rust/commit/7a888fb56e23abded6eb5ec0803f182caacc89cb
2023-07-24 11:29:59 +00:00
David Tolnay e2a847460d Revert "Auto merge of #113166 - moulins:ref-niches-initial, r=oli-obk"
This reverts commit 557359f925, reversing
changes made to 1e6c09a803.
2023-07-21 22:35:57 -07:00
bors e865542981 Auto merge of #113166 - moulins:ref-niches-initial, r=oli-obk
Prototype: Add unstable `-Z reference-niches` option

MCP: rust-lang/compiler-team#641
Relevant RFC: rust-lang/rfcs#3204

This prototype adds a new `-Z reference-niches` option, controlling the range of valid bit-patterns for reference types (`&T` and `&mut T`), thereby enabling new enum niching opportunities. Like `-Z randomize-layout`, this setting is crate-local; as such, references to built-in types (primitives, tuples, ...) are not affected.

The possible settings are (here, `MAX` denotes the all-1 bit-pattern):
| `-Z reference-niches=` | Valid range |
|:---:|:---:|
| `null` (the default) | `1..=MAX` |
| `size` | `1..=(MAX- size)` |
| `align` | `align..=MAX.align_down_to(align)` |
| `size,align` | `align..=(MAX-size).align_down_to(align)` |

------

This is very WIP, and I'm not sure the approach I've taken here is the best one, but stage 1 tests pass locally; I believe this is in a good enough state to unleash this upon unsuspecting 3rd-party code, and see what breaks.
2023-07-21 15:00:36 +00:00
Guillaume Gomez 918332bea2 Add support for "ffi_const" function attribute 2023-07-21 11:23:41 +02:00
Matthias Krüger c022c81ece Rollup merge of #113723 - khei4:khei4/llvm-stats, r=oli-obk,nikic
Resurrect: rustc_llvm: Add a -Z `print-codegen-stats` option to expose LLVM statistics.

This resurrects PR https://github.com/rust-lang/rust/pull/104000, which has sat idle for a while. And I want to see the effect of stack-move optimizations on LLVM (like https://reviews.llvm.org/D153453) :).

I have applied the changes requested by `@oli-obk` and `@nagisa`  https://github.com/rust-lang/rust/pull/104000#discussion_r1014625377 and https://github.com/rust-lang/rust/pull/104000#discussion_r1014642482 in the latest commits.

r? `@oli-obk`

-----

LLVM has a neat [statistics](https://llvm.org/docs/ProgrammersManual.html#the-statistic-class-stats-option) feature that tracks how often optimizations kick in. It's very handy for optimization work. Since we expose the LLVM pass timings, I thought it made sense to expose the LLVM statistics too.

-----
(Edit: fix broken link
(Edit2: fix segmentation fault and use malloc

If `rustc` is built with
```toml
[llvm]
assertions = true
```
Then you can see like
```
rustc +stage1 -Z print-codegen-stats -C opt-level=3  tmp.rs
===-------------------------------------------------------------------------===
                          ... Statistics Collected ...
===-------------------------------------------------------------------------===
         3 aa                           - Number of MayAlias results
       193 aa                           - Number of MustAlias results
       531 aa                           - Number of NoAlias results
...
```

And the current default build emits only
```
$ rustc +stage1 -Z print-codegen-stats -C opt-level=3  tmp.rs
===-------------------------------------------------------------------------===
                          ... Statistics Collected ...
===-------------------------------------------------------------------------===
$
```
This might be better to emit the message to tell assertion flag necessity, but now I can't find how to do that...
2023-07-21 06:52:27 +02:00
Moulins 1984e208e0 Don't treat ref. fields with non-null niches as dereferenceable_or_null 2023-07-21 03:31:46 +02:00
Jhonny Bill Mena f746fe1e6c UPDATE - replace expected_simd error with one from codegen_ssa
Here I am assuming we want to treat these parameters (input, first, second, third, return) as translatable
2023-07-20 00:20:00 -04:00
Jhonny Bill Mena 5f56f49946 UPDATE - replace gcc monomorphization errors with ssa ones
Reduces error duplication and makes it more consistent across backends
2023-07-19 23:40:08 -04:00
antoyo 57d2ecb14e Merge pull request #305 from GuillaumeGomez/pure-attr
Add support for "pure" function attribute
2023-07-17 18:10:00 -04:00
Nicholas Nethercote 4bebfae44a Introduce MonoItemData.
It replaces `(Linkage, Visibility)`, making the code nicer. Plus the
next commit will add another field.
2023-07-17 08:44:48 +10:00
Patrick Walton 2c0c87d959 rustc_llvm: Add a -Z print-llvm-stats option to expose LLVM statistics.
LLVM has a neat [statistics] feature that tracks how often optimizations kick
in. It's very handy for optimization work. Since we expose the LLVM pass
timings, I thought it made sense to expose the LLVM statistics too.

[statistics]: https://llvm.org/docs/ProgrammersManual.html#the-statistic-class-stats-option
2023-07-16 22:56:04 +09:00
bjorn3 7ba60ecb53 Extract a create_wrapper_function for use in allocator shim writing
This deduplicates some logic and makes it easier to follow what wrappers
are produced. In the future it may allow moving the code to determine
which wrappers to create to cg_ssa.
2023-07-15 12:37:47 +00:00
Mahdi Dibaiee d873fa7382 refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
Guillaume Gomez c04a631ea6 Add support for "pure" function attribute 2023-07-13 21:43:12 +02:00
Guillaume Gomez 97a0d35a8c Add support for "returns_twice" function attribute 2023-07-12 16:56:24 +02:00
Boxy 761324d1df Move TyCtxt::mk_x to Ty::new_x where applicable 2023-07-05 20:27:07 +01:00
Antoni Boucher 91e04000ea Add support for detecting CPU features 2023-07-05 13:54:14 -04:00
Zalathar 744d05ccb6 Remove trait CoverageInfoMethods, since non-LLVM backends don't need it
These methods are only ever called from within `rustc_codegen_llvm`, so they
can just be declared there as well.
2023-07-05 20:40:40 +10:00
Zalathar d710bee436 Narrow trait CoverageInfoBuilderMethods down to just one method
This effectively inlines most of `FunctionCx::codegen_coverage` into the LLVM
implementation of `CoverageInfoBuilderMethods`.
2023-07-05 20:40:39 +10:00
Guillaume Gomez afc6489394 Add support for cold attribute 2023-06-30 17:11:09 +02:00
Antoni Boucher 38c16e9862 Merge commit '1bbee3e217d75e7bc3bfe5d8c1b35e776fce96e6' into sync-cg_gcc-2023-06-19 2023-06-19 18:51:02 -04:00
Antoni Boucher 37413a2cea Fix indent 2023-06-18 19:42:20 -04:00
Antoni Boucher 607cbfda14 Cleanup and update to rustc 2023-06-19 2023-06-19 10:53:33 -04:00
Antoni Boucher 3d7ec5923d Fix for check_ptr_call for variadic functions 2023-06-17 13:19:41 -04:00
Antoni Boucher 45bca00520 Handle alignment of the load instruction 2023-06-16 12:48:09 -04:00
Antoni Boucher 8bba64673c Cleanup 2023-06-11 20:01:24 -04:00
Antoni Boucher ef037e6d30 Fix tests 2023-06-11 19:27:39 -04:00
Antoni Boucher 90527b81c9 Some fixes and cleanups 2023-06-11 16:04:00 -04:00
Antoni Boucher 6f858a2b0f Add missing cast to fix another issue caused by opaque pointers 2023-06-11 11:52:34 -04:00
Antoni Boucher e74bc5113d Attempt to fix the tests 2023-06-11 11:52:27 -04:00
Antoni Boucher 4115e09c13 Fix for opaque pointers 2023-06-11 11:52:15 -04:00
Antoni Boucher 3d4c59ed75 Merge branch 'master' into sync_from_rust_2023_06_11 2023-06-11 11:52:06 -04:00