880 Commits

Author SHA1 Message Date
est31
fe93911ebc Simplify message paths
This makes it easier to open the messages file while developing on features.

The commit was the result of automatted changes:

for p in compiler/rustc_*; do mv $p/locales/en-US.ftl $p/messages.ftl; rmdir $p/locales; done

for p in compiler/rustc_*; do sed -i "s#\.\./locales/en-US.ftl#../messages.ftl#" $p/src/lib.rs; done
2023-03-11 22:51:57 +01:00
Pietro Albini
8652bbb072 replace legacy copyright annotations in submodules 2023-03-09 12:24:47 +01:00
Matthias Krüger
cbbaebc34c Rollup merge of - antoyo:sync-cg_gcc-2023-03-04, r=cjgillot
Sync rustc_codegen_gcc 2023/03/04

Hi.
This sync all the changes from rustc_codegen_gcc.
Thanks for the review.
2023-03-07 19:57:45 +01:00
bors
7b85215c4f Auto merge of - Jules-Bertholet:round_ties_to_even, r=pnkfelix,m-ou-se,scottmcm
Add `round_ties_even` to `f32` and `f64`

Tracking issue: 

Redux of . See also 

Adds a new method, `round_ties_even`, to `f32` and `f64`, that rounds the float to the nearest integer , rounding halfway cases to the number with an even least significant bit. Uses the `roundeven` LLVM intrinsic to do this.

Of the five IEEE 754 rounding modes, this is the only one that doesn't already have a round-to-integer function exposed by Rust (others are `round`, `floor`, `ceil`, and `trunc`).  Ties-to-even is also the rounding mode used for int-to-float and float-to-float `as` casts, as well as float arithmentic operations. So not having an explicit rounding method for it seems like an oversight.

Bikeshed: this PR currently uses `round_ties_even` for the name of the method. But maybe `round_ties_to_even` is better, or `round_even`, or `round_to_even`?
2023-03-07 09:43:12 +00:00
Antoni Boucher
cf9c2f840f Fix for diagnostics 2023-03-05 12:31:16 -05:00
Antoni Boucher
94538736a8 Update gccjit 2023-03-05 12:16:33 -05:00
Antoni Boucher
d725cfb6ab Merge commit '08a6d6e16b5efe217123e780398969946266268f' into sync-cg_gcc-2023-03-04 2023-03-05 12:03:19 -05:00
antoyo
08a6d6e16b
Merge pull request from rust-lang/sync_from_rust_2023_feb_28_2
Sync from rust 2023 feb 28
2023-03-04 20:21:03 -05:00
Antoni Boucher
4b878ccab4 Fix tests 2023-03-04 19:49:03 -05:00
Antoni Boucher
3180da5529 Fix tests 2023-03-04 19:18:31 -05:00
Antoni Boucher
f83ede03f5 Fix tests 2023-03-04 18:52:25 -05:00
Antoni Boucher
42a89bd875 Fix tests 2023-03-04 15:41:30 -05:00
Antoni Boucher
9d5bc7c929 Fix tests 2023-03-04 15:25:34 -05:00
Antoni Boucher
5c35dc067d Fix warnings 2023-03-04 15:04:55 -05:00
Antoni Boucher
08c75aee1b Fix error in libgccjit12 code path 2023-03-04 15:03:05 -05:00
Antoni Boucher
6958188e10 Temporarily disable rust repo cache 2023-03-04 15:02:49 -05:00
Antoni Boucher
901e413a3f Fix tests 2023-03-04 14:42:34 -05:00
Antoni Boucher
a2f499f05f Fix tests 2023-03-04 14:30:29 -05:00
antoyo
8c3c02097d
Merge pull request from GuillaumeGomez/regen-intrinsics
Regen intrinsics
2023-03-03 10:10:15 -05:00
Guillaume Gomez
74506d3bb1 Regen intrinsics 2023-03-02 23:31:18 +01:00
Antoni Boucher
b4f83c6ed8 Fix error 2023-03-02 17:15:57 -05:00
Antoni Boucher
d8b5a3eaa9 Fix to examples 2023-02-28 22:39:50 -05:00
Antoni Boucher
e74f6ff54f Fix rebase 2023-02-28 22:35:10 -05:00
Antoni Boucher
78f3a7ed1f Update toolchain 2023-02-28 22:20:44 -05:00
Alan Egerton
802e9026d9 Remove type-traversal trait aliases 2023-02-28 22:18:04 -05:00
David Wood
7696f981ea various: translation resources from cg backend
Extend `CodegenBackend` trait with a function returning the translation
resources from the codegen backend, which can be added to the complete
list of resources provided to the emitter.

