diff options
| author | bors <bors@rust-lang.org> | 2023-06-14 14:20:59 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-06-14 14:20:59 +0000 |
| commit | afa9fef70904bee316d5a73275397d7c4e7c8c4b (patch) | |
| tree | f4c520b318d66dbbcfd1c1aeb5962ff8154386c2 /tests/mir-opt/while_storage.while_loop.PreCodegen.after.panic-abort.mir | |
| parent | 7b0eac438ace0ba305b4633328b00474fbbf5120 (diff) | |
| parent | f67809ac1dca66e98c0999634212532974e43b97 (diff) | |
| download | rust-afa9fef70904bee316d5a73275397d7c4e7c8c4b.tar.gz rust-afa9fef70904bee316d5a73275397d7c4e7c8c4b.zip | |
Auto merge of #112418 - ferrocene:pa-mir-opt-panic, r=ozkanonur,saethlin
Add support for targets without unwinding in `mir-opt`, and improve `--bless` for it The main goal of this PR is to add support for targets without unwinding support in the `mir-opt` test suite, by adding the `EMIT_MIR_FOR_EACH_PANIC_STRATEGY` comment. Similarly to 32bit vs 64bit, when that comment is present, blessed output files will have the `.panic-unwind` or `.panic-abort` suffix, and the right one will be chosen depending on the target's panic strategy. The `EMIT_MIR_FOR_EACH_PANIC_STRATEGY` comment replaced all the `ignore-wasm32` comments in the `mir-opt` test suite, as those comments were added due to `wasm32` being a target without unwinding support. The comment was also added on other tests that were only executed on x86 but were still panic strategy dependent. The `mir-opt` suite was then blessed, which caused a ton of churn as most of the existing output files had to be renamed and (mostly) duplicated with the abort strategy. --- After [asking on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/mir-opt.20tests.20and.20panic.3Dabort), the main concern about this change is it'd make blessing the `mir-opt` suite even harder, as you'd need to both bless it with an unwinding target and an aborting target. This exacerbated the current situation, where you'd need to bless it with a 32bit and a 64bit target already. Because of that, this PR also makes significant enhancements to `--bless` for the `mir-opt` suite, where it will automatically bless the suite four times with different targets, while requiring minimal cross-compilation. To handle the 32bit vs 64bit blessing, there is now an hardcoded list of target mapping between 32bit and 64bit. The goal of the list is to find a related target that will *probably* work without requiring additional cross-compilation toolchains on the system. If a mapping is found, bootstrap will bless the suite with both targets, otherwise just with the current target. To handle the panic strategy blessing (abort vs unwind), I had to resort to what I call "synthetic targets". For each of the target we're blessing (so either the current one, or a 32bit and a 64bit depending on the previous paragraph), bootstrap will extract the JSON spec of the target and change it to include `"panic-strategy": "abort"`. It will then build the standard library with this synthetic target, and bless the `mir-opt` suite with it. As a result of these changes, blessing the `mir-opt` suite will actually bless it two or four times with different targets, ensuring all possible variants are actually blessed. --- This PR is best reviewed commit-by-commit. r? `@jyn514` cc `@saethlin` `@oli-obk`
Diffstat (limited to 'tests/mir-opt/while_storage.while_loop.PreCodegen.after.panic-abort.mir')
| -rw-r--r-- | tests/mir-opt/while_storage.while_loop.PreCodegen.after.panic-abort.mir | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/mir-opt/while_storage.while_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/while_storage.while_loop.PreCodegen.after.panic-abort.mir new file mode 100644 index 00000000000..c12f3591881 --- /dev/null +++ b/tests/mir-opt/while_storage.while_loop.PreCodegen.after.panic-abort.mir @@ -0,0 +1,52 @@ +// MIR for `while_loop` after PreCodegen + +fn while_loop(_1: bool) -> () { + debug c => _1; // in scope 0 at $DIR/while_storage.rs:+0:15: +0:16 + let mut _0: (); // return place in scope 0 at $DIR/while_storage.rs:+0:24: +0:24 + let mut _2: bool; // in scope 0 at $DIR/while_storage.rs:+1:11: +1:22 + let mut _3: bool; // in scope 0 at $DIR/while_storage.rs:+2:12: +2:23 + + bb0: { + goto -> bb1; // scope 0 at $DIR/while_storage.rs:+1:5: +5:6 + } + + bb1: { + StorageLive(_2); // scope 0 at $DIR/while_storage.rs:+1:11: +1:22 + _2 = get_bool(_1) -> [return: bb2, unwind unreachable]; // scope 0 at $DIR/while_storage.rs:+1:11: +1:22 + // mir::Constant + // + span: $DIR/while_storage.rs:11:11: 11:19 + // + literal: Const { ty: fn(bool) -> bool {get_bool}, val: Value(<ZST>) } + } + + bb2: { + switchInt(move _2) -> [0: bb7, otherwise: bb3]; // scope 0 at $DIR/while_storage.rs:+1:11: +1:22 + } + + bb3: { + StorageLive(_3); // scope 0 at $DIR/while_storage.rs:+2:12: +2:23 + _3 = get_bool(_1) -> [return: bb4, unwind unreachable]; // scope 0 at $DIR/while_storage.rs:+2:12: +2:23 + // mir::Constant + // + span: $DIR/while_storage.rs:12:12: 12:20 + // + literal: Const { ty: fn(bool) -> bool {get_bool}, val: Value(<ZST>) } + } + + bb4: { + switchInt(move _3) -> [0: bb5, otherwise: bb6]; // scope 0 at $DIR/while_storage.rs:+2:12: +2:23 + } + + bb5: { + StorageDead(_3); // scope 0 at $DIR/while_storage.rs:+4:9: +4:10 + StorageDead(_2); // scope 0 at $DIR/while_storage.rs:+5:5: +5:6 + goto -> bb1; // scope 0 at $DIR/while_storage.rs:+1:5: +5:6 + } + + bb6: { + StorageDead(_3); // scope 0 at $DIR/while_storage.rs:+4:9: +4:10 + goto -> bb7; // scope 0 at no-location + } + + bb7: { + StorageDead(_2); // scope 0 at $DIR/while_storage.rs:+5:5: +5:6 + return; // scope 0 at $DIR/while_storage.rs:+6:2: +6:2 + } +} |
