about summary refs log tree commit diff
path: root/src/test/codegen
AgeCommit message (Collapse)AuthorLines
2022-07-07Bless codegen test.Camille GILLOT-2/+2
2022-07-06Stop emitting CET prologues for naked functionsJubilee Young-1/+1
We can apply nocf_check as a hack for now.
2022-07-06unit tests that inspect LLVM output directly. This relies on a human being ↵Felix S. Klock II-0/+204
to confirm that the entries actually correspond to what is specified in each of the respective ABIs... updated to incorporate feedback: fix x86_64/i686 tests to use correct name for the corresponding llvm component.
2022-07-05Rollup merge of #98920 - krasimirgg:llvm-15-issue-37945, r=nikicMatthias Krüger-2/+6
adapt issue-37945 codegen test to accept any order of ops Adapt this test to accept `icmp` operands in any order as a follow-up to https://github.com/rust-lang/rust/commit/cbbf06b0cd39dc93033568f1e65f5363cbbdebcd#commitcomment-77670922.
2022-07-05adapt issue-37945 codegen test to accept any order of opsKrasimir Georgiev-2/+6
2022-07-05Auto merge of #96862 - oli-obk:enum_cast_mir, r=RalfJungbors-7/+14
Change enum->int casts to not go through MIR casts. follow-up to https://github.com/rust-lang/rust/pull/96814 this simplifies all backends and even gives LLVM more information about the return value of `Rvalue::Discriminant`, enabling optimizations in more cases.
2022-07-04Avoid unnecessary 1-tuples in derived code.Nicholas Nethercote-1/+1
2022-07-01Amend codegen test.Camille GILLOT-22/+24
2022-06-30Auto merge of #98377 - davidv1992:add-lifetimes-to-argument-temporaries, ↵bors-0/+27
r=oli-obk Added llvm lifetime annotations to function call argument temporaries. The goal of this change is to ensure that llvm will do stack slot optimization on these temporaries. This ensures that in code like: ```rust const A: [u8; 1024] = [0; 1024]; fn copy_const() { f(A); f(A); } ``` we only use 1024 bytes of stack space, instead of 2048 bytes. I am new to developing for the rust compiler, and as such not entirely sure, but I believe this should be sufficient to close #98156. Also, this does not contain a test case to ensure this keeps working, primarily because I am not sure how to go about testing this. I would love some suggestions as to how that could be approached.
2022-06-30Change enum->int casts to not go through MIR casts.Oli Scherer-7/+14
Instead we generate a discriminant rvalue and cast the result of that.
2022-06-25Added test for const arg lifetimes suggested by erikdesjardins.David Venhoek-0/+27
2022-06-25Auto merge of #96820 - r-raymond:master, r=cuviperbors-0/+14
Make RwLockReadGuard covariant Hi, first time contributor here, if anything is not as expected, please let me know. `RwLockReadGoard`'s type constructor is invariant. Since it behaves like a smart pointer to an immutable reference, there is no reason that it should not be covariant. Take e.g. ``` fn test_read_guard_covariance() { fn do_stuff<'a>(_: RwLockReadGuard<'_, &'a i32>, _: &'a i32) {} let j: i32 = 5; let lock = RwLock::new(&j); { let i = 6; do_stuff(lock.read().unwrap(), &i); } drop(lock); } ``` where the compiler complains that &i doesn't live long enough. If `RwLockReadGuard` is covariant, then the above code is accepted because the lifetime can be shorter than `'a`. In order for `RwLockReadGuard` to be covariant, it can't contain a full reference to the `RwLock`, which can never be covariant (because it exposes a mutable reference to the underlying data structure). By reducing the data structure to the required pieces of `RwLock`, the rest falls in place. If there is a better way to do a test that tests successful compilation, please let me know. Fixes #80392
2022-06-21Auto merge of #95576 - DrMeepster:box_erasure, r=oli-obkbors-20/+20
Remove dereferencing of Box from codegen Through #94043, #94414, #94873, and #95328, I've been fixing issues caused by Box being treated like a pointer when it is not a pointer. However, these PRs just introduced special cases for Box. This PR removes those special cases and instead transforms a deref of Box into a deref of the pointer it contains. Hopefully, this is the end of the Box<T, A> ICEs.
2022-06-20UnsafeCell -> RwLockRobin Raymond-4/+3
2022-06-19Make sure we don't match noalias in later linesRobin Raymond-0/+1
2022-06-19Add test to verify noalias is not being addedRobin Raymond-0/+14
2022-06-15remove box derefs from codgenDrMeepster-20/+20
2022-06-15Rollup merge of #98078 - erikdesjardins:uncheckedsize, r=petrochenkovYuki Okushi-0/+29
Use unchecked mul to compute slice sizes This allows LLVM to realize that `slice.len() > 0` iff `slice.len() * size_of::<T>() > 0`, allowing a branch on the latter to be folded into the former when dropping vecs and boxed slices, in some cases. Fixes (partially) #96497
2022-06-14use unchecked mul to compute slice sizesErik Desjardins-0/+29
...since slice sizes can't signed wrap see https://doc.rust-lang.org/std/slice/fn.from_raw_parts.html > The total size len * mem::size_of::<T>() of the slice must be no larger than isize::MAX.
2022-06-14Add VFE test for 32 bitflip1995-0/+36
The offset in the llvm.type.checked.load intrinsic differs on 32 bit platforms
2022-06-14Add test for VFE optimizationflip1995-0/+99
2022-06-08Rollup merge of #97846 - pcwalton:align-bits, r=michaelwoeristerDylan DPC-0/+8
Specify DWARF alignment in bits, not bytes. In DWARF, alignment of types is specified in bits, as is made clear by the parameter name `AlignInBits`. However, `rustc` was incorrectly passing a byte alignment. This commit fixes that. This was noticed in upstream LLVM when I tried to check in a test consisting of LLVM IR generated from `rustc` and it triggered assertions [1]. [1]: https://reviews.llvm.org/D126835
2022-06-07Specify DWARF alignment in bits, not bytes.Patrick Walton-0/+8
In DWARF, alignment of types is specified in bits, as is made clear by the parameter name `AlignInBits`. However, `rustc` was incorrectly passing a byte alignment. This commit fixes that. This was noticed in upstream LLVM when I tried to check in a test consisting of LLVM IR generated from `rustc` and it triggered assertions [1]. [1]: https://reviews.llvm.org/D126835
2022-06-07Auto merge of #97512 - scottmcm:add-coldcc, r=nagisa,lcnrbors-0/+18
Add support for emitting functions with `coldcc` to LLVM The eventual goal is to try using this for things like the internal panicking stuff, to see whether it helps.
2022-06-05Fix the coldcc codegen test on wasm32Scott McMurray-1/+3
2022-05-30Add support for emitting functions with `coldcc` in LLVMScott McMurray-0/+16
The eventual goal is to try using this for things like the internal panicking stuff, to see whether it helps.
2022-05-25Update some codegen tests for opaque pointersNikita Popov-276/+243
2022-05-23Refactor call terminator to always hold a destination placeJakob Degen-1/+1
2022-05-20Auto merge of #97027 - cuviper:yesalias-refcell, r=thomccbors-0/+14
Use pointers in `cell::{Ref,RefMut}` to avoid `noalias` When `Ref` and `RefMut` were based on references, they would get LLVM `noalias` attributes that were incorrect, because that alias guarantee is only true until the guard drops. A `&RefCell` on the same value can get a new borrow that aliases the previous guard, possibly leading to miscompilation. Using `NonNull` pointers in `Ref` and `RefCell` avoids `noalias`. Fixes the library side of #63787, but we still might want to explore language solutions there.
2022-05-18Properly apply path prefix remapping paths emitted into debuginfo.Michael Woerister-1/+1
2022-05-18Rollup merge of #97097 - chorman0773:add_tmm_clobers, r=joshtriplettYuki Okushi-4/+11
Add tmm_reg clobbers This adds support for naming the 8 tile registers from intel AMX as clobbers from `asm!` invocations on x86_64 (only). It does not add the registers as input or output operands.
2022-05-17Auto merge of #96959 - nbdd0121:unwind, r=Amanieubors-8/+13
Prevent unwinding when `-C panic=abort` is used regardless declared ABI Ensures that Rust code will abort with `-C panic=abort` regardless ABI used. ```rust extern "C-unwind" { fn may_unwind(); } // Will be nounwind with `-C panic=abort`, despite `C-unwind` ABI. pub unsafe extern "C-unwind" fn rust_item_that_can_unwind() { may_unwind(); } ``` Current behaviour is that unwind will propagate through. While the current behaviour won't cause unsoundness it is inconsistent with the text reading of [RFC2945](https://rust-lang.github.io/rfcs/2945-c-unwind-abi.html). I tweaked `fn_can_unwind` instead of tweaking `AbortUnwindingCalls` because this approach would allow Rust (non-direct) callers to also see that this function is nounwind, so it can prevent excessive landing pads generation. For more discussions: https://rust-lang.zulipchat.com/#narrow/stream/210922-project-ffi-unwind/topic/soundness.20in.20mixed.20panic.20mode. cc `@alexcrichton,` `@BatmanAoD` r? `@Amanieu` `@rustbot` label: T-compiler T-lang F-c_unwind
2022-05-17fix clobber_abi testsConnor Horman-4/+4
2022-05-17Handle tmm_reg in rustc_codegen_gccConnor Horman-1/+1
2022-05-16add clobbersConnor Horman-0/+7
2022-05-14Auto merge of #95602 - scottmcm:faster-array-intoiter-fold, r=the8472bors-0/+54
Fix `array::IntoIter::fold` to use the optimized `Range::fold` It was using `Iterator::by_ref` in the implementation, which ended up pessimizing it enough that, for example, it didn't vectorize when we tried it in the <https://rust-lang.zulipchat.com/#narrow/stream/257879-project-portable-simd/topic/Reducing.20sum.20into.20wider.20types> conversation. Demonstration that the codegen test doesn't pass on the current nightly: <https://rust.godbolt.org/z/Taxev5eMn>
2022-05-13Test RefCell aliasingJosh Stone-0/+14
2022-05-13Don't hardcode attribute id in codegen testGary Guo-4/+4
2022-05-12Expand c-unwind-abi-panic-abort testGary Guo-4/+9
2022-05-11Add `unsigned_offset_from` on pointersScott McMurray-0/+36
Like we have `add`/`sub` which are the `usize` version of `offset`, this adds the `usize` equivalent of `offset_from`. Like how `.add(d)` replaced a whole bunch of `.offset(d as isize)`, you can see from the changes here that it's fairly common that code actually knows the order between the pointers and *wants* a `usize`, not an `isize`. As a bonus, this can do `sub nuw`+`udiv exact`, rather than `sub`+`sdiv exact`, which can be optimized slightly better because it doesn't have to worry about negatives. That's why the slice iterators weren't using `offset_from`, though I haven't updated that code in this PR because slices are so perf-critical that I'll do it as its own change. This is an intrinsic, like `offset_from`, so that it can eventually be allowed in CTFE. It also allows checking the extra safety condition -- see the test confirming that CTFE catches it if you pass the pointers in the wrong order.
2022-05-12Prevent unwinding when `-C panic=abort` is used regardless declared ABIGary Guo-3/+3
2022-05-09fix codegen test failureRalf Jung-1/+1
2022-05-01Tweak the calloc optimization to only apply to shortish-arraysScott McMurray-0/+32
2022-04-29Fix duplicate directory separator in --remap-path-prefix.Michael Woerister-1/+1
2022-04-25Rollup merge of #96215 - nikic:legacy-pm-removal, r=nagisaMatthias Krüger-7/+5
Drop support for legacy PM with LLVM 15 LLVM 15 already removes some of the legacy PM APIs we're using. This patch forces use of NewPM with LLVM 15 (with `-Z new-llvm-pass-manager=no` throwing a warning) and stubs out various FFI methods with a report_fatal_error on LLVM 15. For LLVMPassManagerBuilderPopulateLTOPassManager() I went with adding our own wrapper, as the alternative would be to muck about with weak symbols, which seems to be non-trivial as far as cross-platform support is concerned (std has `weak!` for this purpose, but only as an internal utility.) Fixes #96072. Fixes #96362.
2022-04-20Rollup merge of #93313 - tmiasko:uninhabited, r=tmandryDylan DPC-1/+1
Check if call return type is visibly uninhabited when building MIR The main motivation behind the change is to expose information about diverging calls to the generator transform and match the precision of drop range tracking which already understands that call expressions with visibly uninhabited types diverges. This change should also accept strictly more programs than before. That is programs that were previously rejected due to errors raised by control-flow sensitive checks in a code that is no longer considered reachable. Fixes #93161.
2022-04-20Drop inaccurate commentNikita Popov-5/+1
The linked issue has an accurate description of the situation, drop the inaccurate comment.
2022-04-19Rollup merge of #95740 - Amanieu:kreg0, r=nagisaDylan DPC-4/+4
asm: Add a kreg0 register class on x86 which includes k0 Previously we only exposed a kreg register class which excludes the k0 register since it can't be used in many instructions. However k0 is a valid register and we need to have a way of marking it as clobbered for clobber_abi. Fixes #94977
2022-04-19asm: Add a kreg0 register class on x86 which includes k0Amanieu d'Antras-4/+4
Previously we only exposed a kreg register class which excludes the k0 register since it can't be used in many instructions. However k0 is a valid register and we need to have a way of marking it as clobbered for clobber_abi. Fixes #94977
2022-04-19Don't use new-llvm-pass-manager=no in testNikita Popov-3/+5