Commit Graph

710 Commits

Author SHA1 Message Date
Antoni Boucher
f1f136bb66 Fix tests 2023-01-09 17:27:28 -05:00
Antoni Boucher
2bf7fb402b Use gccjit from repo 2023-01-09 17:12:08 -05:00
Antoni Boucher
af8db759be Support libgccjit12 2023-01-09 17:04:59 -05:00
Antoni Boucher
70659f7591 Cleanup 2023-01-08 11:42:00 -05:00
Antoni Boucher
a4b74e3adf Fix unwinding 2023-01-06 10:42:38 -05:00
Michael Goulet
26c010c941 Simplify some iterator combinators 2023-01-04 00:48:07 +00:00
Antoni Boucher
7c1d21c3b9 Don't automatically run asm_tests in test.sh 2023-01-03 15:08:07 -05:00
Antoni Boucher
71d7e561bd Comment 2023-01-03 08:56:00 -05:00
Antoni Boucher
b0cf0e8c06 WIP 2023-01-02 14:57:38 -05:00
Antoni Boucher
889a33a500 WIP: Implement unwinding 2023-01-02 14:57:38 -05:00
Jeremy Stucki
2d09c9bc94 Add missing anonymous lifetime 2022-12-20 22:34:42 +01:00
Jeremy Stucki
b4e9ba5cf3 rustc: Remove needless lifetimes 2022-12-20 22:10:40 +01:00
bors
6ec5ebdc2c Auto merge of #105252 - bjorn3:codegen_less_pair_values, r=nagisa
Use struct types during codegen in less places

This makes it easier to use cg_ssa from a backend like Cranelift that doesn't have any struct types at all. After this PR struct types are still used for function arguments and return values. Removing those usages is harder but should still be doable.
2022-12-12 10:38:31 +00:00
Jules Bertholet
ac4e9caaf5 Add round_ties_even to f32 and f64 2022-12-11 01:20:17 -05:00
Matthias Krüger
79f7b7b874 Rollup merge of #105109 - rcvalle:rust-kcfi, r=bjorn3
Add LLVM KCFI support to the Rust compiler

This PR adds LLVM Kernel Control Flow Integrity (KCFI) support to the Rust compiler. It initially provides forward-edge control flow protection for operating systems kernels for Rust-compiled code only by aggregating function pointers in groups identified by their return and parameter types. (See llvm/llvm-project@cff5bef.)

