summary refs log tree commit diff
path: root/src/test/codegen
AgeCommit message (Collapse)AuthorLines
2020-12-10tests: codegen/transmute-scalar needs optimizations enabled.Eduard-Mihai Burtescu-1/+1
2020-12-09tests: add 3 cases involving pointers to codegen/transmute-scalar.Eduard-Mihai Burtescu-0/+50
2020-12-07rustc_codegen_ssa: use bitcasts instead of type punning for scalar transmutes.Eduard-Mihai Burtescu-0/+35
2020-11-30make test work in llvm 9Erik Desjardins-1/+1
2020-11-29Pass arguments up to 2*usize by valueErik Desjardins-5/+10
2020-11-29Auto merge of #78380 - bstrie:rm-old-num-const-from-tests, r=jyn514bors-5/+4
Update tests to remove old numeric constants Part of #68490. Care has been taken to leave the old consts where appropriate, for testing backcompat regressions, module shadowing, etc. The intrinsics docs were accidentally referring to some methods on f64 as std::f64, which I changed due to being contrary with how we normally disambiguate the shadow module from the primitive. In one other place I changed std::u8 to std::ops since it was just testing path handling in macros. For places which have legitimate uses of the old consts, deprecated attributes have been optimistically inserted. Although currently unnecessary, they exist to emphasize to any future deprecation effort the necessity of these specific symbols and prevent them from being accidentally removed.
2020-11-29Auto merge of #78863 - KodrAus:feat/simd-array, r=oli-obkbors-0/+91
Support repr(simd) on ADTs containing a single array field This is a squash and rebase of `@gnzlbg's` #63531 I've never actually written code in the compiler before so just fumbled my way around until it would build 😅 I imagine there'll be some work we need to do in `rustc_codegen_cranelift` too for this now, but might need some input from `@bjorn3` to know what that is. cc `@rust-lang/project-portable-simd` ----- This PR allows using `#[repr(simd)]` on ADTs containing a single array field: ```rust #[repr(simd)] struct S0([f32; 4]); #[repr(simd)] struct S1<const N: usize>([f32; N]); #[repr(simd)] struct S2<T, const N: usize>([T; N]); ``` This should allow experimenting with portable packed SIMD abstractions on nightly that make use of const generics.
2020-11-29args may be passed by valueAshley Mannix-4/+4
2020-11-29Update tests to remove old numeric constantsbstrie-5/+4
Part of #68490. Care has been taken to leave the old consts where appropriate, for testing backcompat regressions, module shadowing, etc. The intrinsics docs were accidentally referring to some methods on f64 as std::f64, which I changed due to being contrary with how we normally disambiguate the shadow module from the primitive. In one other place I changed std::u8 to std::ops since it was just testing path handling in macros. For places which have legitimate uses of the old consts, deprecated attributes have been optimistically inserted. Although currently unnecessary, they exist to emphasize to any future deprecation effort the necessity of these specific symbols and prevent them from being accidentally removed.
2020-11-29looser regex on local argsAshley Mannix-6/+6
2020-11-25Validate use of parameters in naked functionsTomasz Miąsko-49/+5
* Reject use of parameters inside naked function body. * Reject use of patterns inside function parameters, to emphasize role of parameters a signature declaration (mirroring existing behaviour for function declarations) and avoid generating code introducing specified bindings.
2020-11-24Rollup merge of #79346 - tmiasko:more-names, r=jonas-schievinkJonas Schievink-0/+20
Allow using `-Z fewer-names=no` to retain value names Change `-Z fewer-names` into an optional boolean flag and allow using it to either discard value names when true or retain them when false, regardless of other settings.
2020-11-24generalize codegen to non 64bit platformsAshley Mannix-6/+6
2020-11-23Auto merge of #78439 - lzutao:rm-clouldabi, r=Mark-Simulacrumbors-2/+0
Drop support for all cloudabi targets `cloudabi` is a tier-3 target, and [it is no longer being maintained upstream][no]. This PR drops supports for cloudabi targets. Those targets are: * aarch64-unknown-cloudabi * armv7-unknown-cloudabi * i686-unknown-cloudabi * x86_64-unknown-cloudabi Since this drops supports for a target, I'd like somebody to tag `relnotes` label to this PR. Some other issues: * The tidy exception for `cloudabi` crate is still remained because * `parking_lot v0.9.0` and `parking_lot v0.10.2` depends on `cloudabi v0.0.3`. * `parking_lot v0.11.0` depends on `cloudabi v0.1.0`. [no]: https://github.com/NuxiNL/cloudabi#note-this-project-is-unmaintained
2020-11-23Allow using `-Z fewer-names=no` to retain value namesTomasz Miąsko-0/+20
Change `-Z fewer-names` into an optional boolean flag and allow using it to either discard value names when true or retain them when false, regardless of other settings.
2020-11-22Change slice::to_vec to not use extend_from_slicekadmin-0/+10
This also required adding a loop guard in case clone panics Add specialization for copy There is a better version for copy, so I've added specialization for that function and hopefully that should speed it up even more. Switch FromIter<slice::Iter> to use `to_vec` Test different unrolling version for to_vec Revert to impl From benchmarking, it appears this version is faster
2020-11-22Drop support for cloudabi targetsLzu Tao-2/+0
2020-11-20Never inline naked functionsTomasz Miąsko-0/+30
The `#[naked]` attribute disabled prologue / epilogue emission for the function and it is responsibility of a developer to provide them. The compiler is no position to inline such functions correctly. Disable inlining of naked functions at LLVM and MIR level.
2020-11-18Auto merge of #79106 - tmiasko:inline-hint, r=nagisa,eddybbors-0/+31
Fix setting inline hint based on `InstanceDef::requires_inline` For instances where `InstanceDef::requires_inline` is true, an attempt is made to set an inline hint though a call to the `inline` function. The attempt is ineffective, since all attributes will be usually removed by the second call. Fix the issue by applying the attributes only once, with user provided attributes having a priority when provided. Closes #79108.
2020-11-17Rollup merge of #78967 - tmiasko:codegen-tests, r=cuviperMara Bos-9/+17
Make codegen tests compatible with extra inlining
2020-11-17Fix setting inline hint based on `InstanceDef::requires_inline`Tomasz Miąsko-0/+31
For instances where `InstanceDef::requires_inline` is true, an attempt is made to set an inline hint though a call to the `inline` function. The attempt is ineffective, since all attributes will be usually removed by the second call. Fix the issue by applying the attributes only once, with user provided attributes having a priority when provided.
2020-11-14tweak new codegen test to work on localAshley Mannix-4/+4
2020-11-13remove const_generics from codegen testsAshley Mannix-4/+4
2020-11-12fully exploited the dropped support of LLVM 8DevJPM-2/+0
This commit grepped for LLVM_VERSION_GE, LLVM_VERSION_LT, get_major_version and min-llvm-version and statically evaluated every expression possible (and sensible) assuming that the LLVM version is >=9 now
2020-11-12Fix codegen test for issue 37945Tomasz Miąsko-6/+14
2020-11-12Ensure that closure call is not removed by MIR optimizations in a testTomasz Miąsko-1/+1
2020-11-12Fix test checking that into_boxed_slice does not panicTomasz Miąsko-2/+2
The memory allocation in vec might panic in the case of capacity overflow. Move the allocation outside the function to fix the test.
2020-11-08Support repr(simd) on ADTs containing a single array fieldgnzlbg-0/+91
This PR allows using `#[repr(simd)]` on ADTs containing a single array field: ```rust #[repr(simd)] struct S0([f32; 4]); #[repr(simd)] struct S1<const N: usize>([f32; N]); #[repr(simd)] struct S2<T, const N: usize>([T; N]); ``` This should allow experimenting with portable packed SIMD abstractions on nightly that make use of const generics.
2020-11-03Rollup merge of #77950 - arlosi:sha256, r=eddybMara Bos-0/+7
Add support for SHA256 source file hashing Adds support for `-Z src-hash-algorithm sha256`, which became available in LLVM 11. Using an older version of LLVM will cause an error `invalid checksum kind` if the hash algorithm is set to sha256. r? `@eddyb` cc #70401 `@est31`
2020-10-31Assert that locals have storage when usedTomasz Miąsko-0/+1
The validator in visit_local asserts that local has a stroage when used, but visit_local is never called so validation is ineffective. Use super_statement and super_terminator to ensure that locals are visited.
2020-10-26Auto merge of #77876 - tmiasko:simplify-locals, r=wesleywiserbors-6/+6
Remove unused set-discriminant statements and assignments regardless of rvalue * Represent use counts with u32 * Unify use count visitors * Change RemoveStatements visitor into a function * Remove unused set-discriminant statements * Use exhaustive match to clarify what is being optimized * Remove unused assignments regardless of rvalue kind
2020-10-26Auto merge of #68965 - eddyb:mir-inline-scope, r=nagisa,oli-obkbors-0/+17
rustc_mir: track inlined callees in SourceScopeData. We now record which MIR scopes are the roots of *other* (inlined) functions's scope trees, which allows us to generate the correct debuginfo in codegen, similar to what LLVM inlining generates. This PR makes the `ui` test `backtrace-debuginfo` pass, if the MIR inliner is turned on by default. Also, `#[track_caller]` is now correct in the face of MIR inlining (cc `@anp).` Fixes #76997. r? `@rust-lang/wg-mir-opt`
2020-10-26Ignore long lines in testoli-0/+1
2020-10-26Add an inlining debuginfo testoli-0/+16
2020-10-26simplify-locals: Remove unused assignments regardless of rvalue kindTomasz Miąsko-6/+6
2020-10-23Add codegen test for #45964Dániel Buga-0/+38
2020-10-20Rollup merge of #78046 - bugadani:issue-73827, r=nikicGuillaume Gomez-0/+18
Add codegen test for issue #73827 Closes #73827
2020-10-17Add codegen test for issue #73827Dániel Buga-0/+18
2020-10-15Prevent miscompilation in trivial loop {}Mark Rousskov-0/+15
Ideally, we would want to handle a broader set of cases to fully fix the underlying bug here. That is currently relatively expensive at compile and runtime, so we don't do that for now.
2020-10-14Add support for SHA256 source file hashing for LLVM 11+.Arlo Siemsen-0/+7
2020-10-13Auto merge of #76830 - Artoria2e5:tune, r=nagisabors-0/+21
Pass tune-cpu to LLVM I think this is how it should work... See https://internals.rust-lang.org/t/expose-tune-cpu-from-llvm/13088 for the background. Or the documentation diff.
2020-10-10Revert "Assume slice len is bounded by allocation size"Simonas Kazlauskas-24/+0
https://github.com/rust-lang/rust/pull/77023#issuecomment-703987379 suggests that the original PR introduced a significant perf regression. This reverts commit e44784b8750016a695361c990024750e037d8f9f / #77023.
2020-10-07Add codegen testAnthonyMikh-0/+35
2020-10-05Auto merge of #77466 - Aaron1011:reland-drop-tree, r=matthewjasperbors-3/+3
Re-land PR #71840 (Rework MIR drop tree lowering) PR https://github.com/rust-lang/rust/pull/71840 was reverted in https://github.com/rust-lang/rust/pull/72989 to fix an LLVM error (https://github.com/rust-lang/rust/issues/72470). That LLVM error no longer occurs with the recent upgrade to LLVM 11 (https://github.com/rust-lang/rust/pull/73526), so let's try re-landing this PR. I've cherry-picked the commits from the original PR (with the exception of the commit blessing test output), making as few modifications as possible. I addressed the rebase fallout in separate commits on top of those. r? `@matthewjasper`
2020-10-05Pass tune-cpu to LLVMMingye Wang-0/+21
I think this is how it should work...
2020-10-04Auto merge of #77023 - HeroicKatora:len-missed-optimization, r=Mark-Simulacrumbors-0/+24
Hint the maximum length permitted by invariant of slices One of the safety invariants of references, and in particular of references to slices, is that they may not cover more than `isize::MAX` bytes. The unsafe `from_raw_parts` constructors of slices explicitly requires the caller to guarantee this fact. Violating it would also be UB with regards to the semantics of generated llvm code. This effectively bounds the length of a (non-ZST) slice from above by a compile time constant. But when the length is loaded from a function argument it appears llvm is not aware of this requirement. The additional value range assertions allow some further elision of code branches, including overflow checks, especially in the presence of artithmetic on the indices. This may have a performance impact, adding more code to a common method but allowing more optimization. I'm not quite sure, is the Rust side of const-prop strong enough to elide the irrelevant match branches? Fixes: #67186
2020-10-04Assume slice len is bounded by allocation sizeAndreas Molzer-0/+24
Uses assume to check the length against a constant upper bound. The inlined result then informs the optimizer of the sound value range. This was tried with unreachable_unchecked before which introduces a branch. This has the advantage of not being executed in sound code but complicates basic blocks. It resulted in ~2% increased compile time in some worst cases. Add a codegen test for the assumption, testing the issue from #67186
2020-10-04Defer creating drop trees in MIR lowering until leaving that scopeMatthew Jasper-3/+3
2020-10-02Auto merge of #77396 - wesleywiser:disable-simplifyarmidentity, r=oli-obkbors-1/+1
Disable the SimplifyArmIdentity mir-opt The optimization still has some bugs that need to be worked out such as #77359. We can try re-enabling this again after the known issues are resolved. r? `@oli-obk`
2020-10-01Disable the SimplifyArmIdentity mir-optWesley Wiser-1/+1
The optimization still has some bugs that need to be worked out such as #77359. We can try re-enabling this again after the known issues are resolved.