Commit Graph

125 Commits

Author SHA1 Message Date
Tomasz Miąsko 3b7ca287a7 Describe lifetime of call argument temporaries passed indirectly 2025-05-17 09:49:03 +02:00
Matthias Krüger a8ebfb256a Rollup merge of #139261 - RalfJung:msvc-align-mitigation, r=oli-obk
mitigate MSVC alignment issue on x86-32

This implements mitigation for https://github.com/rust-lang/rust/issues/112480 by stopping to emit `align` attributes on loads and function arguments when building for a win32 MSVC target. MSVC is known to not properly align `u64` and similar types, and claiming to LLVM that everything is properly aligned increases the chance that this will cause problems.

Of course, the misalignment is still a bug, but we can't fix that bug, only MSVC can.

Also add an errata note to the platform support page warning users about this known problem.

try-job: `i686-msvc*`
2025-04-24 11:40:35 +02:00
Augie Fackler d3b167493e tests: adjust 101082 test for LLVM 21 fix
Fixes #139987.
2025-04-17 15:11:21 -04:00
bors 1bc56185ee Auto merge of #139430 - scottmcm:polymorphic-array-into-iter, r=cuviper
Polymorphize `array::IntoIter`'s iterator impl

Today we emit all the iterator methods for every different array width.  That's wasteful since the actual array length never even comes into it -- the indices used are from the separate `alive: IndexRange` field, not even the `N` const param.

This PR switches things so that an `array::IntoIter<T, N>` stores a `PolymorphicIter<[MaybeUninit<T>; N]>`, which we *unsize* to `PolymorphicIter<[MaybeUninit<T>]>` and call methods on that non-`Sized` type for all the iterator methods.

That also necessarily makes the layout consistent between the different lengths of arrays, because of the unsizing.  Compare that to today <https://rust.godbolt.org/z/Prb4xMPrb>, where different widths can't even be deduped because the offset to the indices is different for different array widths.
2025-04-11 23:21:31 +00:00
Pietro Albini cd371b90e2 replace //@ compile-flags: --edition with //@ edition 2025-04-10 09:56:37 +02:00
Scott McMurray 4207c786e7 PR feedback 2025-04-09 21:44:59 -07:00
Ralf Jung 2678d04dd9 mitigate MSVC unsoundness by not emitting alignment attributes on win32-msvc targets
also mention the MSVC alignment issue in platform-support.md
2025-04-07 23:30:55 +02:00
Stuart Cook f4aa209e20 Rollup merge of #139438 - Zalathar:fix-test-122600, r=scottmcm
Prevent a test from seeing forbidden numbers in the rustc version

The final CHECK-NOT directive in this test was able to see past the end of the enclosing function, and find the substring `753` or `754` in the git hash in the rustc version number, causing false failures in CI whenever the git hash happens to contain those digits in sequence.

Adding an explicit check for `ret` prevents the CHECK-NOT directive from seeing past the end of the function.

---

Manually tested by adding `// CHECK-NOT: rustc` after the existing CHECK-NOT directives, and demonstrating that the new check prevents it from seeing the rustc version string.
2025-04-06 16:21:03 +10:00
Zalathar f6afb35c61 Prevent a test from seeing forbidden numbers in the rustc version
The final CHECK-NOT directive in this test was able to see past the end of the
enclosing function, and find the substring 753 or 754 in the git hash in the
rustc version number, causing false failures in CI.

Adding an explicit check for `ret` prevents the CHECK-NOT directive from seeing
past the end of the function.
2025-04-06 12:38:20 +10:00
Scott McMurray e30cb329d8 Polymorphize array::IntoIter's iterator impl 2025-04-05 17:55:24 -07:00
Josh Stone 12167d7064 Update the minimum external LLVM to 19 2025-04-05 11:44:38 -07:00
KonaeAkira ccde0a2203 Fix formatting (line too long) 2025-03-14 01:45:10 +01:00
KonaeAkira 82a79b99e1 Add codegen test for modulo with power-of-two divisor 2025-03-14 01:27:07 +01:00
Matthias Krüger 827bb5e27b Rollup merge of #122790 - Zoxc:dllimp-rev, r=ChrisDenton
Apply dllimport in ThinLTO

This partially reverts https://github.com/rust-lang/rust/pull/103353 by properly applying `dllimport` if  `-Z dylib-lto` is passed. That PR should probably fully be reverted as it looks quite sketchy. We don't know locally if the entire crate graph would be statically linked.