Forward-edge control flow protection for C or C++ and Rust -compiled code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code share the same virtual address space) will be provided in later work as part of this project by identifying C char and integer type uses at the time types are encoded (see Type metadata in the design document in the tracking issue #89653).

LLVM KCFI can be enabled with -Zsanitizer=kcfi.

Thank you again, `@bjorn3,` `@eddyb,` `@nagisa,` and `@ojeda,` for all the help!
2022-12-10 09:24:43 +01:00
Ramon de C Valle
d5f7c20ce5 Add LLVM KCFI support to the Rust compiler
This commit adds LLVM Kernel Control Flow Integrity (KCFI) support to
the Rust compiler. It initially provides forward-edge control flow
protection for operating systems kernels for Rust-compiled code only by
aggregating function pointers in groups identified by their return and
parameter types. (See llvm/llvm-project@cff5bef.)

Forward-edge control flow protection for C or C++ and Rust -compiled
code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code
share the same virtual address space) will be provided in later work as
part of this project by identifying C char and integer type uses at the
time types are encoded (see Type metadata in the design document in the
tracking issue #89653).

LLVM KCFI can be enabled with -Zsanitizer=kcfi.

Co-authored-by: bjorn3 <17426603+bjorn3@users.noreply.github.com>
2022-12-08 17:24:39 -08:00
Peter Collingbourne
6181cb2929 Move linkage type check to HIR analysis and fix semantics issues.
This ensures that the error is printed even for unused variables,
as well as unifying the handling between the LLVM and GCC backends.

This also fixes unusual behavior around exported Rust-defined variables
with linkage attributes. With the previous behavior, it appears to be
impossible to define such a variable such that it can actually be imported
and used by another crate. This is because on the importing side, the
variable is required to be a pointer, but on the exporting side, the
type checker rejects static variables of pointer type because they do
not implement `Sync`. Even if it were possible to import such a type, it
appears that code generation on the importing side would add an unexpected
additional level of pointer indirection, which would break type safety.

This highlighted that the semantics of linkage on Rust-defined variables
is different to linkage on foreign items. As such, we now model the
difference with two different codegen attributes: linkage for Rust-defined
variables, and import_linkage for foreign items.

This change gives semantics to the test
src/test/ui/linkage-attr/auxiliary/def_illtyped_external.rs which was
previously expected to fail to compile. Therefore, convert it into a
test that is expected to successfully compile.

The update to the GCC backend is speculative and untested.
2022-12-05 15:05:43 -08:00
bjorn3
213ced1c43 Destruct landing_pad return value before passing it to cg_ssa 2022-12-03 18:27:18 +00:00
bors
12224e81c9 Auto merge of #97485 - bjorn3:new_archive_writer, r=wesleywiser
Rewrite LLVM's archive writer in Rust

This allows it to be used by other codegen backends.

Fixes https://github.com/bjorn3/rustc_codegen_cranelift/issues/1155
2022-12-03 15:07:39 +00:00
Matthias Krüger
f9805a2186 Rollup merge of #104976 - WaffleLapkin:move_comments, r=cjgillot
Prefer doc comments over `//`-comments in compiler

Doc comments are generally nicer: they show up in the documentation, they are shown in IDEs when you hover other mentions of items, etc. Thus it makes sense to use them instead of `//`-comments.
2022-11-27 22:14:08 +01:00
Maybe Waffle
38dfdee36a Prefer doc comments over //-comments in compiler 2022-11-27 11:19:04 +00:00
bjorn3
690085c2da Rewrite LLVM's archive writer in Rust
This allows it to be used by other codegen backends
2022-11-26 19:35:32 +00:00
Chris Denton
39511672e7 Remove more redundant alls 2022-11-26 09:54:54 +00:00
antoyo
0a54f243f6
Merge pull request #225 from rust-lang/feature/stdarch-tests
Run stdarch tests in the CI
2022-11-25 15:12:29 -05:00
Antoni Boucher
054696e4a3 Disable stdarch examples which require unwinding 2022-11-25 11:38:49 -05:00
Antoni Boucher
3791646c02 Run stdarch tests in the CI 2022-11-25 11:38:49 -05:00
antoyo
8520bc7f9f
Merge pull request #174 from rust-lang/ci/ubuntu-libgccjit-12
Download libgccjit-12-dev package in the CI
2022-11-24 21:29:42 -05:00
antoyo
57b50df17e
Merge pull request #241 from rust-lang/fix/avx-intrinsics
Fix the argument order for some AVX-512 intrinsics
2022-11-24 21:27:42 -05:00
Antoni Boucher
69341c44cc Fix the argument order for some AVX-512 intrinsics 2022-11-24 18:32:17 -05:00
Antoni Boucher
bbc0c26508 Download libgccjit-12-dev package in the CI 2022-11-24 18:13:23 -05:00
antoyo
83c55fc4df
Merge pull request #240 from rust-lang/fix/simd_bitmask
Fix simd_bitmask
2022-11-24 17:47:42 -05:00
Antoni Boucher
76991ba26f Fix simd_bitmask 2022-11-24 17:26:58 -05:00
antoyo
3c03c8f048
Merge pull request #239 from rust-lang/fix/expandloadu
Escape { and } in inline asm
2022-11-24 13:54:59 -05:00
Antoni Boucher
15fcca80a4 Escape { and } in inline asm 2022-11-24 13:21:04 -05:00
Dylan DPC
20ff36217a Rollup merge of #104001 - Ayush1325:custom-entry, r=bjorn3
Improve generating Custom entry function

This commit is aimed at making compiler-generated entry functions (Basically just C `main` right now) more generic so other targets can do similar things for custom entry. This was initially implemented as part of https://github.com/rust-lang/rust/pull/100316.

Currently, this moves the entry function name and Call convention to the target spec.

Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2022-11-19 11:54:43 +05:30
bors
ee50714c91 Auto merge of #103138 - nnethercote:merge-BBs, r=bjorn3
Merge basic blocks where possible when generating LLVM IR.

r? `@ghost`
2022-11-17 01:56:24 +00:00
Matthias Krüger
5d862b86df Rollup merge of #103750 - calebzulawski:master, r=workingjubilee
Fix some misleading target feature aliases

This is the first half of a fix for #100752.  It looks like these aliases were added in #78361 and slipped under the radar, as these features are not AVX512.  These features _do_ add AVX512 instructions when used _in combination_ with AVX512F, but without AVX512F, these features still provide 128-bit and 256-bit vector instructions.  A user might be mislead into thinking these features imply AVX512F (which is true of the actual AVX512 features).  This PR allows using the names as defined by LLVM, which matches Intel documentation.

A future PR should change the `std::arch` intrinsics to use these names, and finally remove these aliases from rustc.

r? ```@workingjubilee```

cc ```@Amanieu```
2022-11-16 15:39:44 +01:00
Nicholas Nethercote
d01b63a09a Use &mut Bx more.
For the next commit, `FunctionCx::codegen_*_terminator` need to take a
`&mut Bx` instead of consuming a `Bx`. This triggers a cascade of
similar changes across multiple functions. The resulting code is more
concise and replaces many `&mut bx` expressions with `bx`.
2022-11-16 15:46:39 +11:00
bors
d2d2b28f5a Auto merge of #102570 - cjgillot:deagg-debuginfo, r=oli-obk
Perform simple scalar replacement of aggregates (SROA) MIR opt

This is a re-open of https://github.com/rust-lang/rust/pull/85796

I copied the debuginfo implementation (first commit) from `@eddyb's` own SROA PR.

This pass replaces plain field accesses by simple locals when possible.
To be eligible, the replaced locals:
- must not be enums or unions;
- must not be used whole;
- must not have their address taken.

The storage and deinit statements are duplicated on each created local.

cc `@tmiasko` who reviewed the former version of this PR.
2022-11-15 23:52:22 +00:00
Camille GILLOT
af8682b8b4 Introduce composite debuginfo. 2022-11-15 17:53:50 +00:00
bors
eb0bc4759b Auto merge of #104054 - RalfJung:byte-provenance, r=oli-obk
interpret: support for per-byte provenance

Also factors the provenance map into its own module.

The third commit does the same for the init mask. I can move it in a separate PR if you prefer.

Fixes https://github.com/rust-lang/miri/issues/2181

r? `@oli-obk`
2022-11-15 17:37:15 +00:00
Ayush Singh
695c76c45a Use custom entry name in gcc
This is a continuation of 9f0a8620bd for
gcc.

Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2022-11-15 22:15:55 +05:30
Ralf Jung
358419cc25 add is_sized method on Abi and Layout, and use it 2022-11-13 12:23:53 +01:00
Caleb Zulawski
2596ab4d75 Allow actual AVX512-related feature names in the case of some misleading aliases 2022-11-12 18:46:21 -05:00
Ralf Jung
e876f43599 fix cranelift and gcc 2022-11-06 14:17:10 +01:00
Ayush Singh
87237cb699 Add type_array to BaseTypeMethods
Moved type_array function to rustc_codegen_ssa::BaseTypeMethods trait.
This allows using normal alloca function to create arrays as suggested in
https://github.com/rust-lang/rust/pull/104022.

Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2022-11-06 14:18:36 +05:30
Amanieu d'Antras
5a1c8e8e5c Rewrite implementation of #[alloc_error_handler]
The new implementation doesn't use weak lang items and instead changes
`#[alloc_error_handler]` to an attribute macro just like
`#[global_allocator]`.

The attribute will generate the `__rg_oom` function which is called by
the compiler-generated `__rust_alloc_error_handler`. If no `__rg_oom`
function is defined in any crate then the compiler shim will call
`__rdl_oom` in the alloc crate which will simply panic.

This also fixes link errors with `-C link-dead-code` with
`default_alloc_error_handler`: `__rg_oom` was previously defined in the
alloc crate and would attempt to reference the `oom` lang item, even if
it didn't exist. This worked as long as `__rg_oom` was excluded from
linking since it was not called.

This is a prerequisite for the stabilization of
`default_alloc_error_handler` (#102318).
2022-10-31 16:32:57 +00:00
antoyo
bfc184cd2c
Merge pull request #232 from GuillaumeGomez/more-inline-asm-register-class-conversion
Add missing register class conversion for inline asm
2022-10-26 12:20:15 -04:00
Guillaume Gomez
bf3ef4ce1a Revert changes in argument parsing for setting asm syntax 2022-10-26 17:04:58 +02:00
bors
a1d984ce61 Auto merge of #103392 - RalfJung:miri, r=oli-obk
update Miri

I had to use a hacked version of josh to create this, so let's be careful with merging this and maybe wait a bit to see if the josh issue becomes more clear. But the history looks good to me, we are not adding duplicates of rustc commits that were previously mirrored to Miri.

Also I want to add some cross-testing of Miri in x.py.
2022-10-25 12:33:39 +00:00