Commit Graph

304 Commits

Author SHA1 Message Date
bors
f3284dc3ad Auto merge of #115260 - scottmcm:not-quite-so-cold, r=WaffleLapkin
Use `preserve_mostcc` for `extern "rust-cold"`

As experimentation in #115242 has shown looks better than `coldcc`.  Notably, clang exposes `preserve_most` (https://clang.llvm.org/docs/AttributeReference.html#preserve-most) but not `cold`, so this change should put us on a better-supported path.

And *don't* use a different convention for cold on Windows, because that actually ends up making things worse. (See comment in the code.)

cc tracking issue #97544
2023-08-29 02:23:43 +00:00
bors
9f48a85447 Auto merge of #115050 - khei4:khei4/codegen-move-before-nocapture, r=nikic
add codegen test for the move before passing to nocapture, by shared-ref arg

This PR adds codegen test for https://github.com/rust-lang/rust/issues/107436#issuecomment-1685792517 (It seems like this works from llvm-16?)

Fixes #107436
2023-08-28 15:30:28 +00:00
bors
668bf8c593 Auto merge of #115231 - saethlin:dont-ignore-wasm, r=Mark-Simulacrum
Remove some wasm/emscripten ignores

I'm planning on landing a few PRs like this that remove ignores that aren't required. This just covers mir-opt and codegen tests.
2023-08-27 17:51:50 +00:00
bors
f0727758d1 Auto merge of #115139 - cjgillot:llvm-fragment, r=nikic
Do not forget to pass DWARF fragment information to LLVM.

Fixes https://github.com/rust-lang/rust/issues/115113 for the rustc part
2023-08-27 14:06:57 +00:00
Matthias Krüger
ce7993670b
Rollup merge of #114957 - loongarch-rs:fix-tests, r=Mark-Simulacrum
tests: Fix tests for LoongArch64

This PR fixes `lp64d abi` tests for LoongArch64.
2023-08-27 09:45:18 +02:00
Scott McMurray
754f488d46 Use preserve_mostcc for extern "rust-cold"
As experimentation in 115242 has shown looks better than `coldcc`.

And *don't* use a different convention for cold on Windows, because that actually ends up making things worse.

cc tracking issue 97544
2023-08-26 17:42:59 -07:00
Camille GILLOT
5529e2f893 Restrict test to x86_64. 2023-08-26 22:55:52 +00:00
Camille GILLOT
930b2e72ee Do not produce fragment for ZST. 2023-08-26 16:54:28 +00:00
Camille GILLOT
f49494ecce Add test with non-ZST. 2023-08-26 14:21:10 +00:00
Camille GILLOT
b3bbc22cb7 Do not forget to pass DWARF fragment information to LLVM. 2023-08-26 14:21:10 +00:00
khei4
d88c80f5de add codegen test for #107436
remove trailing whitespace, add trailing newline

fix llvm version and function name
2023-08-26 18:14:47 +09:00
bors
42857db66d Auto merge of #115232 - wesleywiser:revert_114643, r=tmiasko
Revert "Use the same DISubprogram for each instance of the same inline function within the caller"

This reverts commit 687bffa493.

Reverting to resolve ICEs reported on nightly.

cc `@dpaoliello`

Fixes #115156
2023-08-26 07:47:26 +00:00
Scott McMurray
84e305dd93 Stop emitting non-power-of-two vectors in basic LLVM codegen 2023-08-25 20:06:57 -07: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
Ben Kimock
b678d40826 Remove some wasm/emscripten ignores 2023-08-25 19:48:20 -04:00
Ramon de C Valle
5d6e2d7050 Fix CFI: f32 and f64 are encoded incorrectly for c
Fix #115150 by encoding f32 and f64 correctly for cross-language CFI. I
missed changing the encoding for f32 and f64 when I introduced the
integer normalization option in #105452 as integer normalization does
not include floating point. `f32` and `f64` should be always encoded as
`f` and `d` since they are both FFI safe when their representation are
the same (i.e., IEEE 754) for both the Rust compiler and Clang.
2023-08-24 21:02:06 -07:00
bors
97fff1f2ed Auto merge of #114790 - taiki-e:asm-maybe-uninit, r=Amanieu
Allow MaybeUninit in input and output of inline assembly

**Motivation:**

