about summary refs log tree commit diff
path: root/tests/codegen
AgeCommit message (Collapse)AuthorLines
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-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` 🙃
2023-06-16[libs] Simplify `unchecked_{shl,shr}`Scott McMurray-0/+4
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.
2023-06-16Rollup merge of #112474 - ldm0:ldm_enum_debuginfo_128_support, r=compiler-errorsMichael Goulet-2/+29
Support 128-bit enum variant in debuginfo codegen fixes #111600
2023-06-14use indexed loop instead of ptr bumpingThe 8472-8/+0
this seems to produce less IR
2023-06-14update codegent test to be independent of panic strategyPietro Albini-1/+1
2023-06-12add codegen test for slice::Iter::foldThe 8472-0/+14
2023-06-11cg_llvm: use index-based loop in write_operand_repeatedlyErik Desjardins-0/+12
This is easier for LLVM to analyze.
2023-06-10Add testldm0-0/+27
2023-06-10Fix codegen testsldm0-2/+2
2023-06-04Use `load`-`store` instead of `memcpy` for short integer arraysScott McMurray-15/+65
2023-06-04Add a codegen test for manually swapping a small `Copy` typeScott McMurray-0/+20
To confirm we're not just helping `mem::swap`
2023-06-03Rollup merge of #111878 - ferrocene:pa-codegen-tests, r=Mark-SimulacrumMatthias Krüger-55/+64
Fix codegen test suite for bare-metal-like targets For Ferrocene I needed to run the test suite for custom target with no unwinding and static relocation. Running the tests uncovered ~20 failures due to the test suite not accounting for these options. This PR fixes them by: * Fixing `CHECK`s to account for functions having extra LLVM IR attributes (in this case `nounwind`). * Fixing `CHECK`s to account for the `dso_local` LLVM IR modifier, which is [added to every item when relocation is static](https://github.com/rust-lang/rust/blob/f3d597b31c0f101a02c230798afa31a36bdacbc6/compiler/rustc_codegen_llvm/src/mono_item.rs#L139-L142). * Fixing `CHECK`s to account for missing `uwtables` attributes. * Added the `needs-unwind` attributes for tests that are designed to check unwinding. There is no part of Rust CI that checks this unfortunately, and testing whether the PR works locally is kinda hard because you need a target with std enabled but no unwinding and static relocations. Still, this works in my local testing, and if future PRs accidentally break this Ferrocene will take care of sending followup PRs.