about summary refs log tree commit diff
path: root/tests/codegen
AgeCommit message (Collapse)AuthorLines
2024-02-16Auto merge of #120500 - oli-obk:intrinsics2.0, r=WaffleLapkinbors-2/+2
Implement intrinsics with fallback bodies fixes #93145 (though we can port many more intrinsics) cc #63585 The way this works is that the backend logic for generating custom code for intrinsics has been made fallible. The only failure path is "this intrinsic is unknown". The `Instance` (that was `InstanceDef::Intrinsic`) then gets converted to `InstanceDef::Item`, which represents the fallback body. A regular function call to that body is then codegenned. This is currently implemented for * codegen_ssa (so llvm and gcc) * codegen_cranelift other backends will need to adjust, but they can just keep doing what they were doing if they prefer (though adding new intrinsics to the compiler will then require them to implement them, instead of getting the fallback body). cc `@scottmcm` `@WaffleLapkin` ### todo * [ ] miri support * [x] default intrinsic name to name of function instead of requiring it to be specified in attribute * [x] make sure that the bodies are always available (must be collected for metadata)
2024-02-13tests: LLVM 18 infers an extra noalias hereAugie Fackler-1/+1
This test started failing on LLVM 18 after change 61118ffd04aa6d1f9ee92daae4deb28bd975d4ab. As far as I can tell, it's just good fortune that LLVM is able to sniff out the new noalias here, and it's correct.
2024-02-12Support safe intrinsics with fallback bodiesOli Scherer-2/+2
Turn `is_val_statically_known` into such an intrinsic to demonstrate. It is perfectly safe to call after all.
2024-02-11Rollup merge of #118307 - scottmcm:tuple-eq-simpler, r=joshtriplettMatthias Krüger-6/+8
Remove an unneeded helper from the tuple library code Thanks to https://github.com/rust-lang/rust/pull/107022, this is just what `==` does, so we don't need the helper here anymore.
2024-02-09Build DebugInfo for coroutine-closureMichael Goulet-0/+21
2024-02-07Rollup merge of #119162 - heiher:direct-access-external-data, r=petrochenkovGuillaume Boisseau-0/+21
Add unstable `-Z direct-access-external-data` cmdline flag for `rustc` The new flag has been described in the Major Change Proposal at https://github.com/rust-lang/compiler-team/issues/707 Fixes #118053
2024-02-06Rollup merge of #120502 - clubby789:remove-ffi-returns-twice, r=compiler-errorsMatthias Krüger-11/+0
Remove `ffi_returns_twice` feature The [tracking issue](https://github.com/rust-lang/rust/issues/58314) and [RFC](https://github.com/rust-lang/rfcs/pull/2633) have been closed for a couple of years. There is also an attribute gate in R-A which should be removed if this lands.
2024-02-04Auto merge of #120624 - matthiaskrgr:rollup-3gvcl20, r=matthiaskrgrbors-0/+38
Rollup of 8 pull requests Successful merges: - #120484 (Avoid ICE when is_val_statically_known is not of a supported type) - #120516 (pattern_analysis: cleanup manual impls) - #120517 (never patterns: It is correct to lower `!` to `_`.) - #120523 (Improve `io::Read::read_buf_exact` error case) - #120528 (Store SHOULD_CAPTURE as AtomicU8) - #120529 (Update data layouts in custom target tests for LLVM 18) - #120531 (Remove a bunch of `has_errors` checks that have no meaningful or the wrong effect) - #120533 (Correct paths for hexagon-unknown-none-elf platform doc) r? `@ghost` `@rustbot` modify labels: rollup
2024-02-03Rollup merge of #120484 - Teapot4195:issue-120480-fix, r=compiler-errorsMatthias Krüger-0/+38
Avoid ICE when is_val_statically_known is not of a supported type 2 ICE with 1 stone! 1. Implement `llvm.is.constant.ptr` to avoid first ICE in linked issue. 2. return `false` when the argument is not one of `i*`/`f*`/`ptr` to avoid second ICE. fixes #120480
2024-02-01Revert unsound libcore changes of #119911Oli Scherer-55/+0
2024-01-30Remove `ffi_returns_twice` featureclubby789-11/+0
2024-01-30Add additional test cases for is_val_statically_knownAlex Huang-0/+38
2024-01-30Rollup merge of #120310 - krasimirgg:jan-v0-sym, r=Mark-SimulacrumGuillaume Gomez-1/+1
adapt test for v0 symbol mangling No functional changes intended. Adapts the test to also work under `new-symbol-mangling = true`.
2024-01-26Update codegen test for LLVM 18Nikita Popov-2/+2
2024-01-25Auto merge of #119911 - NCGThompson:is-statically-known, r=oli-obkbors-0/+103
Replacement of #114390: Add new intrinsic `is_var_statically_known` and optimize pow for powers of two This adds a new intrinsic `is_val_statically_known` that lowers to [``@llvm.is.constant.*`](https://llvm.org/docs/LangRef.html#llvm-is-constant-intrinsic).` It also applies the intrinsic in the int_pow methods to recognize and optimize the idiom `2isize.pow(x)`. See #114390 for more discussion. While I have extended the scope of the power of two optimization from #114390, I haven't added any new uses for the intrinsic. That can be done in later pull requests. Note: When testing or using the library, be sure to use `--stage 1` or higher. Otherwise, the intrinsic will be a noop and the doctests will be skipped. If you are trying out edits, you may be interested in [`--keep-stage 0`](https://rustc-dev-guide.rust-lang.org/building/suggested.html#faster-builds-with---keep-stage). Fixes #47234 Resolves #114390 `@Centri3`
2024-01-24adapt test for v0 symbol manglingKrasimir Georgiev-1/+1
No functional changes intended. Adapts the test to also work under new-symbol-mangling = true.
2024-01-23Further Implement Power of Two OptimizationNicholas Thompson-39/+26
2024-01-23Further Implement `is_val_statically_known`Nicholas Thompson-3/+1
2024-01-23Remove uses of no-system-llvmNikita Popov-17/+0
It looks like none of these are actually needed.
2024-01-23Allow disjoint flag in codegen testNikita Popov-1/+1
2024-01-23Auto merge of #119892 - joboet:libs_use_assert_unchecked, r=Nilstrieb,cuviperbors-0/+4
Use `assert_unchecked` instead of `assume` intrinsic in the standard library Now that a public wrapper for the `assume` intrinsic exists, we can use it in the standard library. CC #119131
2024-01-22update codegen testsjoboet-0/+4
2024-01-19Tweak the threshold for chunked swappingAngelicosPhosphoros-18/+64
Thanks to 98892 for the tests I brought in here, as it demonstrated that 3×usize is currently suboptimal.
2024-01-19Add new intrinsic `is_constant` and optimize `pow`Catherine Flores-0/+118
Fix overflow check Make MIRI choose the path randomly and rename the intrinsic Add back test Add miri test and make it operate on `ptr` Define `llvm.is.constant` for primitives Update MIRI comment and fix test in stage2 Add const eval test Clarify that both branches must have the same side effects guaranteed non guarantee use immediate type instead Co-Authored-By: Ralf Jung <post@ralfj.de>
2024-01-19Directly use volatile_load intrinsicNikita Popov-1/+3
This makes the test work if libstd is compiled with debug assertions.
2024-01-19Add codegen test for ScalarPair with i128 on LLVM 17Nikita Popov-0/+101
2024-01-16Auto merge of #119954 - scottmcm:option-unwrap-failed, r=WaffleLapkinbors-2/+2
Split out `option::unwrap_failed` like we have `result::unwrap_failed` ...and like `option::expect_failed`
2024-01-16Add unstable `-Z direct-access-external-data` cmdline flag for `rustc`WANG Rui-0/+21
The new flag has been described in the Major Change Proposal at https://github.com/rust-lang/compiler-team/issues/707
2024-01-15Auto merge of #119878 - scottmcm:inline-always-unwrap, r=workingjubileebors-0/+26
Tune the inlinability of `unwrap` Fixes #115463 cc `@thomcc` This tweaks `unwrap` on ~~`Option` &~~ `Result` to be two parts: - `#[inline(always)]` for checking the discriminant - `#[cold]` for actually panicking The idea here is that checking the discriminant on a `Result` ~~or `Option`~~ should always be trivial enough to be worth inlining, even in `opt-level=z`, especially compared to passing it to a function. As seen in the issue and codegen test, this will hopefully help particularly for things like `.try_into().unwrap()`s that are actually infallible, but in a way that's only visible with the inlining. EDIT: I've restricted this to `Result` to avoid combining effects
2024-01-14Split out `option::unwrap_failed` like we have `result::unwrap_failed`Scott McMurray-2/+2
...and like `option::expect_failed`
2024-01-12Auto merge of #119452 - ↵bors-0/+83
AngelicosPhosphoros:make_nonzeroint_get_assume_nonzero, r=scottmcm Add assume into `NonZeroIntX::get` LLVM currently don't support range metadata for function arguments so it fails to optimize non zero integers using their invariant if they are provided using by-value function arguments. Related to https://github.com/rust-lang/rust/issues/119422 Related to https://github.com/llvm/llvm-project/issues/76628 Related to https://github.com/rust-lang/rust/issues/49572
2024-01-12Tune the inlinability of `Result::unwrap`Scott McMurray-0/+26
2024-01-07mark vec::IntoIter pointers as `!nonnull`The 8472-0/+46
2024-01-06Add assume into `NonZeroIntX::get`AngelicosPhosphoros-0/+83
LLVM currently don't support range metadata for function arguments so it fails to optimize non zero integers using their invariant if they are provided using by-value function arguments. Related to https://github.com/rust-lang/rust/issues/119422 Related to https://github.com/llvm/llvm-project/issues/76628 Related to https://github.com/rust-lang/rust/issues/49572
2024-01-05Auto merge of #118991 - nikic:scalar-pair, r=nagisabors-34/+33
Separate immediate and in-memory ScalarPair representation Currently, we assume that ScalarPair is always represented using a two-element struct, both as an immediate value and when stored in memory. This currently works fairly well, but runs into problems with https://github.com/rust-lang/rust/pull/116672, where a ScalarPair involving an i128 type can no longer be represented as a two-element struct in memory. For example, the tuple `(i32, i128)` needs to be represented in-memory as `{ i32, [3 x i32], i128 }` to satisfy alignment requirements. Using `{ i32, i128 }` instead will result in the second element being stored at the wrong offset (prior to LLVM 18). Resolve this issue by no longer requiring that the immediate and in-memory type for ScalarPair are the same. The in-memory type will now look the same as for normal struct types (and will include padding filler and similar), while the immediate type stays a simple two-element struct type. This also means that booleans in immediate ScalarPair are now represented as i1 rather than i8, just like we do everywhere else. The core change here is to llvm_type (which now treats ScalarPair as a normal struct) and immediate_llvm_type (which returns the two-element struct that llvm_type used to produce). The rest is fixing things up to no longer assume these are the same. In particular, this switches places that try to get pointers to the ScalarPair elements to use byte-geps instead of struct-geps.
2024-01-05Make test compatible with 32-bit as wellNikita Popov-1/+1
2024-01-04Rollup merge of #119555 - Kobzol:maybeuninit-rvo-codegen-test, r=nikicMatthias Krüger-0/+33
Add codegen test for RVO on MaybeUninit Codegen test for https://github.com/rust-lang/rust/issues/90595. Currently, this only works with `-Cpanic=abort`, but hopefully in the [future](https://www.npopov.com/2024/01/01/This-year-in-LLVM-2023.html#writable-and-dead_on_unwind) it should also work in the presence of panics. r? ``@nikic``
2024-01-03Add codegen test for RVO on MaybeUninitJakub Beránek-0/+33
Currently, this only works with `-Cpanic=abort`.
2024-01-03Rollup merge of #119523 - maurer:fix-sparc-llvm-18, r=nikicLeón Orell Valerian Liehr-2/+2
llvm: Allow `noundef` in codegen tests LLVM 18 will automatically infer `noundef` in some situations. Adjust codegen tests to accept this. See llvm/llvm-project#76553 for why `noundef` is being generated now. ``@rustbot`` label:+llvm-main
2024-01-02llvm: Allow `noundef` in codegen testsMatthew Maurer-2/+2
LLVM 18 will automatically infer `noundef` in some situations. Adjust codegen tests to accept this. See llvm/llvm-project#76553 for why `noundef` is being generated now.
2024-01-02Address review commentsNikita Popov-1/+1
2023-12-24Revert codegen test change.Camille GILLOT-0/+2
2023-12-24Replace legacy ConstProp by GVN.Camille GILLOT-1/+1
2023-12-24Enable GVN by default.Camille GILLOT-2/+0
2023-12-21tests: fix overaligned-constant to not over-specify getelementptr instrAugie Fackler-1/+1
On LLVM 18 we get slightly different arguments here, so it's easier to just regex those away. The important details are all still asserted as I understand things. Fixes #119193. @rustbot label: +llvm-main
2023-12-21Auto merge of #119056 - cjgillot:codegen-overalign, r=wesleywiserbors-0/+36
Tolerate overaligned MIR constants for codegen. Fixes https://github.com/rust-lang/rust/issues/117761 cc `@saethlin`
2023-12-20Auto merge of #106790 - the8472:rawvec-niche, r=scottmcmbors-8/+20
add more niches to rawvec Previously RawVec only had a single niche in its `NonNull` pointer. With this change it now has `isize::MAX` niches since half the value-space of the capacity field is never needed, we can't have a capacity larger than isize::MAX.
2023-12-17Fortify test.Camille GILLOT-4/+9
2023-12-17Tolerate overaligned MIR constants for codegen.Camille GILLOT-0/+31
2023-12-15Separate immediate and in-memory ScalarPair representationNikita Popov-33/+32
Currently, we assume that ScalarPair is always represented using a two-element struct, both as an immediate value and when stored in memory. This currently works fairly well, but runs into problems with https://github.com/rust-lang/rust/pull/116672, where a ScalarPair involving an i128 type can no longer be represented as a two-element struct in memory. For example, the tuple `(i32, i128)` needs to be represented in-memory as `{ i32, [3 x i32], i128 }` to satisfy alignment requirement. Using `{ i32, i128 }` instead will result in the second element being stored at the wrong offset (prior to LLVM 18). Resolve this issue by no longer requiring that the immediate and in-memory type for ScalarPair are the same. The in-memory type will now look the same as for normal struct types (and will include padding filler and similar), while the immediate type stays a simple two-element struct type. This also means that booleans in immediate ScalarPair are now represented as i1 rather than i8, just like we do everywhere else. The core change here is to llvm_type (which now treats ScalarPair as a normal struct) and immediate_llvm_type (which returns the two-element struct that llvm_type used to produce). The rest is fixing things up to no longer assume these are the same. In particular, this switches places that try to get pointers to the ScalarPair elements to use byte-geps instead of struct-geps.