Commit Graph

3086 Commits

Author SHA1 Message Date
bjorn3
244455d8e3 Apply sysroot patches to rustc bootstrap and rustc test suite tests
This is necessary on AArch64 as 128bit atomics aren't yet supported by
Cranelift.
2022-09-01 16:41:01 +00:00
bjorn3
de7342b444 Implement core::hint::spin_loop() on AArch64
This is used in the futex based mutex implementation of libstd
2022-09-01 16:18:39 +00:00
bjorn3
eef75dde3b Update libloading to 0.7.3
This was previously done in bfcf97bd83, but got
reverted due to a bug. The bug seems to be fixed now.

Fixes #1137
2022-09-01 15:52:48 +00:00
bjorn3
2231545ebf Use pointer_ty instead of func.dfg.value_type
This fixes a borrowck error with the current main branch of Cranelift.
2022-09-01 14:00:21 +02:00
bjorn3
2bcc936a5a Remove all uses of Function::with_name_signature
The current main branch of Cranelift changed it's signature. Removing
it's use is the easiest way to deal with this.
2022-09-01 13:53:47 +02:00
bjorn3
096611855c Update abi-checker
This updates a test expectation for s390x
2022-09-01 11:53:35 +02:00
bors
bfb2016a7e Auto merge of #100707 - dzvon:fix-typo, r=davidtwco
Fix a bunch of typo

This PR will fix some typos detected by [typos].

I only picked the ones I was sure were spelling errors to fix, mostly in
the comments.

[typos]: https://github.com/crate-ci/typos
2022-09-01 05:39:58 +00:00
Ralf Jung
d60e93035f Rollup merge of #100730 - CleanCut:diagnostics-rustc_monomorphize, r=davidtwco
Migrate rustc_monomorphize to use SessionDiagnostic

### Description

- Migrates diagnostics in `rustc_monomorphize` to use `SessionDiagnostic`
- Adds an `impl IntoDiagnosticArg for PathBuf`

### TODO / Help!
- [x] I'm having trouble figuring out how to apply an optional note. 😕  Help!?
  - Resolved. It was bad docs. Fixed in https://github.com/rust-lang/rustc-dev-guide/pull/1437/files
- [x] `errors:RecursionLimit` should be `#[fatal ...]`, but that doesn't exist so it's `#[error ...]` at the moment.
  - Maybe I can switch after this is merged in? --> https://github.com/rust-lang/rust/pull/100694
  - Or maybe I need to manually implement `SessionDiagnostic` instead of deriving it?
- [x] How does one go about converting an error inside of [a call to struct_span_lint_hir](8064a49508/compiler/rustc_monomorphize/src/collector.rs (L917-L927))?
- [x] ~What placeholder do you use in the fluent template to refer to the value in a vector? It seems like [this code](0b79f758c9/compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs (L83-L114)) ought to have the answer (or something near it)...but I can't figure it out.~ You can't. Punted.
2022-08-31 14:29:51 +02:00
Dezhi Wu
3d9cee13dd Correct typo 2022-08-31 18:25:00 +08:00
Dezhi Wu
8d76b2ffb9 Fix a bunch of typo
This PR will fix some typos detected by [typos].

I only picked the ones I was sure were spelling errors to fix, mostly in
the comments.

[typos]: https://github.com/crate-ci/typos
2022-08-31 18:24:55 +08:00
bjorn3
eb9fb29395 Rustup to rustc 1.65.0-nightly (bc4b39c27 2022-08-29) 2022-08-30 10:14:55 +02:00
bjorn3
4f613ec2aa Sync from rust 9f4d5d2a28 2022-08-30 10:01:28 +02:00
Dylan DPC
5e494b4243 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
Matthias Krüger
663b8949b7 Rollup merge of #99027 - tmiasko:basic-blocks, r=oli-obk
Replace `Body::basic_blocks()` with field access

Since the refactoring in #98930, it is possible to borrow the basic blocks
independently from other parts of MIR by accessing the `basic_blocks` field
directly.

Replace unnecessary `Body::basic_blocks()` method with a direct field access,
which has an additional benefit of borrowing the basic blocks only.
2022-08-29 06:34:43 +02:00
Martin Nordholts
4b3aa91b03 Support #[unix_sigpipe = "inherit|sig_dfl|sig_ign"] on fn main()
This makes it possible to instruct libstd to never touch the signal
handler for `SIGPIPE`, which makes programs pipeable by default (e.g.
with `./your-program | head -n 1`) without `ErrorKind::BrokenPipe`
errors.
2022-08-28 19:46:45 +02:00
bjorn3
d18a3757dd
Merge pull request #1273 from bjorn3/jit_pull_symbols
Use pull instead of push based model for getting dylib symbols in the jit
2022-08-28 11:30:00 +02:00
bjorn3
a7de42f61b Use pull instead of push based model for getting dylib symbols in the jit
This avoids having to parse the dylibs to get all symbols and matches
the way the dynamic linker resolves symbols. Furthermore it fixes the
jit on Windows.
2022-08-28 10:43:19 +02:00
bors
f48af912ea 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
94f2fef4cc interpret: make read-pointer-as-bytes *always* work in Miri
and show some extra information when it happens in CTFE
2022-08-27 18:37:44 -04:00
Ralf Jung
0644a8c858 interpret: rename relocation → provenance 2022-08-27 14:11:19 -04:00
bors
1239a022ca Auto merge of #100999 - nnethercote:shrink-FnAbi, r=bjorn3
Shrink `FnAbi`

