-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[compiler-v2] Do not pop non-droppables on stack flush
Fixes #14233 On stack flush we must not pop values which cannot be dropped. Rather they should be stored in temps. This faciltates scenarios where an `abort` happens before the end of a block. Without this, we pop the value before the abort, leading to a bytecode verification error. There is still an issue with a missing warning, added #14320 for that.
- Loading branch information
Showing
8 changed files
with
77 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
third_party/move/move-compiler-v2/tests/ability-check/bug_14233_unused_non_droppable.exp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
============ bytecode verification succeeded ======== |
9 changes: 9 additions & 0 deletions
9
third_party/move/move-compiler-v2/tests/ability-check/bug_14233_unused_non_droppable.move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module 0xCAFE::Module0 { | ||
struct S {} | ||
|
||
public fun f() { | ||
let _x = S {}; | ||
abort 1; | ||
let S {} = _x; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...rty/move/move-compiler-v2/tests/ability-check/bug_14233_unused_non_droppable_no_abort.exp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
Diagnostics: | ||
error: local `_x` of type `Module0::S` does not have the `drop` ability | ||
┌─ tests/ability-check/bug_14233_unused_non_droppable_no_abort.move:5:18 | ||
│ | ||
5 │ let _x = S {}; | ||
│ ^^^^ implicitly dropped here since it is no longer used |
9 changes: 9 additions & 0 deletions
9
...ty/move/move-compiler-v2/tests/ability-check/bug_14233_unused_non_droppable_no_abort.move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module 0xCAFE::Module0 { | ||
struct S {} | ||
|
||
public fun f() { | ||
let _x = S {}; | ||
//abort 1; | ||
//let S {} = _x; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
...ove-compiler-v2/transactional-tests/tests/optimization/bug_14233_unused_non_droppable.exp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
comparison between v1 and v2 failed: | ||
- processed 2 tasks | ||
+ processed 2 tasks | ||
= | ||
- task 0 'publish'. lines 1-10: | ||
- warning[W09005]: dead or unreachable code | ||
- ┌─ TEMPFILE:7:9 | ||
- │ | ||
- 7 │ let S {} = _x; | ||
- │ ^^^^^^^^^^^^^ Unreachable code. This statement (and any following statements) will not be executed. | ||
- | ||
- | ||
- | ||
= task 1 'run'. lines 12-12: | ||
= Error: Function execution failed with VMError: { | ||
= major_status: ABORTED, | ||
= sub_status: Some(1), | ||
= location: 0xcafe::m, | ||
= indices: redacted, | ||
= offsets: redacted, | ||
= } | ||
= |
12 changes: 12 additions & 0 deletions
12
...ve-compiler-v2/transactional-tests/tests/optimization/bug_14233_unused_non_droppable.move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
//# publish | ||
module 0xCAFE::m { | ||
struct S {} | ||
|
||
public fun f() { | ||
let _x = S {}; | ||
abort 1; | ||
let S {} = _x; | ||
} | ||
} | ||
|
||
//# run 0xCAFE::m::f |