Commit Graph

144 Commits

Author SHA1 Message Date
Nilstrieb c65ebae221 Migrate all diagnostics 2022-10-23 10:09:44 +02:00
bjorn3 268e02c387 Remove type argument of array_alloca and rename to byte_array_alloca 2022-10-02 13:42:14 +00:00
bjorn3 0fe84bc38b Remove dynamic_alloca from BuilderMethods 2022-10-02 13:42:02 +00:00
bjorn3 62cf644c64 Merge apply_attrs_callsite into call and invoke
Some codegen backends are not able to apply callsite attrs after the fact.
2022-10-01 17:01:31 +00:00
bjorn3 a3cc67c796 Remove unused target_cpu and tune_cpu methods from ExtraBackendMethods 2022-10-01 16:45:33 +00:00
bjorn3 c431ea681c Remove several unused methods from MiscMethods 2022-10-01 16:45:07 +00:00
bjorn3 7c91ec4652 Remove unused Context assoc type from WriteBackendMethods 2022-10-01 16:34:45 +00:00
Ellis Hoag 01439c93b8 print <signal> when ranlib failed without an exit code 2022-09-28 19:02:38 -07:00
Ellis Hoag 6d01c6d9c8 lint and remove unused diagnostic 2022-09-26 19:57:40 -07:00
Ellis Hoag d7bee58105 remove comment 2022-09-24 15:03:14 -07:00
Ellis Hoag ac97487645 fix lifetime error 2022-09-24 11:36:16 -07:00
Ellis Hoag 5c7e629b63 rebase and update trait names 2022-09-24 11:06:05 -07:00
Ellis Hoag 6e22c0a8e1 impl SessionDiagnostic for LayoutError and Spanned<T> 2022-09-24 10:25:19 -07:00
Ellis Hoag 249e46bfba Add monomorphization errors 2022-09-24 10:24:48 -07:00
Ellis Hoag 6fdfcb3547 lint type 2022-09-24 10:24:48 -07:00
Ellis Hoag e906ea80fe Add wrapper type for ExitCode for use in RanlibFailure 2022-09-24 10:24:48 -07:00
Ellis Hoag fb488ad366 remove IntoDiagnosticArg impl for Option 2022-09-24 10:24:48 -07:00
Ellis Hoag 1ce482adda Lint against untranslatable diagnostics in rustc_codegen_gcc 2022-09-24 10:24:48 -07:00
Ellis Hoag 5e0c53a679 Add LayoutSizeOverflow 2022-09-24 10:24:48 -07:00
Ellis Hoag d0b7e71918 Add LTONotSupported 2022-09-24 10:24:48 -07:00
Ellis Hoag d9aa635969 Add UnwindingInlineAsm 2022-09-24 10:24:48 -07:00
Ellis Hoag 7e00a48305 Add LinkageConstOrMutType 2022-09-24 10:24:48 -07:00
Ellis Hoag 9363f0fda5 Add RanlibFailure 2022-09-24 10:24:48 -07:00
Oli Scherer 9c4fb018ca Remove dead broken code from const zst handling in backends 2022-09-06 14:09:49 +00:00
Dylan DPC c57a932c3f Rollup merge of #100653 - cuviper:fptoint_sat, r=michaelwoerister,antoyo
Move the cast_float_to_int fallback code to GCC

Now that we require at least LLVM 13, that codegen backend is always
using its intrinsic `fptosi.sat` and `fptoui.sat` conversions, so it
doesn't need the manual implementation. However, the GCC backend still
needs it, so we can move all of that code down there.
2022-08-30 16:56:09 +05:30
Dylan DPC 81f3841cfb Rollup merge of #101101 - RalfJung:read-pointer-as-bytes, r=oli-obk
interpret: make read-pointer-as-bytes a CTFE-only error with extra information

Next step in the reaction to https://github.com/rust-lang/rust/issues/99923. Also teaches Miri to implicitly strip provenance in more situations when transmuting pointers to integers, which fixes https://github.com/rust-lang/miri/issues/2456.

Pointer-to-int transmutation during CTFE now produces a message like this:
```
   = help: this code performed an operation that depends on the underlying bytes representing a pointer
   = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
```

r? ``@oli-obk``
2022-08-30 11:26:51 +05:30
bors 1e978a3627 Auto merge of #96946 - WaffleLapkin:ptr_mask, r=scottmcm
Add pointer masking convenience functions

This PR adds the following public API:
```rust
impl<T: ?Sized> *const T {
    fn mask(self, mask: usize) -> *const T;
}

impl<T: ?Sized> *mut T {
    fn mask(self, mask: usize) -> *const T;
}

// mod intrinsics
fn mask<T>(ptr: *const T, mask: usize) -> *const T
```
This is equivalent to `ptr.map_addr(|a| a & mask)` but also uses a cool llvm intrinsic.

Proposed in https://github.com/rust-lang/rust/pull/95643#issuecomment-1121562352

cc `@Gankra` `@scottmcm` `@RalfJung`

r? rust-lang/libs-api
2022-08-28 01:34:47 +00:00
Ralf Jung e63a625711 interpret: rename relocation → provenance 2022-08-27 14:11:19 -04:00
Nicholas Nethercote f974617bda Move ArgAbi::pad_i32 into PassMode::Cast.
Because it's only needed for that variant. This shrinks the types and
clarifies the logic.
2022-08-26 11:12:36 +10:00
Nicholas Nethercote b853e8a619 Turn ArgAbi::pad into a bool.
Because it's only ever set to `None` or `Some(Reg::i32())`.
2022-08-26 10:53:41 +10:00
Nicholas Nethercote feeaa4db3c Simplify arg capacity calculations.
Currently they try to be very precise. But they are wrong, i.e. they
don't match what's happening in the loop below. This code isn't hot
enough for it to matter that much.
2022-08-26 10:45:45 +10:00
Nicholas Nethercote b75b3b3afe Change FnAbi::args to a boxed slice. 2022-08-26 10:30:36 +10:00
Nicholas Nethercote e4bf113027 Box CastTarget within PassMode.
Because `PassMode::Cast` is by far the largest variant, but is
relatively rare.

