Commit Graph

306 Commits

Author SHA1 Message Date
Mark Rousskov
db3e2bacb6 Bump cfg(bootstrap)s 2023-11-15 19:41:28 -05:00
Ralf Jung
5b5006916b target_feature: make it more clear what that 'Option' means 2023-11-12 12:46:05 +01:00
Guillaume Gomez
43290933a4 Remove libc dependency in cg_gcc alloc_system example 2023-11-02 21:03:27 +01:00
Guillaume Gomez
edfd67b598 Pass --sysroot option 2023-11-02 21:03:27 +01:00
Guillaume Gomez
3c58feaa08 Fix config.sh script 2023-11-02 21:03:27 +01:00
Guillaume Gomez
ded81de066 Fix compilation errors in rustc_codegen_gcc examples 2023-11-02 21:03:27 +01:00
Guillaume Gomez
42bdc873e5 Disable master feature by default when building rustc_codegen_gcc 2023-11-02 21:03:27 +01:00
Antoni Boucher
f0aaf2ff11 Merge commit '09ce29d0591a21e1abae22eac4d41ffd32993af8' into subtree-update_cg_gcc_2023-10-25 2023-10-27 16:07:01 -04:00
Antoni Boucher
c797cccda6 Merge commit 'e4fe941b11a55c5005630696e9b6d81c65f7bd04' into subtree-update_cg_gcc_2023-10-25 2023-10-26 17:42:02 -04:00
Oli Scherer
e96ce20b34 s/generator/coroutine/ 2023-10-20 21:14:01 +00:00
Oli Scherer
60956837cf s/Generator/Coroutine/ 2023-10-20 21:10:38 +00:00
Michael Howell
2ff2624722 docs: add Rust logo to more compiler crates
c6e6ecb1af added it to some of the
compiler's crates, but avoided adding it to all of them to reduce
bit-rot. This commit adds to more.
2023-10-16 15:38:08 -07:00
Antoni Boucher
06c5ac4761 Use IntoDynSyncSend 2023-10-09 17:13:35 -04:00
Antoni Boucher
2cbac9c636 Fix checks 2023-10-09 16:03:05 -04:00
Antoni Boucher
30290c8b41 Merge commit '11a0cceab966e5ff1058ddbcab5977e8a1d6d290' into subtree-update_cg_gcc_2023-10-09 2023-10-09 15:53:34 -04:00
bors
2e5a9dd6c9 Auto merge of #102099 - InnovativeInventor:re-cold-land, r=nikic
Rebased: Mark drop calls in landing pads cold instead of noinline

I noticed that certain inlining optimizations were missing while staring at some compiled code output. I'd like to see this relanded, so I rebased the PR from `@erikdesjardins` (PR #94823).

This PR reapplies https://github.com/rust-lang/rust/pull/92419, which was reverted in https://github.com/rust-lang/rust/pull/94402 due to https://github.com/rust-lang/rust/issues/94390.

Fixes https://github.com/rust-lang/rust/issues/46515, fixes https://github.com/rust-lang/rust/issues/87055.

Update: fixes #97217.
2023-10-02 22:02:12 +00:00
Erik Desjardins
31ee8b1818 Reapply: Mark drop calls in landing pads cold instead of noinline
Co-authored-by: Max Fan <git@max.fan>
Co-authored-by: Nikita Popov <npopov@redhat.com>
2023-10-02 10:37:53 +02:00
bors
781ebbec8a Auto merge of #115898 - onur-ozkan:config-change-tracking, r=Mark-Simulacrum
bootstrap major change detection implementation

The use of `changelog-seen` and `bootstrap/CHANGELOG.md` has not been functional in any way for many years. We often do major/breaking changes but never update the changelog file or the `changelog-seen`. This is an alternative method for tracking major or breaking changes and informing developers when such changes occur.

