forked from FuelLabs/sway
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Traverse IR blocks using a reverse post order traverse of the CFG (Fu…
…elLabs#3942) Closes FuelLabs#3815 This change updates how IR blocks are traversed when compiling them into assembly. Specifically, a reverse post-order traversal is used. Following this order forces all IR values to be converted to registers before all their uses. Even though the initial IR (out of IR gen) may have the right order of blocks, CFG-altering passes like simplify-cfg can change that order, so a correct traversal of the final CFG is needed.
- Loading branch information
1 parent
0e204d5
commit fb2503b
Showing
7 changed files
with
55 additions
and
11 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
13 changes: 13 additions & 0 deletions
13
test/src/e2e_vm_tests/test_programs/should_pass/language/complex_cfg/Forc.lock
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,13 @@ | ||
[[package]] | ||
name = 'complex_cfg' | ||
source = 'member' | ||
dependencies = ['std'] | ||
|
||
[[package]] | ||
name = 'core' | ||
source = 'path+from-root-8B200AD7FF2D8C10' | ||
|
||
[[package]] | ||
name = 'std' | ||
source = 'path+from-root-8B200AD7FF2D8C10' | ||
dependencies = ['core'] |
8 changes: 8 additions & 0 deletions
8
test/src/e2e_vm_tests/test_programs/should_pass/language/complex_cfg/Forc.toml
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,8 @@ | ||
[project] | ||
authors = ["Fuel Labs <[email protected]>"] | ||
entry = "main.sw" | ||
license = "Apache-2.0" | ||
name = "complex_cfg" | ||
|
||
[dependencies] | ||
std = { path = "../../../../../../../sway-lib-std" } |
16 changes: 16 additions & 0 deletions
16
test/src/e2e_vm_tests/test_programs/should_pass/language/complex_cfg/src/main.sw
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,16 @@ | ||
script; | ||
|
||
use std::u128::U128; | ||
|
||
pub enum Error { | ||
Overflow: (), | ||
} | ||
|
||
fn main() { | ||
let x = U128 { | ||
upper: 0, | ||
lower: 0, | ||
}; | ||
let cond = false; | ||
require(cond || (x < U128::from((1, 1)) || x == U128::from((1, 1))), Error::Overflow); | ||
} |
3 changes: 3 additions & 0 deletions
3
test/src/e2e_vm_tests/test_programs/should_pass/language/complex_cfg/test.toml
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,3 @@ | ||
category = "run" | ||
expected_result = { action = "return", value = 0 } | ||
validate_abi = false |
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
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