about summary refs log tree commit diff
path: root/tests/codegen
AgeCommit message (Collapse)AuthorLines
2024-06-02Test codegen for repr(packed,simd) -> repr(simd)Jubilee Young-0/+44
2024-06-02Rollup merge of #125311 - calebzulawski:repr-packed-simd-intrinsics, ↵Jubilee-0/+44
r=workingjubilee Make repr(packed) vectors work with SIMD intrinsics In #117116 I fixed `#[repr(packed, simd)]` by doing the expected thing and removing padding from the layout. This should be the last step in providing a solution to rust-lang/portable-simd#319
2024-06-02Test codegen for repr(packed,simd)Jubilee Young-0/+44
2024-06-02Auto merge of #124294 - tspiteri:ilog-first-iter, r=the8472bors-0/+20
Unroll first iteration of checked_ilog loop This follows the optimization of #115913. As shown in https://github.com/rust-lang/rust/pull/115913#issuecomment-2066788006, the performance was improved in all important cases, but some regressions were introduced for the benchmarks `u32_log_random_small`, `u8_log_random` and `u8_log_random_small`. Basically, #115913 changed the implementation from one division per iteration to one multiplication per iteration plus one division. When there are zero iterations, this is a regression from zero divisions to one division. This PR avoids this by avoiding the division if we need zero iterations by returning `Some(0)` early. It also reduces the number of multiplications by one in all other cases.
2024-05-31Run rustfmt on `tests/codegen/`.Nicholas Nethercote-1334/+1447
Except for `simd-intrinsic/`, which has a lot of files containing multiple types like `u8x64` which really are better when hand-formatted. There is a surprising amount of two-space indenting in this directory. Non-trivial changes: - `rustfmt::skip` needed in `debug-column.rs` to preserve meaning of the test. - `rustfmt::skip` used in a few places where hand-formatting read more nicely: `enum/enum-match.rs` - Line number adjustments needed for the expected output of `debug-column.rs` and `coroutine-debug.rs`.
2024-05-29Rollup merge of #124655 - Darksonn:fixed-x18, r=lqd,estebankMatthias Krüger-0/+22
Add `-Zfixed-x18` This PR is a follow-up to #124323 that proposes a different implementation. Please read the description of that PR for motivation. See the equivalent flag in [the clang docs](https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-ffixed-x18). MCP: https://github.com/rust-lang/compiler-team/issues/748 Fixes https://github.com/rust-lang/rust/issues/121970 r? rust-lang/compiler
2024-05-29Rollup merge of #125226 - madsmtm:fix-mac-catalyst-tests, r=workingjubilee许杰友 Jieyou Xu (Joe)-9/+8
Make more of the test suite run on Mac Catalyst Combined with https://github.com/rust-lang/rust/pull/125225, the only failing parts of the test suite are in `tests/rustdoc-js`, `tests/rustdoc-js-std` and `tests/debuginfo`. Tested with: ```console ./x test --target=aarch64-apple-ios-macabi library/std ./x test --target=aarch64-apple-ios-macabi --skip=tests/rustdoc-js --skip=tests/rustdoc-js-std --skip=tests/debuginfo tests ``` Will probably put up a PR later to enable _running_ on (not just compiling for) Mac Catalyst in CI, though not sure where exactly I should do so? `src/ci/github-actions/jobs.yml`? Note that I've deliberately _not_ enabled stack overflow handlers on iOS/tvOS/watchOS/visionOS (see https://github.com/rust-lang/rust/issues/25872), but rather just skipped those tests, as it uses quite a few APIs that I'd be weary about getting rejected by the App Store (note that Swift doesn't do it on those platforms either). r? ``@workingjubilee`` CC ``@thomcc`` ``@rustbot`` label O-ios O-apple
2024-05-29Rollup merge of #124251 - scottmcm:unop-ptr-metadata, r=oli-obk许杰友 Jieyou Xu (Joe)-0/+36
Add an intrinsic for `ptr::metadata` The follow-up to #123840, so we can remove `PtrComponents` and `PtrRepr` from libcore entirely (well, after a bootstrap update). As discussed in <https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/.60ptr_metadata.60.20in.20MIR/near/435637808>, this introduces `UnOp::PtrMetadata` taking a raw pointer and returning the associated metadata value. By no longer going through a `union`, this should also help future PRs better optimize pointer operations. r? ``@oli-obk``
2024-05-28Add an intrinsic for `ptr::metadata`Scott McMurray-0/+36
2024-05-28Auto merge of #122662 - Mark-Simulacrum:optional-drop, r=bjorn3bors-0/+16
Omit non-needs_drop drop_in_place in vtables This replaces the drop_in_place reference with null in vtables. On librustc_driver.so, this drops about ~17k (11%) dynamic relocations from the output, since many vtables can now be placed in read-only memory, rather than having a relocated pointer included. This makes a tradeoff by adding a null check at vtable call sites. I'm not sure that's readily avoidable without changing the vtable format (e.g., so that we can use a pc-relative relocation instead of an absolute address, and avoid the dynamic relocation that way). But it seems likely that the check is cheap at runtime. Accepted MCP: https://github.com/rust-lang/compiler-team/issues/730
2024-05-28Bless codegen testOli Scherer-21/+23
2024-05-28Make more of the test suite run on Mac CatalystMads Marquart-9/+8
This adds the `only-apple`/`ignore-apple` compiletest directive, and uses that basically everywhere instead of `only-macos`/`ignore-macos`. Some of the updates in `run-make` are a bit redundant, as they use `ignore-cross-compile` and won't run on iOS - but using Apple in these is still more correct, so I've made that change anyhow.
2024-05-27Omit non-needs_drop drop_in_place in vtablesMark Rousskov-0/+16
This replaces the drop_in_place reference with null in vtables. On librustc_driver.so, this drops about ~17k dynamic relocations from the output, since many vtables can now be placed in read-only memory, rather than having a relocated pointer included. This makes a tradeoff by adding a null check at vtable call sites. That's hard to avoid without changing the vtable format (e.g., to use a pc-relative relocation instead of an absolute address, and avoid the dynamic relocation that way). But it seems likely that the check is cheap at runtime.
2024-05-23Rollup merge of #125222 - Oneirical:fifth, r=jieyouxuMatthias Krüger-0/+21
Migrate `run-make/issue-46239` to `rmake` Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).
2024-05-22rewrite and rename issue-46239Oneirical-0/+21
2024-05-21Auto merge of #125298 - tesuji:arrcmp, r=nikicbors-0/+18
Add codegen test for array comparision opt Fixed since rust 1.55 closes #62531
2024-05-21Add codegen test for array comparision optLzu Tao-0/+18
2024-05-20add codegen test for issue 120493Joshua Wong-0/+22
2024-05-18Rollup merge of #125184 - scottmcm:fix-thin-ptr-ice, r=jieyouxuMatthias Krüger-0/+23
Fix ICE in non-operand `aggregate_raw_ptr` intrinsic codegen Introduced in #123840 Found in #121571, cc `@clarfonthey`
2024-05-16Fix ICE in non-operand `aggregate_raw_ptr` instrinsic codegenScott McMurray-0/+23
2024-05-16Fix assertion when attempting to convert `f16` and `f128` with `as`Trevor Gross-3/+393
These types are currently rejected for `as` casts by the compiler. Remove this incorrect check and add codegen tests for all conversions involving these types.
2024-05-11Unify `Rvalue::Aggregate` paths in cg_ssaScott McMurray-1/+1
2024-05-11fix few typo in filecheck annotationsklensy-8/+8
2024-05-08Make SSA aggregates without needing an allocaScott McMurray-15/+99
2024-05-08Add a codegen test for transparent aggregatesScott McMurray-0/+39
2024-05-06Adjust dbg.value/dbg.declare checks for LLVM updateArthur Eubanks-10/+10
https://github.com/llvm/llvm-project/pull/89799 changes llvm.dbg.value/declare intrinsics to be in a different, out-of-instruction-line representation. For example call void @llvm.dbg.declare(...) becomes #dbg_declare(...) Update tests accordingly to work with both the old and new way.
2024-05-04tests/ui: prepare some tests for --check-cfg by defaultUrgau-9/+6
2024-05-03Add -Zfixed-x18Alice Ryhl-0/+22
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
2024-05-01Add inline comments why we're forcing the target cpuJosh Stone-0/+1
2024-05-01Use an explicit x86-64 cpu in tests that are sensitive to itJosh Stone-1/+1
There are a few tests that depend on some target features **not** being enabled by default, and usually they are correct with the default x86-64 target CPU. However, in downstream builds we have modified the default to fit our distros -- `x86-64-v2` in RHEL 9 and `x86-64-v3` in RHEL 10 -- and the latter especially trips tests that expect not to have AVX. These cases are few enough that we can just set them back explicitly.
2024-04-30Rollup merge of #124543 - maurer:llvm-range, r=nikicMatthias Krüger-3/+3
codegen tests: Tolerate `range()` qualifications in enum tests Current LLVM can infer range bounds on the i8s involved with these tests, and annotates it. Accept these bounds if present. `@rustbot` label: +llvm-main cc `@durin42`
2024-04-30codegen tests: Tolerate `range()` qualifications in enum testsMatthew Maurer-3/+3
Current LLVM can infer range bounds on the i8s involved with these tests, and annotates it. Accept these bounds if present.
2024-04-29adapt a codegen test for llvm 19Krasimir Georgiev-3/+3
No functional changes intended. Found by our experimental rust + LLVM @ HEAD bot: https://buildkite.com/llvm-project/rust-llvm-integrate-prototype/builds/27747#018f2570-018c-4b12-9c5a-38cf81453683/957-965
2024-04-25Auto merge of #121298 - nikic:writable, r=cuviperbors-4/+6
Set writable and dead_on_unwind attributes for sret arguments Set the `writable` and `dead_on_unwind` attributes for `sret` arguments. This allows call slot optimization to remove more memcpy's. See https://llvm.org/docs/LangRef.html#parameter-attributes for the specification of these attributes. In short, the statement we're making here is that: * The return slot is writable. * The return slot will not be read if the function unwinds. Fixes https://github.com/rust-lang/rust/issues/90595.
2024-04-25Add needs-unwind to codegen testNikita Popov-0/+1
When compiled with -C panic=abort we'd generate an extra panic_cannot_unwind shim in the variant calling C-unwind.
2024-04-25Fix incorrect CHECK-LABELNikita Popov-1/+1
2024-04-25Set writable and dead_on_unwind attributes for sret argumentsNikita Popov-3/+4
2024-04-24Fix tests and blessGary Guo-6/+1
2024-04-24Error on using `yield` without also using `#[coroutine]` on the closureOli Scherer-2/+2
And suggest adding the `#[coroutine]` to the closure
2024-04-24Auto merge of #122053 - erikdesjardins:alloca, r=nikicbors-108/+174
Stop using LLVM struct types for alloca The alloca type has no semantic meaning, only the size (and alignment, but we specify it explicitly) matter. Using `[N x i8]` is a more direct way to specify that we want `N` bytes, and avoids relying on LLVM's struct layout. It is likely that a future LLVM version will change to an untyped alloca representation. Split out from #121577. r? `@ghost`
2024-04-23Rollup merge of #124003 - WaffleLapkin:dellvmization, r=scottmcm,RalfJung,antoyoMatthias Krüger-0/+118
Dellvmize some intrinsics (use `u32` instead of `Self` in some integer intrinsics) This implements https://github.com/rust-lang/compiler-team/issues/693 minus what was implemented in #123226. Note: I decided to _not_ change `shl`/... builder methods, as it just doesn't seem worth it. r? ``@scottmcm``
2024-04-23add codegen testTrevor Spiteri-0/+20
The test confirms that when val < base, we do not divide or multiply.
2024-04-22Stabilize generic `NonZero`.Markus Reiter-10/+1
2024-04-20Avoid reloading Vec::len across grow_one in pushMark Rousskov-0/+16
This saves an extra load from memory.
2024-04-18Make `checked` ops emit *unchecked* LLVM operations where feasibleScott McMurray-0/+86
For things with easily pre-checked overflow conditions -- shifts and unsigned subtraction -- write then checked methods in such a way that we stop emitting wrapping versions of them. For example, today <https://rust.godbolt.org/z/qM9YK8Txb> neither ```rust a.checked_sub(b).unwrap() ``` nor ```rust a.checked_sub(b).unwrap_unchecked() ``` actually optimizes to `sub nuw`. After this PR they do.
2024-04-18At debuginfo=0, don't inline debuginfo when inliningScott McMurray-18/+20
2024-04-16Add codegen tests for changed intrinsicsMaybe Waffle-0/+118
2024-04-15Auto merge of #122917 - saethlin:atomicptr-to-int, r=nikicbors-0/+38
Add the missing inttoptr when we ptrtoint in ptr atomics Ralf noticed this here: https://github.com/rust-lang/rust/pull/122220#discussion_r1535172094 Our previous codegen forgot to add the cast back to integer type. The code compiles anyway, because of course all locals are in-memory to start with, so previous codegen would do the integer atomic, store the integer to a local, then load a pointer from that local. Which is definitely _not_ what we wanted: That's an integer-to-pointer transmute, so all pointers returned by these `AtomicPtr` methods didn't have provenance. Yikes. Here's the IR for `AtomicPtr::fetch_byte_add` on 1.76: https://godbolt.org/z/8qTEjeraY ```llvm define noundef ptr `@atomicptr_fetch_byte_add(ptr` noundef nonnull align 8 %a, i64 noundef %v) unnamed_addr #0 !dbg !7 { start: %0 = alloca ptr, align 8, !dbg !12 %val = inttoptr i64 %v to ptr, !dbg !12 call void `@llvm.lifetime.start.p0(i64` 8, ptr %0), !dbg !28 %1 = ptrtoint ptr %val to i64, !dbg !28 %2 = atomicrmw add ptr %a, i64 %1 monotonic, align 8, !dbg !28 store i64 %2, ptr %0, align 8, !dbg !28 %self = load ptr, ptr %0, align 8, !dbg !28 call void `@llvm.lifetime.end.p0(i64` 8, ptr %0), !dbg !28 ret ptr %self, !dbg !33 } ``` r? `@RalfJung` cc `@nikic`
2024-04-12Rollup merge of #123249 - goolmoos:naked_variadics, r=pnkfelixMatthias Krüger-1/+20
do not add prolog for variadic naked functions fixes #99858
2024-04-12remove alloca type from issue-105386-ub-in-debuginfoErik Desjardins-1/+1
It's irrelevant for the purposes of this test (there is only one alloca) and its size changes depending on the target, so it can't be matched easily.