This should hopefully be sufficient to make ThinLTO work for rustc on Windows.

r? ``@wesleywiser``

---

Edit: This PR is changed to just generally revert https://github.com/rust-lang/rust/pull/103353.
2025-03-09 16:41:48 +01:00
Scott McMurray d9432acfe1 Use trunc nuw+br for 0/1 branches even in optimized builds
Rather than needing to use `switch` for them to include the `unreachable` arm
2025-03-06 22:25:49 -08:00
John Kåre Alsaker cc39e5f266 Apply dllimport in ThinLTO 2025-03-03 13:44:53 +01:00
Matthias Krüger 15e97bd45e Rollup merge of #137826 - karolzwolak:looping_over_ne_bytes_133528, r=DianQK
test(codegen): add looping_over_ne_bytes test for #133528

Adds test for #133528.
I renamed the function to `looping_over_ne_bytes` to better reflect that it is doing.
I also set the min llvm version to 20 as this was presumably a llvm bug that was fixed in version 20.
I didn't tie the test to any specific architecture, as we are testing llvm output.
2025-03-03 06:41:36 +01:00
Matthias Krüger 224ea37aa3 Rollup merge of #137818 - durin42:llvm-21-remove-readonly, r=jieyouxu
tests: adapt for LLVM 21 changes

Per discussion in #137799 we don't really need this readonly attribute, so let's just drop it so the test passes on LLVM 21.

Fixes #137799.
2025-03-01 16:03:15 +01:00
Karol Zwolak 107d7ef767 test(codegen): add looping_over_ne_bytes test for #133528 2025-02-28 22:37:56 +01:00
Augie Fackler 2d3639d559 tests: adapt for LLVM 21 changes
Per discussion in #137799 we don't really need this readonly attribute,
so let's just drop it so the test passes on LLVM 21.

Fixes #137799.
2025-02-28 14:27:22 -05:00
Folkert de Vries 038f4e2ff6 use the right feature in codegen tests 2025-02-27 12:23:00 +01:00
Folkert de Vries d8a067b931 remove most simd_ intrinsic declaration in tests
instead, we can just import the intrinsics from core
2025-02-27 12:22:59 +01:00
许杰友 Jieyou Xu (Joe) e15ce94eae tests: tighten CHECK-NOTs to make str-to-string-128690.rs less likely to collide with symbol name mangling 2025-02-24 01:17:32 +08:00
Ralf Jung 803feb5dc6 x86-sse2 ABI: use SSE registers for floats and SIMD 2025-02-18 16:11:41 +01:00
Scott McMurray 9ad6839f7a Set both nuw and nsw in slice size calculation
There's an old note in the code to do this, and now that LLVM-C has an API for it, we might as well.
2025-02-13 21:26:48 -08:00
Jubilee Young 3c0c9b6770 tests/codegen: use -Copt-level=3 instead of -O 2025-02-11 13:41:35 -08:00
Jubilee Young 3580698996 tests: issue-122805 -> dont-shuffle-bswaps 2025-02-09 16:54:02 -08:00
clubby789 2c35bd0499 #[optimize(none)] implies #[inline(never)] 2025-01-31 17:51:49 +00:00
许杰友 Jieyou Xu (Joe) 5415f067bd Explicitly register MSVC/NONMSVC revisions for some codegen tests 2024-12-19 20:36:51 +08:00
Josh Triplett a105cd6066 Use field init shorthand where possible
Field init shorthand allows writing initializers like `tcx: tcx` as
`tcx`. The compiler already uses it extensively. Fix the last few places
where it isn't yet used.
2024-12-17 14:33:10 -08:00
Tim Neumann 8f0ea9a7be Adapt codegen tests for NUW inference 2024-12-05 16:08:41 +01:00
bors 8575f8f91b Auto merge of #104342 - mweber15:add_file_location_to_more_types, r=wesleywiser
Require `type_map::stub` callers to supply file information

This change attaches file information (`DIFile` reference and line number) to struct debug info nodes.

Before:

```
; foo.ll
...
!5 = !DIFile(filename: "<unknown>", directory: "")
...
!16 = !DICompositeType(tag: DW_TAG_structure_type, name: "MyType", scope: !2, file: !5, size: 32, align: 32, elements: !17, templateParams: !19, identifier: "4cb373851db92e732c4cb5651b886dd0")
...
```