Example output when bootstrap detects a major change:
![image](https://github.com/rust-lang/rust/assets/39852038/ee802dfa-a02b-488b-a433-f853ce079b8a)
2023-10-02 07:41:52 +00:00
onur-ozkan
957de61594 implement major change tracking for the bootstrap configuration
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2023-10-01 16:54:52 +03:00
Oli Scherer
2ba911c832 Have a single struct for queries and hook 2023-09-22 16:26:20 +00:00
Oli Scherer
2157f31731 Add a way to decouple the implementation and the declaration of a TyCtxt method. 2023-09-22 09:23:15 +00:00
Ralf Jung
29a4b7b971 fix gcc, cranelift build 2023-09-15 10:43:44 +02:00
Ralf Jung
89139d4c46 clarify PassMode::Indirect as well 2023-09-15 10:43:44 +02:00
Deadbeef
a0a801cd38 treat host effect params as erased generics in codegen
This fixes the changes brought to codegen tests when effect params are
added to libcore, by not attempting to monomorphize functions that get
the host param by being `const fn`.
2023-09-14 07:34:35 +00:00
Daniel Paoliello
06890774ab Deduplicate inlined function debug info, but create a new lexical scope to child subsequent scopes and variables from colliding 2023-09-01 14:27:21 -07:00
Matthias Krüger
56d7d93a4b
Rollup merge of #111580 - atsuzaki:layout-ice, r=oli-obk
Don't ICE on layout computation failure

Fixes #111176 regression.

r? `@oli-obk`
2023-08-29 20:49:02 +02:00
Katherine Philip
56b767322b Don't ICE on layout computation failure 2023-08-28 12:40:39 -07:00
Matthias Krüger
a5b7504f41
Rollup merge of #115240 - RalfJung:llvm-no-type, r=bjorn3
codegen_llvm/llvm_type: avoid matching on the Rust type

This `match` is highly suspicious. Looking at `scalar_llvm_type_at` I think it makes no difference. But if it were to make a difference that would be a huge problem, since it doesn't look through `repr(transparent)`!

Cc `@eddyb` `@bjorn3`
2023-08-28 19:53:55 +02:00
Ralf Jung
9b9cb51a40 remove an unused argument
it was already unused before, but due to the recursion the compiler did not realize
2023-08-28 18:21:16 +02:00
Ralf Jung
99d76a4027 carry out the same changes in the gcc backend 2023-08-28 16:35:22 +02:00
Wesley Wiser
d0b2c4f727 Revert "Use the same DISubprogram for each instance of the same inlined function within the caller"
This reverts commit 687bffa493.

Reverting to resolve ICEs reported on nightly.
2023-08-25 19:49:10 -04:00
bors
154ae32a55 Auto merge of #114643 - dpaoliello:inlinedebuginfo, r=wesleywiser
Use the same DISubprogram for each instance of the same inlined function within a caller

# Issue Details:
The call to `panic` within a function like `Option::unwrap` is translated to LLVM as a `tail call` (as it will never return), when multiple calls to the same function like this is inlined LLVM will notice the common `tail call` block (i.e., loading the same panic string + location info and then calling `panic`) and merge them together.

When merging these instructions together, LLVM will also attempt to merge the debug locations as well, but this fails (i.e., debug info is dropped) as Rust emits a new `DISubprogram` at each inline site thus LLVM doesn't recognize that these are actually the same function and so thinks that there isn't a common debug location.

As an example of this when building for x86_64 Windows (note the lack of `.cv_loc` before the call to `panic`, thus it will be attributed to the same line at the `addq` instruction):

```
	.cv_loc	0 1 23 0                        # src\lib.rs:23:0
	addq	$40, %rsp
	retq
	leaq	.Lalloc_f570dea0a53168780ce9a91e67646421(%rip), %rcx
	leaq	.Lalloc_629ace53b7e5b76aaa810d549cc84ea3(%rip), %r8
	movl	$43, %edx
	callq	_ZN4core9panicking5panic17h12e60b9063f6dee8E
	int3
```

# Fix Details:
Cache the `DISubprogram` emitted for each inlined function instance within a caller so that this can be reused if that instance is encountered again, this also requires caching the `DILexicalBlock` and `DIVariable` objects to avoid creating duplicates.

After this change the above assembly now looks like:

```
	.cv_loc	0 1 23 0                        # src\lib.rs:23:0
	addq	$40, %rsp
	retq
	.cv_inline_site_id 5 within 0 inlined_at 1 0 0
	.cv_inline_site_id 6 within 5 inlined_at 1 12 0
	.cv_loc	6 2 935 0                       # library\core\src\option.rs:935:0
	leaq	.Lalloc_5f55955de67e57c79064b537689facea(%rip), %rcx
	leaq	.Lalloc_e741d4de8cb5801e1fd7a6c6795c1559(%rip), %r8
	movl	$43, %edx
	callq	_ZN4core9panicking5panic17hde1558f32d5b1c04E
	int3
```
2023-08-22 20:15:29 +00:00
bors
c1699a79a6 Auto merge of #114467 - Amanieu:asm-unstable-features, r=davidtwco
Use `unstable_target_features` when checking inline assembly

This is necessary to properly validate register classes even when the relevant target feature name is still unstable.
2023-08-15 11:59:02 +00:00
Dirreke
d16409fe22 add a csky-unknown-linux-gnuabiv2 target 2023-08-14 23:02:36 +08:00
Daniel Paoliello
687bffa493 Use the same DISubprogram for each instance of the same inlined function within the caller 2023-08-11 10:21:52 -07:00
Matthias Krüger
cbe2522652
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
75277a6606 Apply suggestions from code review
Co-authored-by: Ralf Jung <post@ralfj.de>
2023-08-06 15:47:40 -07:00
Scott McMurray
502af03445 Add a new compare_bytes intrinsic instead of calling memcmp directly 2023-08-06 15:47:40 -07:00
David Tolnay
704aa56ba0
Generate better function argument names in global_allocator expansion 2023-08-06 07:36:05 -07:00
Matthias Krüger
a0fd747e38
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
3d25b5c7e8 Fix ICE failed to get layout for ReferencesError 2023-08-05 01:38:14 +08:00
Amanieu d'Antras
a3ab31c0f9 Use unstable_target_features when checking inline assembly
This is necessary to properly validate register classes even when the
relevant target feature name is still unstable.
2023-08-04 16:09:54 +01:00
Oli Scherer
4457ef2c6d Forbid old-style simd_shuffleN intrinsics 2023-08-03 09:29:00 +00:00
bors
abd3637e42 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
3b44f5b0eb Use standard Rust capitalization rules for names containing "LTO". 2023-07-31 16:21:02 +10:00
Erik Desjardins
04303cfb3a cg_ssa: remove pointee types and pointercast/bitcast-of-ptr 2023-07-29 13:18:20 -04:00
bors
f475098ffd 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 7a888fb56e
2023-07-24 11:29:59 +00:00
David Tolnay
5bbf0a8306
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
557359f925 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
Matthias Krüger
2734b5ada9
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