about summary refs log tree commit diff
path: root/tests/codegen
AgeCommit message (Collapse)AuthorLines
2023-08-01Auto merge of #105545 - erikdesjardins:ptrclean, r=bjorn3bors-4/+4
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-07-29Replace ignore-everything with only-archJubilee Young-108/+39
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-29mv tests/codegen/repr-* tests/codegen/reprJubilee Young-0/+0
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-29Ignore an AVR-inapplicable testJubilee Young-0/+1
2023-07-29cg_llvm: simplify llvm.masked.gather/scatter naming with opaque pointersErik Desjardins-4/+4
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-27CHECK only for opaque ptrJosh Stone-247/+247
2023-07-27Update the minimum external LLVM to 15Josh Stone-27/+2
2023-07-27Auto merge of #113708 - rcvalle:rust-cfi-fix-100778, r=compiler-errorsbors-0/+59
CFI: Fix ICE: encode_const: unexpected type [usize Fixes #100778 and #113366, and complements #106547 by adding support for encoding const parameters.
2023-07-23Auto merge of #111836 - calebzulawski:target-feature-closure, r=workingjubileebors-0/+33
Fix #[inline(always)] on closures with target feature 1.1 Fixes #108655. I think this is the most obvious solution that isn't overly complicated. The comment includes more justification, but I think this is likely better than demoting the `#[inline(always)]` to `#[inline]`, since existing code is unaffected.
2023-07-21Support `.comment` section like GCC/Clang (`!llvm.ident`)Miguel Ojeda-0/+15
Both GCC and Clang write by default a `.comment` section with compiler information: ```txt $ gcc -c -xc /dev/null && readelf -p '.comment' null.o String dump of section '.comment': [ 1] GCC: (GNU) 11.2.0 $ clang -c -xc /dev/null && readelf -p '.comment' null.o String dump of section '.comment': [ 1] clang version 14.0.1 (https://github.com/llvm/llvm-project.git c62053979489ccb002efe411c3af059addcb5d7d) ``` They also implement the `-Qn` flag to avoid doing so: ```txt $ gcc -Qn -c -xc /dev/null && readelf -p '.comment' null.o readelf: Warning: Section '.comment' was not dumped because it does not exist! $ clang -Qn -c -xc /dev/null && readelf -p '.comment' null.o readelf: Warning: Section '.comment' was not dumped because it does not exist! ``` So far, `rustc` only does it for WebAssembly targets and only when debug info is enabled: ```txt $ echo 'fn main(){}' | rustc --target=wasm32-unknown-unknown --emit=llvm-ir -Cdebuginfo=2 - && grep llvm.ident rust_out.ll !llvm.ident = !{!27} ``` In the RFC part of this PR it was decided to always add the information, which gets us closer to other popular compilers. An opt-out flag like GCC and Clang may be added later on if deemed necessary. Implementation-wise, this covers both `ModuleLlvm::new()` and `ModuleLlvm::new_metadata()` cases by moving the addition to `context::create_module` and adds a few test cases. ThinLTO also sees the `llvm.ident` named metadata duplicated (in temporary outputs), so this deduplicates it like it is done for `wasm.custom_sections`. The tests also check this duplication does not take place. Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2023-07-20Get `!nonnull` metadata consistently in slice iterators, without needing ↵Scott McMurray-2/+42
`assume`s
2023-07-20Auto merge of #113758 - cjgillot:move-dse, r=JakobDegen,oli-obkbors-2/+3
Turn copy into moves during DSE. Dead store elimination computes whether removing a direct store to an unborrowed place is allowed. Where removing a store is allowed, writing `uninit` is too. This means that we can use this pass to transform `copy` operands into `move` operands. This is only interesting in call terminators, so we only handle those. Special care is taken for the `use_both(_1, _1)` case: - moving the second argument is ok, as `_1` is not live after the call; - moving the first argument is not, as the second argument reads `_1`. Fixes #75993 Fixes https://github.com/rust-lang/rust/issues/108068 r? `@RalfJung` cc `@JakobDegen`
2023-07-19Make test order-independent.Camille GILLOT-1/+1
2023-07-19Enable MIR opts for test.Camille GILLOT-1/+2
2023-07-19Turn copy into moves during DSE.Camille GILLOT-2/+2
2023-07-18Add the `no-builtins` attribute to functions when `no_builtins` is applied ↵DianQK-0/+24
at the crate level. When `no_builtins` is applied at the crate level, we should add the `no-builtins` attribute to each function to ensure it takes effect in LTO.
2023-07-17CFI: Fix ICE: encode_const: unexpected type [usizeRamon de C Valle-0/+59
Fixes #100778 and #113366, and complements #106547 by adding support for encoding const parameters.
2023-07-16Add codegen test ensuring always-inline closures don't bypass target featuresCaleb Zulawski-0/+33
2023-07-15Auto merge of #112157 - erikdesjardins:align, r=nikicbors-8/+557
Resurrect: rustc_target: Add alignment to indirectly-passed by-value types, correcting the alignment of byval on x86 in the process. Same as #111551, which I [accidentally closed](https://github.com/rust-lang/rust/pull/111551#issuecomment-1571222612) :/ --- This resurrects PR #103830, which has sat idle for a while. Beyond #103830, this also: - fixes byval alignment for types containing vectors on Darwin (see `tests/codegen/align-byval-vector.rs`) - fixes byval alignment for overaligned types on x86 Windows (see `tests/codegen/align-byval.rs`) - fixes ABI for types with 128bit requested alignment on ARM64 Linux (see `tests/codegen/aarch64-struct-align-128.rs`) r? `@nikic` --- `@pcwalton's` original PR description is reproduced below: Commit 88e4d2c from five years ago removed support for alignment on indirectly-passed arguments because of problems with the `i686-pc-windows-msvc` target. Unfortunately, the `memcpy` optimizations I recently added to LLVM 16 depend on this to forward `memcpy`s. This commit attempts to fix the problems with `byval` parameters on that target and now correctly adds the `align` attribute. The problem is summarized in [this comment] by `@eddyb.` Briefly, 32-bit x86 has special alignment rules for `byval` parameters: for the most part, their alignment is forced to 4. This is not well-documented anywhere but in the Clang source. I looked at the logic in Clang `TargetInfo.cpp` and tried to replicate it here. The relevant methods in that file are `X86_32ABIInfo::getIndirectResult()` and `X86_32ABIInfo::getTypeStackAlignInBytes()`. The `align` parameter attribute for `byval` parameters in LLVM must match the platform ABI, or miscompilations will occur. Note that this doesn't use the approach suggested by eddyb, because I felt it was overkill to store the alignment in `on_stack` when special handling is really only needed for 32-bit x86. As a side effect, this should fix #80127, because it will make the `align` parameter attribute for `byval` parameters match the platform ABI on LLVM x86-64. [this comment]: #80822 (comment)
2023-07-14i686-windows: make requested alignment > 4 special case apply transitivelyErik Desjardins-2/+4
2023-07-14Auto merge of #109025 - cjgillot:refprop-dbg, r=JakobDegenbors-23/+27
Enable MIR reference propagation by default
2023-07-14Bless codegen test.Camille GILLOT-1/+1
2023-07-11Reenable all cases of simd-wide-sumJubilee Young-4/+3
2023-07-11Add mir-opt3 rev to simd-wide-sum testJubilee Young-0/+5
2023-07-10aarch64-linux: properly handle 128bit aligned aggregatesErik Desjardins-0/+150
2023-07-10repr(align) <= 4 should still be byvalErik Desjardins-7/+4
2023-07-10align-byval test: add cases for lower requested alignment, wrapped, and ↵Erik Desjardins-3/+100
repr(transparent)
2023-07-10ensure byval allocas are sufficiently alignedErik Desjardins-15/+101
2023-07-10align-byval test: add cases for <= align 4Erik Desjardins-2/+50
2023-07-10align-byval test: add cases distinguishing natural vs forced/requested alignmentErik Desjardins-10/+62
2023-07-10align-byval test: add x86Erik Desjardins-3/+12
x86 Windows also should not use byval since the struct is overaligned, see https://reviews.llvm.org/D72114
2023-07-10add align attr to addr-of-mutate testErik Desjardins-3/+3
2023-07-10implement vector-containing aggregate alignment for x86 darwinErik Desjardins-0/+58
2023-07-10update array-map test for removed allocaErik Desjardins-1/+0
2023-07-10align-byval test: use revisions to test different targetsErik Desjardins-40/+35
2023-07-10rustc_target: Add alignment to indirectly-passed by-value types, correcting thePatrick Walton-4/+60
alignment of `byval` on x86 in the process. Commit 88e4d2c2918428d55e34cd57c11279ea839c8822 from five years ago removed support for alignment on indirectly-passed arguments because of problems with the `i686-pc-windows-msvc` target. Unfortunately, the `memcpy` optimizations I recently added to LLVM 16 depend on this to forward `memcpy`s. This commit attempts to fix the problems with `byval` parameters on that target and now correctly adds the `align` attribute. The problem is summarized in [this comment] by @eddyb. Briefly, 32-bit x86 has special alignment rules for `byval` parameters: for the most part, their alignment is forced to 4. This is not well-documented anywhere but in the Clang source. I looked at the logic in Clang `TargetInfo.cpp` and tried to replicate it here. The relevant methods in that file are `X86_32ABIInfo::getIndirectResult()` and `X86_32ABIInfo::getTypeStackAlignInBytes()`. The `align` parameter attribute for `byval` parameters in LLVM must match the platform ABI, or miscompilations will occur. Note that this doesn't use the approach suggested by eddyb, because I felt it was overkill to store the alignment in `on_stack` when special handling is really only needed for 32-bit x86. As a side effect, this should fix #80127, because it will make the `align` parameter attribute for `byval` parameters match the platform ABI on LLVM x86-64. [this comment]: https://github.com/rust-lang/rust/pull/80822#issuecomment-829985417
2023-07-10Perform reference propagation earlier.Camille GILLOT-16/+16
2023-07-10Fortify codegen test.Camille GILLOT-6/+10
2023-07-09Rollup merge of #113247 - mirkootter:test-wasm-exceptions-nostd, ↵Matthias Krüger-0/+52
r=Mark-Simulacrum Add Tests for native wasm exceptions ### Motivation In PR #111322, I added support for native WASM exceptions. I was asked by ``@davidtwco`` to add some tests for it in a follow up PR, which seems like a very good idea. This PR adds three tests for this feature: * codegen: ensure the correct LLVM instructions are used * assembly: ensure the correct WASM instructions are used * run-make: ensure the exception handling works; the WASM code is run using a small nodejs script which demonstrates the exception handling ### Complications There are a few changes beside adding the tests, which were necessary * Tests for the wasm32-unknown-unknown target are (as far as I know) only run on `test-various`. Its docker image uses nodejs-15, which is very old. Experimental support for wasm-exceptions was added in nodejs16. In nodejs 18.12 (LTS), they are stable. - --> increase nodejs to 18.12 in `test-various` * codegen/assembly tests are not performed for the wasm32-unknown-unknown target yet - --> add those to `test-various` as well Due to the last point, some tests are run which have not run before (assembly+codegen tests for wasm32-unknown-unknown). I added `// ignore wasm32-bare` for those which failed ### Local testing I run all tests locally using both `test-various` and `wasm32`. As far as I know, none of the other systems run any test for wasm32 targets.
2023-07-08Always name the return place.Camille GILLOT-193/+190
2023-07-02test-various: run codegen and assembly testsJan-Mirko Otter-0/+1
2023-07-01add codegen-test: wasm-exceptionsJan-Mirko Otter-0/+51
2023-06-27Auto merge of #112516 - erikdesjardins:loop, r=davidtwcobors-0/+12
cg_llvm: use index-based loop in write_operand_repeatedly This should be easier for LLVM to analyze. Fixes #111603 This needs a perf run. [cc](https://github.com/rust-lang/rust/issues/111603#issuecomment-1567531178) `@caojoshua`
2023-06-23Auto merge of #112891 - oli-obk:impl_trait_in_assoc_tys_cleanup, ↵bors-1/+13
r=compiler-errors Various impl trait in assoc tys cleanups r? `@compiler-errors` All commits except for the last are pure refactorings. 274dab5bd658c97886a8987340bf50ae57900c39 allows struct fields to participate in deciding whether a function has an opaque in its signature. best reviewed commit by commit
2023-06-23Auto merge of #112974 - matthiaskrgr:rollup-hnk7ans, r=matthiaskrgrbors-1/+1
Rollup of 8 pull requests Successful merges: - #112616 (Improve tests on targets without unwinding) - #112643 (Always register sized obligation for argument) - #112740 (Add link to rustdoc book search chapter in help popover) - #112810 (Don't ICE on unnormalized struct tail in layout computation) - #112870 (Migrate `item_bounds` to `ty::Clause`) - #112925 (Stop hiding const eval limit in external macros) - #112960 ([tests/rustdoc] Add `@files` command) - #112962 (Fix rustdoc gui tester) r? `@ghost` `@rustbot` modify labels: rollup
2023-06-23Rollup merge of #112616 - ferrocene:pa-more-test-suite-fixes, r=NilstriebMatthias Krüger-1/+1
Improve tests on targets without unwinding This PR makes more miscellaneous changes to tests, to make it work on targets without unwinding support.
2023-06-23tests: be even more permissive on attributes in one testAugie Fackler-17/+17
2023-06-22tests: be more permissive on attributes in one testAugie Fackler-1/+1
2023-06-22Fix a codegen testOli Scherer-1/+13
2023-06-19Auto merge of #112724 - scottmcm:simpler-unchecked-shifts, r=Mark-Simulacrumbors-0/+4
[libs] Simplify `unchecked_{shl,shr}` There's no need for the `const_eval_select` dance here. And while I originally wrote the `.try_into().unwrap_unchecked()` implementation here, it's kinda a mess in MIR -- this new one is substantially simpler, as shown by the old one being above the inlining threshold but the new one being below it in the `mir-opt/inline/unchecked_shifts` tests. We don't need `u32::checked_shl` doing a dance through both `Result` *and* `Option` 🙃