Signed-off-by: David Wood <david.wood@huawei.com>
2023-02-28 22:16:56 -05:00
David Wood
564ab10b9c errors: generate typed identifiers in each crate
Instead of loading the Fluent resources for every crate in
`rustc_error_messages`, each crate generates typed identifiers for its
own diagnostics and creates a static which are pulled together in the
`rustc_driver` crate and provided to the diagnostic emitter.

Signed-off-by: David Wood <david.wood@huawei.com>
2023-02-28 22:16:56 -05:00
Oli Scherer
ae429e8cab s/eval_usize/eval_target_usize/ for clarity 2023-02-28 22:16:56 -05:00
David Wood
1640ccac4d session: diagnostic migration lint on more fns
Apply the diagnostic migration lint to more functions on `Session`.

Signed-off-by: David Wood <david.wood@huawei.com>
2023-02-28 22:03:22 -05:00
Erik Desjardins
bedaeda508 create and use GlobalAlloc::address_space 2023-02-28 22:03:22 -05:00
Erik Desjardins
7bf0670169 abi: add AddressSpace field to Primitive::Pointer
...and remove it from `PointeeInfo`, which isn't meant for this.

There are still various places (marked with FIXMEs) that assume all pointers
have the same size and alignment. Fixing this requires parsing non-default
address spaces in the data layout string, which will be done in a followup.
2023-02-28 22:03:22 -05:00
Albert Larsan
5dcda26aa6 Change src/test to tests in source files, fix tidy and tests 2023-02-28 22:03:21 -05:00
Michael Goulet
fa874b03e4 Simplify some iterator combinators 2023-02-28 22:00:40 -05:00
Jeremy Stucki
3a1d3241b4 Add missing anonymous lifetime 2023-02-28 21:59:38 -05:00
Jeremy Stucki
888137d7d2 rustc: Remove needless lifetimes 2023-02-28 21:59:38 -05:00
bjorn3
c2e83dce57 Destruct landing_pad return value before passing it to cg_ssa 2023-02-28 21:59:37 -05:00
Ramon de C Valle
7c2db89ce4 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 ).

LLVM KCFI can be enabled with -Zsanitizer=kcfi.

Co-authored-by: bjorn3 <17426603+bjorn3@users.noreply.github.com>
2023-02-28 21:51:37 -05:00
Peter Collingbourne
43f868b1c3 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.
2023-02-28 21:51:36 -05:00
bjorn3
d1eb38f5b5 Rewrite LLVM's archive writer in Rust
This allows it to be used by other codegen backends
2023-02-28 19:24:11 -05:00
Maybe Waffle
634a709549 Prefer doc comments over //-comments in compiler 2023-02-28 19:22:27 -05:00
Chris Denton
6f7a01796d Remove more redundant alls 2023-02-28 19:22:27 -05:00
Ayush Singh
21af0df1e5 Use custom entry name in gcc
This is a continuation of 9f0a8620bd7d325e6d42417b08daff3e55cb88f6 for
gcc.

Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2023-02-28 19:22:27 -05:00
Nicholas Nethercote
bf4e1e49ea 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`.
2023-02-28 19:22:27 -05:00
Caleb Zulawski
5b9b849a19 Allow actual AVX512-related feature names in the case of some misleading aliases 2023-02-28 19:22:27 -05:00
Camille GILLOT
4cbf5e6813 Introduce composite debuginfo. 2023-02-28 19:22:27 -05:00
Ralf Jung
5378b465f0 fix cranelift and gcc 2023-02-28 19:22:27 -05:00
Ralf Jung
fb747d0e24 add is_sized method on Abi and Layout, and use it 2023-02-28 19:22:27 -05:00
Ayush Singh
a897864150 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>
2023-02-28 19:22:26 -05:00
Amanieu d'Antras
dd930a3b5c 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` ().
2023-02-28 19:19:57 -05:00
Daniel Paoliello
4c0a6e610e Support raw-dylib functions being used inside inlined functions 2023-02-28 19:18:41 -05:00