summary refs log tree commit diff
path: root/src/test/codegen
AgeCommit message (Collapse)AuthorLines
2021-06-19Revert "Allow specifying alignment for functions"Mark Rousskov-9/+0
This reverts commit 448d07683a6defd567996114793a09c9a8aef5df.
2021-06-06Auto merge of #79608 - alessandrod:bpf, r=nagisabors-0/+11
BPF target support This adds `bpfel-unknown-none` and `bpfeb-unknown-none`, two new no_std targets that generate little and big endian BPF. The approach taken is very similar to the cuda target, where `TargetOptions::obj_is_bitcode` is enabled and code generation is done by the linker. I added the targets to `dist-various-2`. There are [some tests](https://github.com/alessandrod/bpf-linker/tree/main/tests/assembly) in bpf-linker and I'm planning to add more. Those are currently not ran as part of rust CI.
2021-06-02Update generator testsWesley Wiser-16/+16
2021-05-30BPF: remove unnecessary flags from src/test/codegen/bpf-alu32.rsAlessandro Decina-1/+0
2021-05-29BPF: fix #[target_feature(enable = "alu32")]Alessandro Decina-0/+12
2021-05-19Auto merge of #84876 - alexcrichton:inline-thread-locals-cross-crate, ↵bors-0/+56
r=Mark-Simulacrum std: Attempt again to inline thread-local-init across crates Issue #25088 has been part of `thread_local!` for quite some time now. Historical attempts have been made to add `#[inline]` to `__getit` in #43931, #50252, and #59720, but these attempts ended up not landing at the time due to segfaults on Windows. In the interim though with `const`-initialized thread locals AFAIK this is the only remaining bug which is why you might want to use `#[thread_local]` over `thread_local!`. As a result I figured it was time to resubmit this and see how it fares on CI and if I can help debugging any issues that crop up. Closes #25088
2021-05-18Auto merge of #84767 - scottmcm:try_trait_actual, r=lcnrbors-2/+19
Implement the new desugaring from `try_trait_v2` ~~Currently blocked on https://github.com/rust-lang/rust/issues/84782, which has a PR in https://github.com/rust-lang/rust/pull/84811~~ Rebased atop that fix. `try_trait_v2` tracking issue: https://github.com/rust-lang/rust/issues/84277 Unfortunately this is already touching a ton of things, so if you have suggestions for good ways to split it up, I'd be happy to hear them. (The combination between the use in the library, the compiler changes, the corresponding diagnostic differences, even MIR tests mean that I don't really have a great plan for it other than trying to have decently-readable commits. r? `@ghost` ~~(This probably shouldn't go in during the last week before the fork anyway.)~~ Fork happened.
2021-05-18No matter how trivial the change, tidy always finds a way to complain...Scott McMurray-2/+2
2021-05-18Mention the issue number for the new mir-opt in the FIXMEs scottmcm-1/+1
Thanks for the suggestions, lcnr! Co-authored-by: lcnr <rust@lcnr.de>
2021-05-18std: Attempt again to inline thread-local-init across cratesAlex Crichton-0/+56
Issue #25088 has been part of `thread_local!` for quite some time now. Historical attempts have been made to add `#[inline]` to `__getit` in #43931, #50252, and #59720, but these attempts ended up not landing at the time due to segfaults on Windows. In the interim though with `const`-initialized thread locals AFAIK this is the only remaining bug which is why you might want to use `#[thread_local]` over `thread_local!`. As a result I figured it was time to resubmit this and see how it fares on CI and if I can help debugging any issues that crop up. Closes #25088
2021-05-17rustc_codegen_ssa: only create backend `BasicBlock`s as-needed.Eduard-Mihai Burtescu-6/+9
2021-05-16Auto merge of #84549 - tmiasko:static-initializer, r=varkorbors-4/+0
Reachable statics have reachable initializers Static initializer can read other statics. Initializers are evaluated at compile time, and so their content could become inlined into another crate. Ensure that initializers of reachable statics are also reachable. Previously, when an item incorrectly considered to be unreachable was reached from another crate an attempt would be made to codegen it. The attempt could fail with an ICE (in the case MIR wasn't available to do so) in some circumstances the attempt could also succeed resulting in a local codegen of non-local items, including static ones. Fixes #84455.
2021-05-12Auto merge of #83813 - cbeuw:remap-std, r=michaelwoeristerbors-0/+15
Fix `--remap-path-prefix` not correctly remapping `rust-src` component paths and unify handling of path mapping with virtualized paths This PR fixes #73167 ("Binaries end up containing path to the rust-src component despite `--remap-path-prefix`") by preventing real local filesystem paths from reaching compilation output if the path is supposed to be remapped. `RealFileName::Named` introduced in #72767 is now renamed as `LocalPath`, because this variant wraps a (most likely) valid local filesystem path. `RealFileName::Devirtualized` is renamed as `Remapped` to be used for remapped path from a real path via `--remap-path-prefix` argument, as well as real path inferred from a virtualized (during compiler bootstrapping) `/rustc/...` path. The `local_path` field is now an `Option<PathBuf>`, as it will be set to `None` before serialisation, so it never reaches any build output. Attempting to serialise a non-`None` `local_path` will cause an assertion faliure. When a path is remapped, a `RealFileName::Remapped` variant is created. The original path is preserved in `local_path` field and the remapped path is saved in `virtual_name` field. Previously, the `local_path` is directly modified which goes against its purpose of "suitable for reading from the file system on the local host". `rustc_span::SourceFile`'s fields `unmapped_path` (introduced by #44940) and `name_was_remapped` (introduced by #41508 when `--remap-path-prefix` feature originally added) are removed, as these two pieces of information can be inferred from the `name` field: if it's anything other than a `FileName::Real(_)`, or if it is a `FileName::Real(RealFileName::LocalPath(_))`, then clearly `name_was_remapped` would've been false and `unmapped_path` would've been `None`. If it is a `FileName::Real(RealFileName::Remapped{local_path, virtual_name})`, then `name_was_remapped` would've been true and `unmapped_path` would've been `Some(local_path)`. cc `@eddyb` who implemented `/rustc/...` path devirtualisation
2021-05-09PR feedbackScott McMurray-4/+4
2021-05-06mir-opt & codegen test updatesScott McMurray-2/+19
`SimplifyArm` and such are currently in `-Zunsound-mir-opts` and thus weren't running by default, so having something like them for the new desugar shouldn't be necessary for switching.
2021-05-05Add -Z simulate-remapped-rust-src-base option to simulate path ↵Andy Wang-3/+6
virutalisation during bootstrapping
2021-05-04Add test for --remap-path-prefix on std importsAndy Wang-0/+12
2021-05-02Rollup merge of #84752 - lrh2000:generator-debuginfo, r=tmandryDylan DPC-40/+66
Fix debuginfo for generators First, all fields except the discriminant (including `outer_fields`) should be put into structures inside the variant part, which gives an equivalent layout but offers us much better integration with debuggers. Second, artificial flags in generator variants should be removed. - Literally, variants are not artificial. We have `yield` statements, upvars and inner variables in the source code. - Functionally, we don't want debuggers to suppress the variants. It contains the state of the generator, which is useful when debugging. So they shouldn't be marked artificial. - Debuggers may use artificial flags to find the active variant. In this case, marking variants artificial will make debuggers not work properly. Fixes #62572. Fixes #79009. And refer https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Debuginfo.20for.20generators.
2021-05-01Auto merge of #84658 - Amanieu:reserved_regs, r=petrochenkovbors-2/+2
Be stricter about rejecting LLVM reserved registers in asm! LLVM will silently produce incorrect code if these registers are used as operands. cc `@rust-lang/wg-inline-asm`
2021-04-30Remove artificial flag from generator variantslrh2000-40/+66
- Literally, variants are not artificial. We have `yield` statements, upvars and inner variables in the source code. - Functionally, we don't want debuggers to suppress the variants. It contains the state of the generator, which is useful when debugging. So they shouldn't be marked artificial. - Debuggers may use artificial flags to find the active variant. In this case, marking variants artificial will make debuggers not work properly. Fixes #79009.
2021-04-29Remove tests introduced or cahnged by PR #77885, which is reverted in this PR.Felix S. Klock II-2/+0
2021-04-28Be stricter about rejecting LLVM reserved registers in asm!Amanieu d'Antras-2/+2
2021-04-25Reachable statics have reachable initializersTomasz Miąsko-4/+0
Static initializer can read other statics. Initializers are evaluated at compile time, and so their content could become inlined into another crate. Ensure that initializers of reachable statics are also reachable. Previously, when an item incorrectly considered to be unreachable was reached from another crate an attempt would be made to codegen it. The attempt could fail with an ICE (in the case MIR wasn't available to do so) in some circumstances the attempt could also succeed resulting in a local codegen of non-local items, including static ones.
2021-04-23Update wasm test assertionsAlex Crichton-173/+12
2021-04-17Don't set `fast`(-math) for certain simd opsSimonas Kazlauskas-98/+121
`fast-math` implies things like functions not being able to accept as an argument or return as a result, say, `inf` which made these functions confusingly named or behaving incorrectly, depending on how you interpret it. Since the time when these intrinsics have been implemented the intrinsics user's (stdsimd) approach has changed significantly and so now it is required that these intrinsics operate normally rather than in "whatever" way. Fixes #84268
2021-04-11Allow using `-C force-unwind-tables=no` when `panic=unwind`hyd-dev-1/+11
2021-04-06Auto merge of #81234 - repnop:fn-alignment, r=lcnrbors-0/+9
Allow specifying alignment for functions Fixes #75072 This allows the user to specify alignment for functions, which can be useful for low level work where functions need to necessarily be aligned to a specific value. I believe the error cases not covered in the match are caught earlier based on my testing so I had them just return `None`.
2021-04-06Auto merge of #83592 - nagisa:nagisa/dso_local, r=davidtwcobors-114/+119
Set dso_local for hidden, private and local items This should probably have no real effect in most cases, as e.g. `hidden` visibility already implies `dso_local` (or at least LLVM IR does not preserve the `dso_local` setting if the item is already `hidden`), but it should fix `-Crelocation-model=static` and improve codegen in executables. Note that this PR does not exhaustively port the logic in [clang], only the portion that is necessary to fix a regression from LLVM 12 that relates to `-Crelocation_model=static`. Fixes #83335 [clang]: https://github.com/llvm/llvm-project/blob/3001d080c813da20b329303bf8f45451480e5905/clang/lib/CodeGen/CodeGenModule.cpp#L945-L1039
2021-04-05Allow specifying alignment for functionsWesley Norris-0/+9
2021-04-05Auto merge of #83819 - AngelicosPhosphoros:issue-73338-fix-partial-eq-impl, ↵bors-0/+39
r=Mark-Simulacrum Optimize jumps in PartialOrd le Closes https://github.com/rust-lang/rust/issues/73338 This change stops default implementation of `le()` method of PartialOrd from generating jumps.
2021-04-05Rollup merge of #83841 - Amanieu:asm_clobber_feature, r=nagisaDylan DPC-0/+21
Allow clobbering unsupported registers in asm! Previously registers could only be marked as clobbered if the target feature for that register was enabled. This restriction is now removed. cc #81092 r? ``@nagisa``
2021-04-04Optimize PartialOrd leAngelicosPhosphoros-0/+39
Closes https://github.com/rust-lang/rust/issues/73338 This change stops default implementation of `le()` method from generating jumps.
2021-04-04Allow clobbering unsupported registers in asm!Amanieu d'Antras-0/+21
Previously registers could only be marked as clobbered if the target feature for that register was enabled. This restriction is now removed.
2021-04-03Remove redundant `ignore-tidy-linelength` annotationsSimon Jakobi-35/+35
This is step 2 towards fixing #77548. In the codegen and codegen-units test suites, the `//` comment markers were kept in order not to affect any source locations. This is because these tests cannot be automatically `--bless`ed.
2021-04-03Manually set dso_local when its valid to do soSimonas Kazlauskas-114/+119
This should have no real effect in most cases, as e.g. `hidden` visibility already implies `dso_local` (or at least LLVM IR does not preserve the `dso_local` setting if the item is already `hidden`), but it should fix `-Crelocation-model=static` and improve codegen in executables. Note that this PR does not exhaustively port the logic in [clang]. Only the obviously correct portion and what is necessary to fix a regression from LLVM 12 that relates to `-Crelocation_model=static`. Fixes #83335 [clang]: https://github.com/llvm/llvm-project/blob/3001d080c813da20b329303bf8f45451480e5905/clang/lib/CodeGen/CodeGenModule.cpp#L945-L1039
2021-04-01Simplify logical operations CFGAngelicosPhosphoros-0/+46
This is basically same commit as e38e954a0d249f88d0a55504f70d6055e865a931 which was reverted later in 676953fde9120cda62e4ef2f75a804af7481d6af In both cases, this changes weren't benchmarked. e38e954a0d249f88d0a55504f70d6055e865a931 leads to missed optimization described in [this issue](https://github.com/rust-lang/rust/issues/62993) 676953fde9120cda62e4ef2f75a804af7481d6af leads to missed optimization described in [this issue](https://github.com/rust-lang/rust/issues/83623) Also it changes some src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump* files automatically.
2021-03-28Auto merge of #81354 - SkiFire13:binary-search-assume, r=nagisabors-0/+19
Instruct LLVM that binary_search returns a valid index This allows removing bound checks when the return value of `binary_search` is used to index into the slice it was call on. I also added a codegen test for this, not sure if it's the right thing to do (I didn't find anything on the dev guide), but it felt so.
2021-03-25Mark inline asm tests as requiring LLVM 10.0.1Amanieu d'Antras-1/+1
2021-03-25Auto merge of #83387 - cuviper:min-llvm-10, r=nagisabors-1/+0
Update the minimum external LLVM to 10 r? `@nikic`
2021-03-23Allow not emitting `uwtable` on Androidhyd-dev-0/+22
2021-03-22Update the minimum external LLVM to 10Josh Stone-1/+0
2021-03-22Auto merge of #79846 - the8472:inplace-tra, r=m-ou-sebors-0/+14
Use TrustedRandomAccess for in-place iterators where possible This can speed up in-place iterators containing simple casts and transmutes from `Copy` types to any type of same size. `!Copy` types can't be optimized since `TrustedRandomAccess` isn't implemented for those iterators. ``` name on.b ns/iter o1.b ns/iter diff ns/iter diff % speedup vec::bench_transmute 20 (40000 MB/s) 12 (66666 MB/s) -8 -40.00% x 1.67 ```
2021-03-21disable debug assertions in codegen testThe8472-0/+1
2021-03-21Don't compute optimized PointerKind for unoptimized buildsNikita Popov-3/+3
This saves us both the Freeze/Unpin queries, and avoids placing noalias attributes, which have a compile-time impact on LLVM even in optnone builds (due to always_inline functions).
2021-03-21add codegen testThe8472-0/+13
2021-03-21Enable mutable noalias by default for LLVM 12Nikita Popov-3/+3
We don't have any known noalias bugs for LLVM 12 ... yet.
2021-03-21Don't consider !Unpin references as noaliasNikita Popov-0/+15
Such structures may contain self-references, in which case the same location may be accessible through a pointer that is not based-on the noalias pointer. This is still grey area as far as language semantics are concerned, but checking for !Unpin as an indicator for self-referential sturctures seems like a good approach for the meantime.
2021-03-17Auto merge of #82122 - bstrie:dep4real, r=dtolnaybors-1/+1
Deprecate `intrinsics::drop_in_place` and `collections::Bound`, which accidentally weren't deprecated Fixes #82080. I've taken the liberty of updating the `since` values to 1.52, since an unobservable deprecation isn't much of a deprecation (even the detailed release notes never bothered to mention these deprecations). As mentioned in the issue I'm *pretty* sure that using a type alias for `Bound` is semantically equivalent to the re-export; [the reference implies](https://doc.rust-lang.org/reference/items/type-aliases.html) that type aliases only observably differ from types when used on unit structs or tuple structs, whereas `Bound` is an enum.
2021-03-17Auto merge of #83084 - nagisa:nagisa/features-native, r=petrochenkovbors-18/+47
Adjust `-Ctarget-cpu=native` handling in cg_llvm When cg_llvm encounters the `-Ctarget-cpu=native` it computes an explciit set of features that applies to the target in order to correctly compile code for the host CPU (because e.g. `skylake` alone is not sufficient to tell if some of the instructions are available or not). However there were a couple of issues with how we did this. Firstly, the order in which features were overriden wasn't quite right – conceptually you'd expect `-Ctarget-cpu=native` option to override the features that are implicitly set by the target definition. However due to how other `-Ctarget-cpu` values are handled we must adopt the following order of priority: * Features from -Ctarget-cpu=*; are overriden by * Features implied by --target; are overriden by * Features from -Ctarget-feature; are overriden by * function specific features. Another problem was in that the function level `target-features` attribute would overwrite the entire set of the globally enabled features, rather than just the features the `#[target_feature(enable/disable)]` specified. With something like `-Ctarget-cpu=native` we'd end up in a situation wherein a function without `#[target_feature(enable)]` annotation would have a broader set of features compared to a function with one such attribute. This turned out to be a cause of heavy run-time regressions in some code using these function-level attributes in conjunction with `-Ctarget-cpu=native`, for example. With this PR rustc is more careful about specifying the entire set of features for functions that use `#[target_feature(enable/disable)]` or `#[instruction_set]` attributes. Sadly testing the original reproducer for this behaviour is quite impossible – we cannot rely on `-Ctarget-cpu=native` to be anything in particular on developer or CI machines. cc https://github.com/rust-lang/rust/issues/83027 `@BurntSushi`
2021-03-16Adjust `-Ctarget-cpu=native` handling in cg_llvmSimonas Kazlauskas-18/+47
When cg_llvm encounters the `-Ctarget-cpu=native` it computes an explciit set of features that applies to the target in order to correctly compile code for the host CPU (because e.g. `skylake` alone is not sufficient to tell if some of the instructions are available or not). However there were a couple of issues with how we did this. Firstly, the order in which features were overriden wasn't quite right – conceptually you'd expect `-Ctarget-cpu=native` option to override the features that are implicitly set by the target definition. However due to how other `-Ctarget-cpu` values are handled we must adopt the following order of priority: * Features from -Ctarget-cpu=*; are overriden by * Features implied by --target; are overriden by * Features from -Ctarget-feature; are overriden by * function specific features. Another problem was in that the function level `target-features` attribute would overwrite the entire set of the globally enabled features, rather than just the features the `#[target_feature(enable/disable)]` specified. With something like `-Ctarget-cpu=native` we'd end up in a situation wherein a function without `#[target_feature(enable)]` annotation would have a broader set of features compared to a function with one such attribute. This turned out to be a cause of heavy run-time regressions in some code using these function-level attributes in conjunction with `-Ctarget-cpu=native`, for example. With this PR rustc is more careful about specifying the entire set of features for functions that use `#[target_feature(enable/disable)]` or `#[instruction_set]` attributes. Sadly testing the original reproducer for this behaviour is quite impossible – we cannot rely on `-Ctarget-cpu=native` to be anything in particular on developer or CI machines.