As part of the work to remove UBs from crossbeam's AtomicCell, I'm writing a library to implement atomic operations on MaybeUnint using inline assembly ([atomic-maybe-uninit](https://github.com/taiki-e/atomic-maybe-uninit), https://github.com/crossbeam-rs/crossbeam/pull/1015).

However, currently, MaybeUnint cannot be used in input&output of inline assembly, so when processing MaybeUninit, values must be [passed through memory](https://github.com/taiki-e/atomic-maybe-uninit/blob/main/src/arch/aarch64.rs#L121-L122). It is inefficient and microbenchmarks have [actually shown significant performance degradation](https://github.com/crossbeam-rs/crossbeam/pull/1015#issuecomment-1676549870).

It would be nice if we could allow MaybeUninit in input and output of inline assembly.

---

This PR changed the type check in rustc_hir_analysis to allow `MaybeUnint<int | float | ptr | fn ptr | simd vector>` in input and output of inline assembly and added a simple test.

To be honest, I'm not sure that this is the correct way to do it, because this is like doing transmute to integers/floats/etc from MaybeUninit on the compiler side. EDIT: [this seems fine](https://rust-lang.zulipchat.com/#narrow/stream/216763-project-inline-asm/topic/MaybeUninit.20in.20asm!/near/384662900)

r? `@Amanieu`
cc `@thomcc` (because you [had previously proposed this](https://rust-lang.zulipchat.com/#narrow/stream/216763-project-inline-asm/topic/MaybeUninit.20in.20asm!))
2023-08-23 13:40:41 +00:00
Taiki Endo
03fd2d4379 Allow MaybeUninit in input and output of inline assembly 2023-08-23 21:57:18 +09:00
Dylan DPC
391cbdaa7c
Rollup merge of #115096 - kadiwa4:no_memcpy_padding, r=cjgillot
Add regression test for not `memcpy`ing padding bytes

Closes #56297

See this comparison: https://rust.godbolt.org/z/jjzfonfcE

I don't have any experience with codegen tests, I hope this is correct
2023-08-23 05:35:17 +00: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
kadiwa
265c1b5d50
add regression test for not memcpying padding bytes 2023-08-22 15:10:56 +02:00
WANG Rui
126f4abd8b tests: Fix tests for LoongArch64 2023-08-18 14:56:53 +08:00
Camille GILLOT
3798bca605 Bless codegen tests. 2023-08-17 18:28:33 +00:00
bors
1ec628d7fa Auto merge of #114850 - khei4:khei4/trailing_zero_codegen, r=nikic
add codegen test for `trailing_zeros` comparison

This PR add codegen test for
https://github.com/rust-lang/rust/issues/107554#issuecomment-1677369236

Fixes #107554.
2023-08-16 11:07:13 +00:00
khei4
8d514f2e98 add codegen test for issue 107554
specify llvm-version and bit width for int arg

add missing percent simbol
2023-08-16 14:04:05 +09:00
DianQK
c12c0841ad Cherry-pick test for issue #114312 2023-08-15 11:33:45 +02:00
DianQK
6f5b4e3581
Add test for method debuginfo declaration.
We've investigated one reason why debugging information often goes wrong at https://reviews.llvm.org/D152095.
> LLVM can't handle IR where subprogram definitions are nested within DICompositeType when doing LTO builds,
> because there's no good way to cross the CU boundary to insert a nested DISubprogram definition in one CU into a type defined in another CU.
2023-08-12 21:27:46 +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
Scott McMurray
ab6e2bc3d0 Tell LLVM that the negation in <*const T>::sub cannot overflow
Today it's just `sub` <https://rust.godbolt.org/z/8EzEPnMr5>; with this PR it's `sub nsw`.
2023-08-10 23:00:39 -07:00
Matthias Krüger
06daa9e263
Rollup merge of #114562 - Trolldemorted:thiscall, r=oli-obk
stabilize abi_thiscall

Closes https://github.com/rust-lang/rust/issues/42202, stabilizing the use of the "thiscall" ABI.

FCP was substituted by a poll, and the poll has been accepted.
2023-08-07 16:47:57 +02:00
Benedikt Radtke
3f3262e592 stabilize abi_thiscall 2023-08-07 14:11:03 +02: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
Matthias Krüger
fe1c3a1a5e
Rollup merge of #114230 - workingjubilee:codegen-tests-that-nest, r=Mark-Simulacrum
Nest other codegen test topics

This PR is like rust-lang/rust#114229 in that it mostly pushes codegen tests around, shoving them into their own directories, but because all of the changes are very simple cleanups I pulled them into a separate PR. The other PR might involve actually evaluating the correctness of the test after changes, but here it is mostly a matter of taste. The only "functional" change is deleting a few tests that... hinge on a version of LLVM that we don't support (as of rust-lang/rust#114148 anyways).

I considered a few different ways to group other topics but I feel the question of whether `tests/codegen/{vec,array,slice}` should exist is more subtle than these choices, as it might be better to group such related tests by other topics like bounds check elision, thus I avoided making it.
2023-08-07 05:29:11 +02:00
Matthias Krüger
137177386b
Rollup merge of #114229 - workingjubilee:nest-sanitizer-dir, r=Mark-Simulacrum
Nest tests/codegen/sanitizer*.rs tests in sanitizer dir

The sanitizer tests are the largest and most meticulously tested set of tests in tests/codegen. That's good! They all clearly belong to a subject and thus could go in a directory, but are not, instead being placed simply in tests/codegen. That's bad! Fix this by placing them in their own directory and renaming them to be less repetitive after that move.

A few tests are brittle, and embed their filename in the test's checks. This is acceptable for the ones where it is used only two times, but one test embeds the test's mangled filename in the test *over 50 times*! This may have been one of the things discouraging anyone from moving it, and thus from moving the set. Fortunately, I have some knowledge of Itanium mangling (involuntarily), regex, and the FileCheck syntax. With a capturing variable, FileCheck allows us to now move this test around again without diffing it on ~50 lines, while still guaranteeing that the mangled substring is the same each time.

This also clarifies why the substring is repeated a zillion times, instead of being cryptic. They don't call it mangling because the result is pretty and easy to understand, but now it is slightly easier! Yay descriptive variables!
2023-08-07 05:29:10 +02:00
Scott McMurray
502af03445 Add a new compare_bytes intrinsic instead of calling memcmp directly 2023-08-06 15:47:40 -07: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
Jubilee Young
c81d3e23d1 Remove LLVM 14 codegen tests
We raised our LLVM minimum to 15, so these tests seem pointless.
2023-07-29 18:34:41 -07:00
Jubilee Young
f03b31591c tests/codegen/c-variadic* -> cffi/c-variadic* 2023-07-29 18:34:41 -07:00
Jubilee Young
badba92036 tests/codegen/ffi-* -> cffi/ffi-* 2023-07-29 18:34:41 -07:00
Jubilee Young
0ca0556651 tests/codegen/naked-* -> naked-fn/naked-* 2023-07-29 18:34:41 -07:00
Jubilee Young
45c284cd98 tests/codegen/*simd*.rs -> simd/*simd* 2023-07-29 18:34:41 -07:00
Jubilee Young
df2264a284 tests/codegen/*-macos-* -> macos/* 2023-07-29 18:34:41 -07:00
Jubilee Young
06711615aa tests/codegen/enum-* -> enum/enum-* 2023-07-29 18:34:41 -07:00
Jubilee Young
4d2957cfdf Fix sanitizer tests depending on filename
In the basic case, simply do the string substitution.
For one case with many instances, capture the Itanium-
mangled filename and assert its reuse instead.
2023-07-29 18:09:48 -07:00
Jubilee Young
0f534d06a8 tests/codegen/sanitizer{-,_}* -> sanitizer/* 2023-07-29 17:34:16 -07:00
Jubilee Young
20ebbf467d Replace ignore-everything with only-arch
Combining revisions with only-arch allows specifying
that a test only applies to a handful of targets.
This allows removing a large amount of repetition
in the test suite for tests that do not benefit.
The revisions are suboptimal for this for some tests,
so they aren't preferred in those cases.
2023-07-29 15:49:07 -07:00
Jubilee Young
040bc3447e mv tests/codegen/repr-* tests/codegen/repr
Slightly more complicated: also give them appropriate names
that somewhat describe the cases they are trying to cover,
using information from PR chatter in rust-lang/rust#47158
2023-07-29 15:35:36 -07:00
Jubilee Young
b2375fb9e2 Ignore an AVR-inapplicable test 2023-07-29 15:21:49 -07:00
Erik Desjardins
55800123b7 cg_llvm: simplify llvm.masked.gather/scatter naming with opaque pointers
With opaque pointers, there's no longer a need to generate a chain
of pointer types in the intrinsic name when arguments are pointers to
pointers.
2023-07-29 16:56:27 -04:00
Josh Stone
da47736f42 CHECK only for opaque ptr 2023-07-27 14:44:13 -07:00