Because they can take up a lot of memory in debug and release builds.

r? `@bjorn3`
2022-08-27 14:00:53 +00:00
Tomasz Miąsko
1071c4c10b Replace Body::basic_blocks() with field access 2022-08-26 14:27:08 +02:00
Nicholas Nethercote
2d2a3be651 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
1c989472e4 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
Nathan Stocks
8c93170965 adjust to new error value 2022-08-25 11:06:45 -06:00
bjorn3
53f4bb9352 Sync from rust 4d45b0745a 2022-08-25 16:34:28 +02:00
bjorn3
d9bbac069b Rustfmt 2022-08-24 17:06:47 +00:00
bjorn3
cfef0a4f8d Merge commit 'e9d1a0a7b0b28dd422f1a790ccde532acafbf193' into sync_cg_clif-2022-08-24 2022-08-24 18:40:58 +02:00
bjorn3
e9d1a0a7b0 Rustup to rustc 1.65.0-nightly (060e47f74 2022-08-23) 2022-08-24 18:37:37 +02:00
bjorn3
ad1d993249 Sync from rust 4a24f08ba4 2022-08-24 18:29:45 +02:00
bjorn3
ee8f8bfacd
Merge pull request #1271 from bjorn3/parallel_comp_support
Support compiling codegen units in parallel
2022-08-24 17:22:30 +02:00
bjorn3
072fd2b0b1 Add fixme 2022-08-24 14:28:40 +00:00
bjorn3
293223d0cf Tune drop_excess_capacity 2022-08-24 12:22:01 +02:00
bjorn3
f71c545746 Make sure to count reused cgus towards the count of jobs done 2022-08-23 16:51:06 +00:00
bjorn3
5b4195669e Add some self profiler calls 2022-08-23 16:32:38 +00:00
bjorn3
d081c20273 Compile functions from clif ir to object code in parallel 2022-08-23 16:32:38 +00:00
bjorn3
1a6323313b Use correct CguReuse variant 2022-08-23 16:32:20 +00:00
bjorn3
f9d60cf551 Do asm compilation and object file emission in parallel 2022-08-23 16:05:29 +00:00
bjorn3
1a0dfb399c Add a jobserver based concurrency limiter 2022-08-23 15:44:39 +00:00
bjorn3
5896e5cdfa Store symbol name as owned string 2022-08-23 15:23:56 +00:00
bjorn3
b1e9d2e1a2 Revert "Avoid masking shift amounts (#1268)"
This reverts commit 156bda8bc7.

This breaks the mir_overflow_off rustc test:
https://github.com/bjorn3/rustc_codegen_cranelift/runs/7971362755?check_suite_focus=true#step:7:2904
2022-08-23 11:10:44 +00:00
Afonso Bordado
48c45c481c
Use native scalar fma instruction (#1267)
Cranelift 0.87 now supports lowering `fma` as a libcall on x86 [0].
With 0.88 enabling the native x86 instruction under the `has_fma` flag.

aarch64 and s390x already support this as a native instruction, so it's
nice that we emit it for those.

We can't lower the SIMD version using the `fma` instruction since the
lowering can fail if the x86 `has_fma` flag is not enabled. Cranelift
doesn't yet know how to fallback for these cases

[0]: 709716bb8e
2022-08-23 12:42:35 +02:00
Afonso Bordado
156bda8bc7
Avoid masking shift amounts (#1268)
Cranelift 0.87 now follows its own documentation regarding
shift amounts, and implicitly masks them if the arch requires it. [0]

[0]: 0508932174
2022-08-23 12:42:24 +02:00
bjorn3
b14c7337db Update to Cranelift 0.87.0 2022-08-22 18:53:10 +00:00
Matthias Krüger
5a9b11648f Rollup merge of #100822 - WaffleLapkin:no_offset_question_mark, r=scottmcm
Replace most uses of `pointer::offset` with `add` and `sub`

As PR title says, it replaces `pointer::offset` in compiler and standard library with `pointer::add` and `pointer::sub`. This generally makes code cleaner, easier to grasp and removes (or, well, hides) integer casts.

This is generally trivially correct, `.offset(-constant)` is just `.sub(constant)`, `.offset(usized as isize)` is just `.add(usized)`, etc. However in some cases we need to be careful with signs of things.

r? ````@scottmcm````

_split off from #100746_
2022-08-21 16:54:07 +02:00
Waffle Maybe
5f357c2c51 fix cg cranelift
Co-authored-by: bjorn3 <17426603+bjorn3@users.noreply.github.com>
2022-08-21 05:27:14 +04:00
Waffle Maybe
63a137605f use shorter ptr_mask impl in cg cranelift
Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com>
2022-08-21 05:27:14 +04:00
Maybe Waffle
5b32aa0747 Add pointer masking convenience functions
This commit adds the following functions all of which have a signature
`pointer, usize -> pointer`:
- `<*mut T>::mask`
- `<*const T>::mask`
- `intrinsics::ptr_mask`

These functions are equivalent to `.map_addr(|a| a & mask)` but they
utilize `llvm.ptrmask` llvm intrinsic.

*masks your pointers*
2022-08-21 05:27:14 +04:00
Maybe Waffle
bd1ab72406 Replace most uses of pointer::offset with add and sub 2022-08-21 02:21:41 +04:00
bjorn3
7dc8f38956
Merge pull request #1266 from bjorn3/parallel_comp_refactor2
Refactorings for enabling parallel compilation (part 2)
2022-08-19 12:03:43 +02:00