This requires making `PassMode` not impl `Copy`, and `Clone` is no
longer necessary. This causes lots of sigil adjusting, but nothing very
notable.
2022-08-26 09:35:28 +10:00
Maybe Waffle 4c54973b65 Fix ptr_mask impl in cg gcc 2022-08-21 05:27:14 +04:00
Maybe Waffle a6183c2f44 Implement ptr_mask intrinsic in cg gcc 2022-08-21 05:27:14 +04:00
Josh Stone 147032a618 Move the cast_float_to_int fallback code to GCC
Now that we require at least LLVM 13, that codegen backend is always
using its intrinsic `fptosi.sat` and `fptoui.sat` conversions, so it
doesn't need the manual implementation. However, the GCC backend still
needs it, so we can move all of that code down there.
2022-08-16 15:46:17 -07:00
bjorn3 7c6c7e8785 Introduce an ArchiveBuilderBuilder
This avoids monomorphizing all linker code for each codegen backend and
will allow passing in extra information to the archive builder from the
codegen backend.
2022-07-28 09:08:47 +00:00
bjorn3 90da3c6f2b Inline inject_dll_import_lib 2022-07-28 08:43:15 +00:00
bjorn3 7c93154a30 Move output argument from ArchiveBuilder::new to .build() 2022-07-28 08:39:19 +00:00
bors daaae25022 Auto merge of #98989 - dpaoliello:rawdylibbin, r=michaelwoerister
Enable raw-dylib for bin crates

Fixes #93842

When `raw-dylib` is used in a `bin` crate, we need to collect all of the `raw-dylib` functions, generate the import library and add that to the linker command line.

I also changed the tests so that 1) the C++ dlls are created after the Rust dlls, thus there is no chance of accidentally using them in the Rust linking process and 2) disabled generating import libraries when building with MSVC.
2022-07-26 01:47:34 +00:00
bors db8086eb60 Auto merge of #95548 - rcvalle:rust-cfi-2, r=nagisa
Add fine-grained LLVM CFI support to the Rust compiler

This PR improves the LLVM Control Flow Integrity (CFI) support in the Rust compiler by providing forward-edge control flow protection for Rust-compiled code only by aggregating function pointers in groups identified by their return and parameter types.

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 https://github.com/rust-lang/rust/issues/89653).

LLVM CFI can be enabled with -Zsanitizer=cfi and requires LTO (i.e., -Clto).

Thank you again, `@eddyb,` `@nagisa,` `@pcc,` and `@tmiasko` for all the help!
2022-07-24 01:22:36 +00:00
Ramon de C Valle 5ad7a646a5 Add fine-grained LLVM CFI support to the Rust compiler
This commit improves the LLVM Control Flow Integrity (CFI) support in
the Rust compiler by providing forward-edge control flow protection for
Rust-compiled code only by aggregating function pointers in groups
identified by their return and parameter types.

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 CFI can be enabled with -Zsanitizer=cfi and requires LTO (i.e.,
-Clto).
2022-07-23 10:51:34 -07:00
Daniel Paoliello 1f33785ed4 Enable raw-dylib for binaries 2022-07-22 09:55:14 -07:00
bors aa01891700 Auto merge of #99420 - RalfJung:vtable, r=oli-obk
make vtable pointers entirely opaque

This implements the scheme discussed in https://github.com/rust-lang/unsafe-code-guidelines/issues/338: vtable pointers should be considered entirely opaque and not even readable by Rust code, similar to function pointers.

- We have a new kind of `GlobalAlloc` that symbolically refers to a vtable.
- Miri uses that kind of allocation when generating a vtable.
- The codegen backends, upon encountering such an allocation, call `vtable_allocation` to obtain an actually dataful allocation for this vtable.
- We need new intrinsics to obtain the size and align from a vtable (for some `ptr::metadata` APIs), since direct accesses are UB now.

I had to touch quite a bit of code that I am not very familiar with, so some of this might not make much sense...
r? `@oli-obk`
2022-07-22 01:33:49 +00:00
Ralf Jung adf6d37d83 slightly cleaner, if more verbose, vtable handling in codegen backends 2022-07-20 17:12:07 -04:00
Ralf Jung 3dad266f40 consistently use VTable over Vtable (matching stable stdlib API RawWakerVTable) 2022-07-20 17:12:07 -04:00
Ralf Jung da5e4d73f1 add a Vtable kind of symbolic allocations 2022-07-20 16:57:31 -04:00
Michael Woerister 88f6c6d8a0 Remove unused StableMap and StableSet types from rustc_data_structures 2022-07-20 13:11:39 +02:00
Joshua Nelson 3c9765cff1 Rename debugging_opts to unstable_opts
This is no longer used only for debugging options (e.g. `-Zoutput-width`, `-Zallow-features`).
Rename it to be more clear.
2022-07-13 17:47:06 -05:00
Dylan DPC 68cfdbb5c1 Rollup merge of #99155 - Amanieu:unstable-target-features, r=davidtwco
Keep unstable target features for asm feature checking

Inline assembly uses the target features to determine which registers
are available on the current target. However it needs to be able to
access unstable target features for this.

Fixes #99071
2022-07-13 19:32:36 +05:30