After:

```
; foo.ll
...
!3 = !DIFile(filename: "foo.rs", directory: "/home/matt/src/rust98678", checksumkind: CSK_SHA1, checksum: "bcb9f08512c8f3b8181ef4726012bc6807bc9be4")
...
!16 = !DICompositeType(tag: DW_TAG_structure_type, name: "MyType", scope: !2, file: !3, line: 3, size: 32, align: 32, elements: !17, templateParams: !19, identifier: "9e5968c7af39c148acb253912b7f409f")
...
```

Fixes #98678

r? `@wesleywiser`
2024-12-03 12:49:57 +00:00
Matt Weber e9fbb6f271 Fix tests when using MinGW 2024-12-02 21:59:34 -05:00
Mark Rousskov 4a216a25d1 Share inline(never) generics across crates
This reduces code sizes and better respects programmer intent when
marking inline(never). Previously such a marking was essentially ignored
for generic functions, as we'd still inline them in remote crates.
2024-11-28 13:43:05 -05:00
Matt Weber d151593781 Fix relative lines in coroutine test 2024-11-06 22:26:18 -05:00
Wesley Wiser 64dd582166 Use -DAG to handle use of file before definition
Also fixup the test assertion for msvc and unix
2024-11-06 22:26:18 -05:00
Matt Weber 613ddc199d Restructure compile-flags for tests
Optimization needs to be explicitly disabled now.
2024-11-06 22:26:18 -05:00
Matt Weber 7329111466 Update compile flags formatting 2024-11-06 22:26:18 -05:00
Matt Weber 8200068a1d Rename generator test file 2024-11-06 22:26:18 -05:00
Matt Weber 21c58b1b2c Rename option and add doc 2024-11-06 22:26:18 -05:00
Matt Weber a4833a8089 Move additional source location info behind -Z option 2024-11-06 22:26:17 -05:00
Matt Weber b6659b0621 Move tests into issues directory 2024-11-06 22:26:17 -05:00
Veera d2aa91054b Add a Few Codegen Tests 2024-11-02 05:33:56 +00:00
Ralf Jung 56ee492a6e move strict provenance lints to new feature gate, remove old feature gates 2024-10-21 15:22:17 +01:00
clubby789 aa299a9bdf Add codegen test for branchy bool match 2024-10-19 10:05:25 +00:00
Josh Stone 5365b3f7be Avoid superfluous UB checks in IndexRange
`IndexRange::len` is justified as an overall invariant, and
`take_prefix` and `take_suffix` are justified by local branch
conditions. A few more UB-checked calls remain in cases that are only
supported locally by `debug_assert!`, which won't do anything in
distributed builds, so those UB checks may still be useful.

We generally expect core's `#![rustc_preserve_ub_checks]` to optimize
away in user's release builds, but the mere presence of that extra code
can sometimes inhibit optimization, as seen in #131563.
2024-10-11 16:22:43 -07:00
Jörn Horstmann e393f56d37 Improve autovectorization of to_lowercase / to_uppercase functions
Refactor the code in the `convert_while_ascii` helper function to make
it more suitable for auto-vectorization and also process the full ascii
prefix of the string. The generic case conversion logic will only be
invoked starting from the first non-ascii character.

The runtime on microbenchmarks with ascii-only inputs improves between
1.5x for short and 4x for long inputs on x86_64 and aarch64.

The new implementation also encapsulates all unsafe inside the
`convert_while_ascii` function.

Fixes #123712
2024-09-23 11:31:29 +02:00
Jubilee Young ff3a9f4e2a tests: Remove spuriously failing vec-tryinto-array codegen test 2024-09-22 16:46:10 -07:00
Guillaume Gomez bf6389f077 Rollup merge of #128209 - beetrees:no-macos-10.10, r=jieyouxu
Remove macOS 10.10 dynamic linker bug workaround

Rust's current minimum macOS version is 10.12, so the hack can be removed. This PR also updates the `remove_dir_all` docs to reflect that all supported macOS versions are protected against TOCTOU race conditions (the fallback implementation was already removed in #127683).

try-job: dist-x86_64-apple
try-job: dist-aarch64-apple
try-job: dist-apple-various
try-job: aarch64-apple
try-job: x86_64-apple-1
2024-09-20 19:46:37 +02:00
Josh Stone 6fd8a50680 Update the minimum external LLVM to 18 2024-09-18 13:53:31 -07:00