about summary refs log tree commit diff
path: root/src/test/mir-opt
AgeCommit message (Collapse)AuthorLines
2022-04-16Make derefer work everwhereouz-a-221/+511
Co-Authored-By: Oli Scherer <332036+oli-obk@users.noreply.github.com>
2022-04-14Update inline-into-box-place test outputEduardo Sánchez Muñoz-2/+2
2022-04-11Extend the MIR validator to check many more things around rvalues.Jakob Degen-21/+21
2022-04-11Remove inlining cost of `Deinit` statementsJakob Degen-109/+263
2022-04-11Add new `MutatatingUseContext`s for deinit and `SetDiscriminant`Jakob Degen-13/+26
2022-04-11Fix tests broken by deaggregation changeJakob Degen-464/+618
2022-04-11Bless tests that broke in a trivial way due to change in deaggregationJakob Degen-0/+7
2022-04-10Rollup merge of #95857 - ouz-a:mir-opt, r=oli-obkDylan DPC-0/+109
Allow multiple derefs to be splitted in deref_separator Previously in #95649 only a single deref within projection was supported and multiple derefs caused a bunch of issues, this PR fixes those issues. ```@oli-obk``` helped a ton again ❤️
2022-04-09support multiple derefsouz-a-0/+109
2022-04-06Rollup merge of #95649 - ouz-a:mir-opt, r=oli-obkDylan DPC-4/+115
New mir-opt deref_separator This adds a new mir-opt that split certain derefs into this form: `let x = (*a.b).c;` to => `tmp = a.b; let x = (*tmp).c;` Huge thanks to ``@oli-obk`` for his patient mentoring.
2022-04-06enhance `ConstGoto` mir-opt by moving up `StorageDead` statementsSparrowLii-118/+151
2022-04-05kill temp earlyouz-a-3/+3
2022-04-05mir-interpret now treats unions as non-immediate, even if they have scalar ↵Oli Scherer-40/+54
layout, allowing partially initializing them
2022-04-04destroy temp at the end and avoid ICEouz-a-4/+4
2022-04-04fixed error, made function leaner and tighterouz-a-59/+30
2022-04-04New mir-opt deref_separatorouz-a-22/+162
2022-03-24Check if call return type is visibly uninhabited when building MIRTomasz Miąsko-26/+25
2022-03-10Disable the test on wasm32Scott McMurray-51/+52
Since the expected output has unwind targets
2022-03-10mir-opt: Replace clone on primitives with copyScott McMurray-0/+99
We can't do it for everything, but it would be nice to at least stop making calls to clone methods in debug from things like derived-clones.
2022-03-09manually bless 32-bit stderrb-naber-7/+7
2022-03-09normalization change and rebaseb-naber-41/+21
2022-03-09bless testsb-naber-35/+57
2022-02-27Only create a single expansion for each inline integration.Camille GILLOT-466/+466
2022-02-24Remove an unnecessary restriction in `dest_prop`Jakob Degen-7/+13
2022-02-22change `mir::Constant` in mir dumpslcnr-317/+84
2022-02-21Rollup merge of #94156 - tmiasko:pp-str, r=petrochenkovMatthias Krüger-32/+46
Gracefully handle non-UTF-8 string slices when pretty printing Fixes #78520.
2022-02-20Revert "Auto merge of #93800 - b-naber:static-initializers-mir-val, r=oli-obk"Mark Rousskov-6/+43
This reverts commit a240ccd81c74c105b6f5fe84c46f8d36edb7e306, reversing changes made to 393fdc10483da930cdbb00eabc3635030d2e776f. This PR was likely responsible for a relatively large regression in dist-x86_64-msvc-alt builder times, from approximately 1.7 to 2.8 hours, bringing that builder into the pool of the slowest builders we currently have. This seems to be limited to the alt builder due to needing parallel-compiler enabled, likely leading to slow LLVM compilation for some reason.
2022-02-20Gracefully handle non-UTF-8 string slices when pretty printingTomasz Miąsko-32/+46
2022-02-20Auto merge of #93387 - JakobDegen:improve_partialeq, r=tmiaskobors-17/+128
Extend uninhabited enum variant branch elimination to also affect fallthrough The `uninhabited_enum_branching` mir opt eliminates branches on variants where the data is uninhabited. This change extends this pass to also ensure that the `otherwise` case points to a trivially unreachable bb if all inhabited variants are present in the non-otherwise branches. I believe it was `@scottmcm` who said that LLVM eliminates some of this information in its SimplifyCFG pass. This is unfortunate, but this change should still be at least a small improvement in principle (I don't think it will show up on any benchmarks)
2022-02-19Fix pretty printing of enums without variantsTomasz Miąsko-65/+71
92d20c4aaddea9507f8ad37fe37c551219153bbf removed no-variants special case from try_destructure_const with expectation that this case would be handled gracefully when read_discriminant returns an error. Alas in that case read_discriminant succeeds while returning a non-existing variant, so the special case is still necessary.
2022-02-18Add test checking that fallthrough branches are correctly identified as deadJakob Degen-17/+128
2022-02-17Fix ScalarInt to char conversionTomasz Miąsko-18/+38
to avoid panic for invalid Unicode scalar values
2022-02-16Rollup merge of #94020 - tmiasko:pp, r=oli-obkMatthias Krüger-0/+72
Support pretty printing of invalid constants Make it possible to pretty print invalid constants by introducing a fallible variant of `destructure_const` and falling back to debug formatting when it fails. Closes #93688.
2022-02-16Support pretty printing of invalid constantsTomasz Miąsko-0/+72
Make it possible to pretty print invalid constants by introducing a fallible variant of `destructure_const` and falling back to debug formatting when it fails.
2022-02-15try to bless 32bit mir tests manuallyb-naber-11/+2
2022-02-15bless mir-opt testsb-naber-4/+147
2022-02-15bless testsb-naber-179/+8
2022-02-07Auto merge of #93179 - Urgau:unreachable-2021, r=m-ou-se,oli-obkbors-5/+5
Fix invalid special casing of the unreachable! macro This pull-request fix an invalid special casing of the `unreachable!` macro in the same way the `panic!` macro was solved, by adding two new internal only macros `unreachable_2015` and `unreachable_2021` edition dependent and turn `unreachable!` into a built-in macro that do dispatching. This logic is stolen from the `panic!` macro. ~~This pull-request also adds an internal feature `format_args_capture_non_literal` that allows capturing arguments from formatted string that expanded from macros. The original RFC #2795 mentioned this as a future possibility. This feature is [required](https://github.com/rust-lang/rust/issues/92137#issuecomment-1018630522) because of concatenation that needs to be done inside the macro:~~ ```rust $crate::concat!("internal error: entered unreachable code: ", $fmt) ``` **In summary** the new behavior for the `unreachable!` macro with this pr is: Edition 2021: ```rust let x = 5; unreachable!("x is {x}"); ``` ``` internal error: entered unreachable code: x is 5 ``` Edition <= 2018: ```rust let x = 5; unreachable!("x is {x}"); ``` ``` internal error: entered unreachable code: x is {x} ``` Also note that the change in this PR are **insta-stable** and **breaking changes** but this a considered as being a [bug](https://github.com/rust-lang/rust/issues/92137#issuecomment-998441613). If someone could start a perf run and then a crater run this would be appreciated. Fixes https://github.com/rust-lang/rust/issues/92137
2022-02-04Rollup merge of #90132 - joshtriplett:stabilize-instrument-coverage, ↵Matthias Krüger-4/+4
r=wesleywiser Stabilize `-Z instrument-coverage` as `-C instrument-coverage` (Tracking issue for `instrument-coverage`: https://github.com/rust-lang/rust/issues/79121) This PR stabilizes support for instrumentation-based code coverage, previously provided via the `-Z instrument-coverage` option. (Continue supporting `-Z instrument-coverage` for compatibility for now, but show a deprecation warning for it.) Many, many people have tested this support, and there are numerous reports of it working as expected. Move the documentation from the unstable book to stable rustc documentation. Update uses and documentation to use the `-C` option. Addressing questions raised in the tracking issue: > If/when stabilized, will the compiler flag be updated to -C instrument-coverage? (If so, the -Z variant could also be supported for some time, to ease migrations for existing users and scripts.) This stabilization PR updates the option to `-C` and keeps the `-Z` variant to ease migration. > The Rust coverage implementation depends on (and automatically turns on) -Z symbol-mangling-version=v0. Will stabilizing this feature depend on stabilizing v0 symbol-mangling first? If so, what is the current status and timeline? This stabilization PR depends on https://github.com/rust-lang/rust/pull/90128 , which stabilizes `-C symbol-mangling-version=v0` (but does not change the default symbol-mangling-version). > The Rust coverage implementation implements the latest version of LLVM's Coverage Mapping Format (version 4), which forces a dependency on LLVM 11 or later. A compiler error is generated if attempting to compile with coverage, and using an older version of LLVM. Given that LLVM 13 has now been released, requiring LLVM 11 for coverage support seems like a reasonable requirement. If people don't have at least LLVM 11, nothing else breaks; they just can't use coverage support. Given that coverage support currently requires a nightly compiler and LLVM 11 or newer, allowing it on a stable compiler built with LLVM 11 or newer seems like an improvement. The [tracking issue](https://github.com/rust-lang/rust/issues/79121) and the [issue label A-code-coverage](https://github.com/rust-lang/rust/labels/A-code-coverage) link to a few open issues related to `instrument-coverage`, but none of them seem like showstoppers. All of them seem like improvements and refinements we can make after stabilization. The original `-Z instrument-coverage` support went through a compiler-team MCP at https://github.com/rust-lang/compiler-team/issues/278 . Based on that, `@pnkfelix` suggested that this needed a stabilization PR and a compiler-team FCP.
2022-01-31Fix invalid special casing of the unreachable! macroLoïc BRANSTETT-5/+5
2022-01-26Auto merge of #91840 - JakobDegen:fix_early_otherwise, r=oli-obkbors-97/+219
Fix the unsoundness in the `early_otherwise_branch` mir opt pass Closes #78496 . This change is a significant rewrite of much of the pass. Exactly what it does is documented in the source file (with ascii art!), and all the changes that are made to the MIR that are not trivially sound are carefully documented. That being said, this is my first time touching MIR, so there are probably some invariants I did not know about that I broke. This version of the optimization is also somewhat more flexible than the original; for example, we do not care how or where the value on which the parent is switching is computed. There is no requirement that any types be the same. This could be made even more flexible in the future by allowing a wider range of statements in the bodies of `BBC, BBD` (as long as they are all the same of course). This should be a good first step though. Probably needs a perf run. r? `@oli-obk` who reviewed things the last time this was touched
2022-01-21Auto merge of #93173 - matthiaskrgr:rollup-49bj7ta, r=matthiaskrgrbors-2/+2
Rollup of 10 pull requests Successful merges: - #91965 (Add more granular `--exclude` in `x.py`) - #92467 (Ensure that early-bound function lifetimes are always 'local') - #92586 (Set the allocation MIN_ALIGN for espidf to 4.) - #92835 (Improve error message for key="value" cfg arguments.) - #92843 (Improve string concatenation suggestion) - #92963 (Implement tuple array diagnostic) - #93046 (Use let_else in even more places) - #93109 (Improve `Arc` and `Rc` documentation) - #93134 (delete `Stdin::split` forwarder) - #93139 (rustdoc: fix overflow-wrap for table layouts) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-01-21Rollup merge of #92467 - Aaron1011:extern-local-region, r=oli-obkMatthias Krüger-2/+2
Ensure that early-bound function lifetimes are always 'local' During borrowchecking, we treat any free (early-bound) regions on the 'defining type' as `RegionClassification::External`. According to the doc comments, we should only have 'external' regions when checking a closure/generator. However, a plain function can also have some if its regions be considered 'early bound' - this occurs when the region is constrained by an argument, appears in a `where` clause, or in an opaque type. This was causing us to incorrectly mark these regions as 'external', which caused some diagnostic code to act as if we were referring to a 'parent' region from inside a closure. This PR marks all instantiated region variables as 'local' when we're borrow-checking something other than a closure/generator/inline-const.
2022-01-21Override rustc version in ui and mir-opt tests to get stable hashesThe 8472-24/+24
Building a dozen separate regexps for each test in compiletest consumes significant amounts of CPU cycles. Using `RUSTC_FORCE_INCR_COMP_ARTIFACT_HEADER` stabilizes hashes calcuated for the individual tests so no test-dependent normalization is needed. Hashes for the standard library still change so some normalizations are still needed.
2022-01-17Auto merge of #92816 - tmiasko:rm-llvm-asm, r=Amanieubors-210/+0
Remove deprecated LLVM-style inline assembly The `llvm_asm!` was deprecated back in #87590 1.56.0, with intention to remove it once `asm!` was stabilized, which already happened in #91728 1.59.0. Now it is time to remove `llvm_asm!` to avoid continued maintenance cost. Closes #70173. Closes #92794. Closes #87612. Closes #82065. cc `@rust-lang/wg-inline-asm` r? `@Amanieu`
2022-01-15initial revertEllen-23/+23
2022-01-12Remove mir-opt tests for LLVM-style inline assemblyTomasz Miąsko-210/+0
2022-01-01Stabilize -Z instrument-coverage as -C instrument-coverageJosh Triplett-4/+4
Continue supporting -Z instrument-coverage for compatibility for now, but show a deprecation warning for it. Update uses and documentation to use the -C option. Move the documentation from the unstable book to stable rustc documentation.
2021-12-31Ensure that early-bound function lifetimes are always 'local'Aaron Hill-2/+2
During borrowchecking, we treat any free (early-bound) regions on the 'defining type' as `RegionClassification::External`. According to the doc comments, we should only have 'external' regions when checking a closure/generator. However, a plain function can also have some if its regions be considered 'early bound' - this occurs when the region is constrained by an argument, appears in a `where` clause, or in an opaque type. This was causing us to incorrectly mark these regions as 'external', which caused some diagnostic code to act as if we were referring to a 'parent' region from inside a closure. This PR marks all instantiated region variables as 'local' when we're borrow-checking something other than a closure/generator/inline-const.
2021-12-21Use panic() instead of panic!() in some places in core.Mara Bos-4/+4